Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This seems to work-around the issue:</p> <pre><code>import wx class Dialog(wx.Dialog): def __init__(self, *args, **kwargs): super(Dialog, self).__init__(*args, **kwargs) self.datepicker = wx.DatePickerCtrl(self) # On wxGTK, intercept all keys: if wx.Platform == '__WXGTK__': comboCtrl = self.datepicker.GetChildren()[0] comboCtrl.Bind(wx.EVT_KEY_DOWN, self.onKey) self.button = wx.Button(self, label='OK') self.button.SetDefault() self.button.Bind(wx.EVT_BUTTON, self.onButton) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(self.datepicker) sizer.Add(self.button) self.SetSizerAndFit(sizer) def onButton(self, event): print self.datepicker.GetValue() self.Close() def onKey(self, event): keyCode = event.GetKeyCode() if keyCode == wx.WXK_RETURN: # Move to the next field so that the contents of the text control, # that might be edited by the user, are updated by the datepicker: self.datepicker.Navigate() # Next, click the default button of the dialog: button = self.GetDefaultItem() click = wx.CommandEvent() click.SetEventType(wx.EVT_BUTTON.typeId) wx.PostEvent(button, click) elif keyCode == wx.WXK_TAB: self.datepicker.Navigate(not event.ShiftDown()) else: event.Skip() class Frame(wx.Frame): def __init__(self, *args, **kwargs): super(Frame, self).__init__(*args, **kwargs) self.button = wx.Button(self, label='Press me to open dialog') self.button.Bind(wx.EVT_BUTTON, self.onButton) def onButton(self, event): dialog = Dialog(self, size=(200,30)) dialog.Show() app = wx.App() frame = Frame(None, size=(200,50)) frame.Show() app.MainLoop() </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.
    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