Note that there are some explanatory texts on larger screens.

plurals
  1. POIn linux, wx.PopupWindow don't get any mouse event when it popup from wx.Dialog?
    primarykey
    data
    text
    <p><br/> Hi, everyone.<br/></p> <p>I have a little python GUI program based on wxPython 2.8.x.<br/> It create a wx.Dialog widget and show the dialog by calling ShowModal().<br/> At some situation, the wx.Dialog will show a wx.PopupWindow with a wx.ListCtrl locate inside.<br/> The wx.PopupWindow appears correctly, but trouble comes.<br/> wx.ListCtrl, and its parent widget, wx.PopupWindow, couldn't receive any mouse event,<br/> this cause wx.ListCtrl and wx.PopupWindow have no response while user generate any mouse action.<br/></p> <p>If wx.Dialog is opened by calling Show(),<br/>the above situation won't happen, wx.PopupWindow and wx.ListCtrl work correctly.<br/></p> <p>However, the above situation won't happen in windows version of wxPython 2.8.x even if we show wx.Dialog by calling ShowModal(),<br/>it happen in linux only.<br/></p> <p>Any suggestion?</p> <p>Thanks.</p> <p>Here is my source code.<br/> It may be too long but is easy enough to test the above situation (just copy and paste).<br/></p> <pre><code>#!/usr/bin/env python # -*- coding: utf-8 -*- import sys import wx class TestPopupWindow(wx.PopupWindow): # modify here to change different Widget def __init__(self, *args, **kwargs): super(TestPopupWindow, self).__init__(*args, **kwargs) self.SetSize((200, 200)) self.testButton = wx.Button(self, label='Test') self.testButton.Bind(wx.EVT_BUTTON, self.__onEvtButton, self.testButton) self.Show() def __onEvtButton(self, event): event.Skip() print 'PopupWindow: test button pushed!' self.Hide() class TestDialog(wx.Dialog): def __init__(self, *args, **kwargs): wx.Dialog.__init__(self, *args, **kwargs) panel = wx.Panel(self) panel.SetAutoLayout(True) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Fit(panel) sizer.SetSizeHints(panel) panel.SetSizer(sizer) for i in xrange(2): ctrl = wx.TextCtrl(panel) sizer.Add(ctrl, 0, wx.ADJUST_MINSIZE|wx.EXPAND, 0) for i in xrange(2): ctrl = wx.ComboBox(panel) sizer.Add(ctrl, 0, wx.ADJUST_MINSIZE|wx.EXPAND, 0) self.openPopupWindowButton = wx.Button(panel, label='Open PopupWindow') sizer.Add(self.openPopupWindowButton, 0, 0, 0) standardDialogButtonSizer = wx.StdDialogButtonSizer() self.standardDialogButtonSizerOK = wx.Button(panel, wx.ID_OK) standardDialogButtonSizer.AddButton(self.standardDialogButtonSizerOK) self.standardDialogButtonSizerCancel = wx.Button(panel, wx.ID_CANCEL) standardDialogButtonSizer.AddButton(self.standardDialogButtonSizerCancel) standardDialogButtonSizer.Realize() sizer.Add(standardDialogButtonSizer, 0, wx.EXPAND, 0) panel.Layout() # event binding self.openPopupWindowButton.Bind(wx.EVT_BUTTON, self.__onEvtButtonOpenPopupWindow, self.openPopupWindowButton) self.popupWindow = None # event handler def __onEvtButtonOpenPopupWindow(self, event): event.Skip() if self.popupWindow is not None: self.popupWindow.Close() self.popupWindow = TestPopupWindow(self) class TestFrame(wx.Frame): def __init__(self, *args, **kwargs): wx.Frame.__init__(self, *args, **kwargs) panel = wx.Panel(self) panel.SetAutoLayout(True) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Fit(panel) sizer.SetSizeHints(panel) panel.SetSizer(sizer) self.openButton = wx.Button(panel, label='Open Dialog') sizer.Add(self.openButton, 0, 0, 0) self.openPopupWindowButton = wx.Button(panel, label='Open PopupWindow') sizer.Add(self.openPopupWindowButton, 0, 0, 0) panel.Layout() # event binding self.openButton.Bind(wx.EVT_BUTTON, self.__onEvtButtonOpen, self.openButton) self.openPopupWindowButton.Bind(wx.EVT_BUTTON, self.__onEvtButtonOpenPopupWindow, self.openPopupWindowButton) self.Show() self.popupWindow = None # event handler def __onEvtButtonOpenPopupWindow(self, event): event.Skip() if self.popupWindow is not None: self.popupWindow.Close() self.popupWindow = TestPopupWindow(self) def __onEvtButtonOpen(self, event): event.Skip() dialog = TestDialog(self, title='TestDialog') result = dialog.ShowModal() if result == wx.ID_OK: print &gt;&gt;sys.stderr, 'OK!' else: print &gt;&gt;sys.stderr, 'Cancel!' def main(argv=sys.argv[:]): app = wx.PySimpleApp() frame = TestFrame(None, title='TestFrame', style=wx.TAB_TRAVERSAL|wx.DEFAULT_FRAME_STYLE) app.SetTopWindow(frame) app.MainLoop() return 0 if __name__ == '__main__': sys.exit(main()) </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload