Muddy Coder wrote: > Hi Folks, > > I have a problem of handling Toplevel window. Basically, I wrote a > listbox viewer with scrollbars, and saved in file listbo.py. Then in > my main GUI window, with menu, I need to launch the listbox viewer, in > a new window. Obviously, a Toplevel window is needed. But, I failed at > passing parameters over to Toplevel window. Please take a look at my > code: > > Listbox viewer: > class ScrolledList(Frame): > def __init__(self, options, parent=None):
So the first parameter to the constructor is the scrolled list options, and the second one is its parent widget, right? > Frame.__init__(self, parent) > self.pack(expand=YES, fill=BOTH) > self.makeWidgets(options) > > In my main GUI: > from XXX import ScrolledList > class Foo: > def __init__(self): > ........ > def call_listbox(self, params): > new = Toplevel() > alist = ['foor','bar'] > ScrolledList(new,alist) So why are you passing the parent widget as first parameter and something else as second...? On a more general level, unless really needed, I try to avoid creating subclasses of exisiting classes with a constructor with completely different parameters than the super-class's one. I'm usually doing something like: class ScrolledList(Frame): def __init__(self, *args, **options): Frame.__init__(self, *args, **options) The only thing I (rarely...) allow myself to do is to pass custom options and getting/removing them with options.pop('my_option') before calling the super-class's constructor. Otherwise, I just add specific methods; it's far less confusing. HTH - Eric - -- http://mail.python.org/mailman/listinfo/python-list