[wxPython-users] Can somebody tell me whats wrong with this code
C M
cmpython at gmail.com
Mon Feb 11 13:56:03 PST 2008
On Feb 11, 2008 1:56 PM, 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 =3D wx.BoxSizer(wx.VERTICAL)
>
> self.stext1 =3D 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 =3D 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 =3Dwx.ID_OK)
> self.Bind(wx.EVT_BUTTON,self.OnCancel,id =3Dwx.ID_CANCEL)
> self.ShowModal()
> self.Destory()
>
> def OnOk(self,event):
> self.Close()
>
> def OnCancel(self,event):
> self.Close()
>
> app =3D wx.App()
> dlg =3D MessageDialog(None, -1,'Error')
> dlg.Show(True)
>
> app.MainLoop()
>
Add
event.Skip()
to your two event handlers under the self.Close() lines.
And change self.Destory() to self.Destroy()
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.wxwidgets.org/pipermail/wxpython-users/attachments/200802=
11/38a8a62a/attachment.htm
More information about the wxpython-users
mailing list