[wxPython] argument passing problem with wxDialog

Hello. Here’s the scoop: I’m creating an address book which contains two classes. the first class is the Main class and creates the ‘main screen’. The second class is the Input class (derived from wxDialog) and creates a screen for user input.

In the first class, I have a menu item which calls a function Add(). Within Add() I then try to create an instance of my second class- passing it the arguments for ID and ‘title’.

In the Input class, I am simply subclassing wxDialog and overriding its init.

Error I keep getting is that the init of wxDialog in my second class requires an int. (I’ve tried passing it number values from the Add() function, assigning default values, etc.).

I’m not sure what I’m doing wrong, but it’s probably more of a misunderstanding of argument passing in Python on my part than a wx problem.

Pseudocode:

class Main(wxFrame): …

 def Add( self, event):        

      additem = Input( int, 'title')               #### I've also tried   (self, int, "title")      but I keep getting error of passing more arguments than expected to class

class Input(wxDialog):

 def __init__(self, ID, title):

      wxDialog.__init__(self, ID, title...)

any help GREATLY appreciated, but please be specific as I’m quite thick headed. :wink:

thanks!

Error I keep getting is that the __init__ of wxDialog in my
second class requires an int. (I've tried passing it number
values from the Add() function, assigning default values, etc.).
          
class Input(wxDialog):
     def __init__(self, ID, title):
          wxDialog.__init__(self, ID, title...)

Try this:

    class Input(wxDialog):
        def __init__(self, parent, ID, title):
            wxDialog.__init__(self, parent, ID, title)

and calling it with

    dlg = Input(self, -1, "a title")

···

--
Robin Dunn
Software Craftsman
robin@AllDunn.com
http://wxPython.org Java give you jitters?
http://wxPROs.com Relax with wxPython!

_______________________________________________
wxPython-users mailing list
wxPython-users@lists.sourceforge.net
http://lists.sourceforge.net/mailman/listinfo/wxpython-users

yep, got it. needed a value for 'parent'. thanks!

···

_______________________________________________
wxPython-users mailing list
wxPython-users@lists.sourceforge.net
http://lists.sourceforge.net/mailman/listinfo/wxpython-users

The documentation should say that the constructor requires the “parent” and “ID” fields–values of -1 for the latter and ether None or the main frame should do…

Chris

···

Chris Fama mailto:Chris.Fama@uq.net.au Phone:(07) 3870 5639
Brisbane, Australia Mobile:(0400) 833 700

After a hundred years / Nobody knows the place,–
Agony, that enacted there, / Motionless as peace.
Weeds triumphant ranged, / Strangers strolled and spelled
At the lone orthography / Of the elder dead.
Winds of summer fields / Recollect the way,–
Instinct picking up the key / Dropped by memory.
- Emily Dickinson

-----Original Message-----
From:
wxpython-users-admin@lists.sourceforge.net [mailto:wxpython-users-admin@lists.sourceforge.net]On Behalf Of Steve A.
Sent: Saturday, 2 December 2000 4:34 AM
To:
wxpython-users@lists.sourceforge.net
Subject: [wxPython] argument passing problem with wxDialog

Hello. Here’s the scoop: I’m creating an address book which contains two classes. the first class is the Main class and creates the ‘main screen’. The second class is the Input class (derived from wxDialog) and creates a screen for user input.

In the first class, I have a menu item which calls a function Add(). Within Add() I then try to create an instance of my second class- passing it the arguments for ID and ‘title’.

In the Input class, I am simply subclassing wxDialog and overriding its init.

Error I keep getting is that the init of wxDialog in my second class requires an int. (I’ve tried passing it number values from the Add() function, assigning default values, etc.).

I’m not sure what I’m doing wrong, but it’s probably more of a misunderstanding of argument passing in Python on my part than a wx problem.

Pseudocode:

class Main(wxFrame): …

   def Add( self, event):        
        additem = Input( int, 'title')               #### I've also tried   (self, int, "title")      but I keep getting error of passing more arguments than expected to class

class Input(wxDialog):

   def __init__(self, ID, title):
        wxDialog.__init__(self, ID, title...)

any help GREATLY appreciated, but please be specific as I’m quite thick headed. :wink:

thanks!