Hi
Perhaps not the most descriptive subject, but as you can see from the code I've attached, I'm
trying to work with a dialog which lets the user select from a letter (the actual dialog is a little
more complex, but I simplified it for this mail). Now, if the parent class calls this dialog as a
modal dialog, how can I check whether one button was pressed - except using a button with
ID_OK? Pressing a letter-button should immediately return the letter-value and lead to the next
dialog. (There are a few thousand entries for each letter. That's why I want to use this dialog as a
preselect-dialog for the next one. If one of you has a better idea - I wouldn't mind, too.)
Anyway, I couldn't find a solution on my own nor a hint in the examples.
Thanks a lot in advance,
Christian
my code (truncated):
···
================
import wx
import wx.lib.buttons as buttons
class LetterSelect(wx.Dialog):
def __init__(self):
wx.Dialog.__init__(self,None,-1,'')
sizer1 = wx.BoxSizer(wx.VERTICAL)
<snip>
sizer1.Add(wx.StaticText(self,-1,"Please select one letter."))
<snip>
sizer2 = wx.FlexGridSizer(5,6,2,2)
alph = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
for x in alph:
#id of every button is the ASCII value of the corresponding letter
b = buttons.GenButton(self,ord(x),x)
self.Bind(wx.EVT_BUTTON,self.OnButton,b)
sizer2.Add(b)
sizer1.Add(sizer2)
<snip>
nbuttons = wx.BoxSizer(wx.HORIZONTAL)
nbuttons.Add((VSPACE,-1),0)
b = wx.Button(self,wx.ID_OK,"Okay")
b.SetDefault()
nbuttons.Add(b,0,wx.ALL,10)
nbuttons.Add(wx.Button(self,wx.ID_CANCEL,"Cancel"),0,wx.ALL,10)
<snip>
self.letter = None
def OnButton(self,event):
#to find out which button was pressed the id is back-converted into the letter
self.letter = chr(event.GetId())
def GetValue(self):
return self.letter