wxpython: bringing up a dialog box with a button

John Salerno johnjsal at NOSPAMgmail.com
Tue Jun 13 16:09:12 EDT 2006


I'm not exactly sure how to call the method ShowModal(). This is what I 
have so far:

--------------

import wx


class InputForm(wx.Frame):

     def __init__(self, parent=None, id=wx.ID_ANY, title=''):
         wx.Frame.__init__(self, parent, id, title)
         panel = wx.Panel(self)

         btnModal = wx.Button(panel, -1, 'Modal')
         dialog = wx.Dialog(self, -1, 'Modal Dialog')
         self.Bind(wx.EVT_BUTTON, dialog.ShowModal, btnModal)

class MyApp(wx.App):

     def OnInit(self):
         frame = InputForm(title='Data Entry Form')
         self.SetTopWindow(frame)
         frame.Show()
         return True


app = MyApp(redirect=False)
app.MainLoop()

---------------------

and this is what I get:

 >>>
Traceback (most recent call last):
   File "C:\Python24\Lib\site-packages\wx-2.6-msw-ansi\wx\_windows.py", 
line 688, in ShowModal
     return _windows_.Dialog_ShowModal(*args, **kwargs)
TypeError: Dialog_ShowModal() takes exactly 1 argument (2 given)
 >>>

Hope someone can correct me here!



More information about the Python-list mailing list