Hi
I'm trying to create a dialog box with GenBitmapTextButton buttons. When I create the dialog using the standard button, I can use the enter key to push the button, and the escape key to cancel the dialog.
However, when I use the GenBitmapTextButton, neither the enter nor the escape key work. The enter key behaves in the same way as the tab key. I've included a skeleton example below that illustrates the issue (to run the code you merely need to include two images called ok.png and cancel.png in the same directory as the file containg the code).
Do I need to bind some event to the button/dialog to make this work in the same manner as the simple case?
I'm using python version 2.5 and wxpython version 2.8.9.2 on windows
Any help would be greatly appreciated.
import wx
import wx.lib.buttons
class SimpleDialog(wx.Dialog):
def __init__(self, text):
wx.Dialog.__init__(self, parent=None, id=wx.ID_ANY, title="SimpleDialog", pos=wx.DefaultPosition, size=(250,150))
wx.StaticText(self, -1, text, wx.Point(15, 20))
okButton = wx.Button(self, wx.ID_OK, ' OK ', wx.Point(35, 90), wx.DefaultSize)
okButton.SetDefault()
cancelButton = wx.Button(self, wx.ID_CANCEL, ' Cancel ', wx.Point(135, 90), wx.DefaultSize)
class BitmapDialog(wx.Dialog):
def __init__(self, text):
wx.Dialog.__init__(self, parent=None, id=wx.ID_ANY, title="BitmapDialog", pos=wx.DefaultPosition, size=(250,150))
wx.StaticText(self, -1, text, wx.Point(15, 20))
okButton = wx.lib.buttons.GenBitmapTextButton(self, wx.ID_OK, wx.Bitmap('ok.png'), ' OK ', (15, 80), (100, -1))
okButton.SetBezelWidth(3)
okButton.SetDefault()
cancelButton = wx.lib.buttons.GenBitmapTextButton(self, wx.ID_CANCEL, wx.Bitmap('cancel.png'), ' Cancel ', (130, 80), (100, -1))
cancelButton.SetBezelWidth(3)
if __name__ == '__main__':
app = wx.PySimpleApp()
dlg1 = SimpleDialog("SimpleDialog Text")
if dlg1.ShowModal() == wx.ID_OK:
print "SimpleDialog OK"
else:
print "SimpleDialog Cancel"
dlg1.Destroy()
dlg2 = BitmapDialog("BitmapDialog Text")
if dlg2.ShowModal() == wx.ID_OK:
print "BitmapDialog OK"
else:
print "BitmapDialog Cancel"
dlg2.Destroy()
app.MainLoop()