wxpython

wxPython get event ID

﹥>﹥吖頭↗ 提交于 2019-12-13 02:09:00
问题 I have some code, which binds a menu item to a method: def getEventID(self, event): print id # how do I get id? EVT_MENU(self, 123, self.getEventID) So basicly, I want my app to print "123" when the menu item with that ID is pressed. How would I do that? 回答1: You should just be able to use event.GetId() I believe. You can also use event.GetEventObject() to get the widget that fired the event. 来源: https://stackoverflow.com/questions/6791676/wxpython-get-event-id

What event should I bind to before enabling a button in wxPython?

妖精的绣舞 提交于 2019-12-13 01:29:55
问题 I have a simple app that requires 4 file inputs before proceeding to generate an output. Consider btnFile1 btnFile2 btnFile3 and btnFile4 and btnOutput . btnOutput is disabled on init. btnFile1...4 all link to four similar, yet different, methods, call them OnBtn1..4 that assign a variable (call them file1..file4 ) to the file selected using the wx.FileDialog method. I have a helper method, EnableButton() with a simple test: if self.file1 and self.file2 and self.file3 and self.file4: self

Graphics issue upon resizing a panel in wxPython

坚强是说给别人听的谎言 提交于 2019-12-13 01:26:28
问题 I am working with python v2.7 and wxPython v3.0 on Windows 8 OS. (Sorry for the confusing title. I have no idea what the title should be. I shall try my best to explain my problem in detail.) In my app I have a scrolled panel with a background image. This panel is named as mainPanel in the code snippet. This mainPanel contains other panels named as myPanelA and myPanelB that have transparent background. These panels myPanelA and myPanelB contains sizers that are containing some buttons. PS:

Combine key and mouse button events in wxpython panel using matplotlib

对着背影说爱祢 提交于 2019-12-13 01:06:16
问题 In a wxPython panel I want to use matplotlib's Lasso widget. In my implementation Lasso is used in three different functionalities. Nevertheless, in order to accomplish these functionalities I must combine key events with mouse button events. By default, the initial Lasso function can be used by pressing the left mouse button. So, for my first functionality I press the left mouse button, select a region of interest and do something with the points included. For the second functionality, I

How to colour text in StaticText (wxpython) in different colours?

一笑奈何 提交于 2019-12-13 00:38:17
问题 Is it somehow possible to have text of a StaticText field in wxpython coloured in different colours? I know you can change the colour of the whole text (value) of a StaticText field like this: text = wx.StaticText(panel, -1, 'random text') text.SetForegroundColour('blue') But how can I have the a text coloured in different colours, for example 'random' coloured in red and 'text' coloured in blue. Is there a way? Or is there some kind of other widget I could use? 回答1: The wx.StaticText widget

wxPython Whole Window Focus Event

那年仲夏 提交于 2019-12-13 00:06:37
问题 With wxPython, how does one trigger an event whenever the whole window goes into/out of focus? To elaborate, I'm building a serial terminal GUI and would like to close down the connection whenever the user doesn't have my application selected, and re-open the connection whenever the user brings my app back into the foreground. My application is just a single window derived from wx.Frame. 回答1: The correct answer for this case is to use an EVT_ACTIVATE handler bound to the frame. There will be

ScrolledPanel inside Panel not sizing

一笑奈何 提交于 2019-12-12 23:32:36
问题 I've been toying with this for a while and just can't seem to figure it out. self.panel = wx.Panel(self, wx.ID_ANY) I have a scrolledPanel inside a panel that does not scroll. self.panel = wx.Panel(self, wx.ID_ANY) self.stepPanel = wxscrollpanel.ScrolledPanel(self.panel, -1, style=wx.EXPAND) self.stepPanel.SetupScrolling(scrollToTop=False) sizer = wx.BoxSizer(wx.VERTICAL) self.stepPanel.SetSizerAndFit(sizer) Update function goes like this ... sizer = self.stepPanel.GetSizer() # Add some

Reading an image from the clipboard with wxPython [closed]

放肆的年华 提交于 2019-12-12 22:19:37
问题 It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 7 years ago . How can I read an image from the clipboard? I'm able to read text from the clipboard using wx.Clipboard , but not images. Is it possible to read images with wx.Clipboard ? If not, is there another way? I'm using

Transparency issue with matplotlib and wxpython

扶醉桌前 提交于 2019-12-12 19:03:42
问题 I'm developping a GUI based on matplotlib and wxpython, for Windows. I have an issue that becomes visible when the "Windows XP" theme (green Start button, blue taskbar) is used. I'm quite sure the same problem will show up on Vista as well. I know an imperfect workaround, but I can't fix this issue properly. My matplotlib plots are embedded in wxPanels, which are embedded in a wxNotebook (tabs, if you prefer). With some themes, the background colour of the tabs is actually a gradient, and wx

wxPython - Drawing an unfilled rectangle with the DC

最后都变了- 提交于 2019-12-12 18:34:49
问题 dc.SetPen(wx.Pen(wx.BLACK, 0)) dc.SetBrush(wx.Brush("C0C0C0")) dc.DrawRectangle(50,50,50,50) This is my best attempt at drawing a 50x50, gray box with no border. However, setting the pen width to 0 doesn't seem to accomplish anything, and setting the brush only changes the fill from pure white to pure black. Here's it in the context of a panel, in case it's part of the problem: class DrawRect(wx.Panel): def __init__(self,parent=None,id=-1,pos=(-1,-1),size=(-1,-1),style=0): wx.Panel.__init__