[wxPython-users] Can somebody tell me whats wrong with this code

Mark Guagenti mgenti at gentiweb.com
Mon Feb 11 11:12:45 PST 2008


Try:
self.sizer.GetAffirmativeButton()
self.sizer.GetCancelButton()

On 2/11/08, Thippana, Prasoonadevi <pthippan at mc.com> wrote:
>
>
> I am not able to use events with these id wx.ID_OK and wx.ID_CANCEL.
>
>
> import wx
>
> class MessageDialog(wx.Dialog):
>     def __init__(self,parent,id,title):
>         wx.Dialog.__init__(self,parent,id,title)
>
>         self.vt = wx.BoxSizer(wx.VERTICAL)
>
>         self.stext1 = wx.StaticText(self,11,'Close the window')
>         self.vt.AddSpacer(40)
>         self.vt.Add(self.stext1,0,wx.ALIGN_CENTER  )
>         self.vt.AddSpacer(40)
>         self.sizer = self.CreateButtonSizer(wx.OK | wx.CANCEL)
>         self.vt.Add(self.sizer,0,wx.ALIGN_CENTER )
>         self.SetSizer(self.vt)
>         self.Bind(wx.EVT_BUTTON,self.OnOk,id =wx.ID_OK)
>         self.Bind(wx.EVT_BUTTON,self.OnCancel,id =wx.ID_CANCEL)
>         self.ShowModal()
>         self.Destory()
>
>     def OnOk(self,event):
>         self.Close()
>
>     def OnCancel(self,event):
>         self.Close()
>
> app = wx.App()
> dlg = MessageDialog(None, -1,'Error')
> dlg.Show(True)
>
> app.MainLoop()




More information about the wxpython-users mailing list