wxpython

Send variables in dynamically created buttons with wxPython

风格不统一 提交于 2019-12-25 09:58:37
问题 I want to send a variable to a function from dynamically created buttons (14 of them) # creating buttons for i in range(0, 14): m_pauser.append(wx.Button(panel, 5, "Pause "+str(i))) m_pauser[i].Bind(wx.EVT_BUTTON, lambda event: self.dispenser_pause(event, i), m_pauser[i]) box.Add(m_pauser[i], 0, wx.ALL, 10) # function called by buttons def dispenser_pause(self, event, my_value): print my_value The problem is that all buttons always send 13 (the last value of 'i' in the 'for' loop) How can I

Send variables in dynamically created buttons with wxPython

匆匆过客 提交于 2019-12-25 09:58:20
问题 I want to send a variable to a function from dynamically created buttons (14 of them) # creating buttons for i in range(0, 14): m_pauser.append(wx.Button(panel, 5, "Pause "+str(i))) m_pauser[i].Bind(wx.EVT_BUTTON, lambda event: self.dispenser_pause(event, i), m_pauser[i]) box.Add(m_pauser[i], 0, wx.ALL, 10) # function called by buttons def dispenser_pause(self, event, my_value): print my_value The problem is that all buttons always send 13 (the last value of 'i' in the 'for' loop) How can I

Return value from wxpython main frame

无人久伴 提交于 2019-12-25 09:41:18
问题 i am facing some issues to get return value from wxpython main fram. my script: import wx import wx.xrc class Email_template( wx.Frame ): def __init__( self, parent, to, cc, subject, message_boby ): app = wx.App(False) wx.Frame.__init__ ( self, parent, id = wx.ID_ANY, title = wx.EmptyString, pos = wx.DefaultPosition, size = wx.Size( 650,500 ), style = wx.DEFAULT_FRAME_STYLE|wx.TAB_TRAVERSAL ) self.SetSizeHintsSz( wx.DefaultSize, wx.DefaultSize ) self.SetBackgroundColour( wx.SystemSettings

Return value from wxpython main frame

ぐ巨炮叔叔 提交于 2019-12-25 09:37:20
问题 i am facing some issues to get return value from wxpython main fram. my script: import wx import wx.xrc class Email_template( wx.Frame ): def __init__( self, parent, to, cc, subject, message_boby ): app = wx.App(False) wx.Frame.__init__ ( self, parent, id = wx.ID_ANY, title = wx.EmptyString, pos = wx.DefaultPosition, size = wx.Size( 650,500 ), style = wx.DEFAULT_FRAME_STYLE|wx.TAB_TRAVERSAL ) self.SetSizeHintsSz( wx.DefaultSize, wx.DefaultSize ) self.SetBackgroundColour( wx.SystemSettings

How to make wx.statictext text transparent in wxpython

血红的双手。 提交于 2019-12-25 09:26:51
问题 # -*- coding: utf-8 -*- import wx, wx.media import sqlite3 import os import time class MainFream(wx.Frame): def __init__(self): wx.Frame.__init__(self, None) self.leftPanel = wx.Panel(self, size=(0,0)) self.media = wx.media.MediaCtrl(self, #szBackend=wx.media.MEDIABACKEND_GSTREAMER, szBackend=wx.media.MEDIABACKEND_WMP10, size = (0,0), style = wx.SIMPLE_BORDER) image = wx.Image('1.bmp', wx.BITMAP_TYPE_BMP).ConvertToBitmap() self.background = wx.StaticBitmap(self.leftPanel, 0, image, (0,0))

wx python 3.0.2 classic SetFocus blows

送分小仙女□ 提交于 2019-12-25 09:09:43
问题 I had a Progress class that was working fine in 2.8.12.1 unicode: class Progress(bolt.Progress): """Progress as progress dialog.""" def __init__(self,title=_(u'Progress'),message=u' '*60,parent=None, style=wx.PD_APP_MODAL|wx.PD_ELAPSED_TIME|wx.PD_AUTO_HIDE|wx.PD_SMOOTH, abort=False, onAbort=None): if abort: style |= wx.PD_CAN_ABORT self.fnAbort = onAbort self.dialog = wx.ProgressDialog(title,message,100,parent,style) self.dialog.SetFocus() #### line 1295 in the traceback is here #### bolt

wxpython 3.0 & multiprocessing - update GUI from background process

自作多情 提交于 2019-12-25 08:55:00
问题 From my wxpython GUI app I have an rsync task that I kick off as a multiprocessing.Process. The idea is to update a wx.textCtrl with the constant output from this background process. I am using a pubsub subscribe method. The functions work fine but I can't get the textCtrl to update. If I use a CallAfter method I get this crash/error: The process has forked and you cannot use this CoreFoundation functionality safely. You MUST exec(). Break on THE_PROCESS_HAS_FORKED_AND_YOU_CANNOT_USE_THIS

Setting selection background in ListCtrl

丶灬走出姿态 提交于 2019-12-25 08:51:32
问题 I'm trying to set a custom background for selected items in wxPython 2.8. I cannot figure out how to do so. I've tried SetItemBackground with no luck. 回答1: Selected items in wxListCtrl , wxListBox and so on always use the system background selection colour, it can't be changed. 来源: https://stackoverflow.com/questions/22624070/setting-selection-background-in-listctrl

Get inline data from serial

不羁岁月 提交于 2019-12-25 08:43:39
问题 I have a method in my TerminalPanel class when receiving a serial read: def OnSerialRead(self, event): """Handle input from the serial port.""" text = event.data self.text_ctrl_output.AppendText(text) self.GetParent().graphics_panel.get_data(text) Now, inside the TerminalPanel class the text comes out perfectly, but in my GraphicsPanel class (instantiated with graphics_panel somewhere else) I have this method: def get_data(self, text): self.mario = text print self.mario The result is that I

How to use Mac OS X NSEvents within wxPython application?

谁都会走 提交于 2019-12-25 08:32:08
问题 I am writing an application that has to react to system wide keypresses on Mac OS X. So I found some key logger examples that should work and hit a wall, because all examples are based on NSSharedApplication() and PyObjC AppHelper.runEventLoop() while my application is written in wxPython. Here I post a modification of the simplest example from https://github.com/ljos that I thought it should work. But it does not. from AppKit import * import wx class AppDelegate(NSObject): def