[wxPython-users] problem with stock button ids

Robin Dunn robin at alldunn.com
Mon Sep 4 10:48:48 PDT 2006


Christian Meesters wrote:
> Hi,
> 
> wanted to make use of stock buttons in a self-made dialog. The code looks like 
> this:
> class MetaDataDialog(wx.Dialog):
>     def __init__(self, *args, **cmds):
> <snip>
> 	self.b = wx.Button(self,wx.ID_SAVE)
>         wx.EVT_BUTTON(self,self.b.GetId(),self.PutValue)
>         self.b.SetDefault()
> 
> Now I'd like to access the ID in a function of the parent frame:
> 
> 	mdatadialog = MetaDataDialog(self,title="Manipulating Meta Data")
> 	if mdatadialog.ShowModal() == wx.ID_SAVE:
> 	
> Clicking on the 'SAVE' button does close the dialog, as programmed in the the 
> function 'PutValue', but I never get mdatadialog.ShowModal() == wx.ID_SAVE to 
> be true. Can anybody point me on my mistake, please?

The value returned from ShowModal is the value passed to EndModal, so in 
your PutValue event handler you need to call self.EndModal(wx.ID_SAVE).


-- 
Robin Dunn
Software Craftsman
http://wxPython.org  Java give you jitters?  Relax with wxPython!





More information about the wxpython-users mailing list