newbie question about forms in tkinter

Fredrik Lundh fredrik at pythonware.com
Sun Apr 27 06:42:05 EDT 2003


Eamon Reyn wrote:

> I am creating a little app which needs to have multiple forms pop up but
> whenever I try to create a second form in my application the content I want
> to appear on the new form just gets placed into my existing one. Here is som
> sample code which looks vaguely sane to me but can someone please tell me
> what is wrong with it.

> class Interface2(Frame):
>     def __init__(self, master = None):
>         Frame.__init__(self, master)

here, master=None means that you're adding stuff to the root
window.

>     def newForm(self):
>         myInter2 = Interface2()
>         myInter2.mainloop();

to open the interface in a separate window, create a Toplevel
window, and pass it as the master:

    top = Toplevel()
    top.title("my other window")
    myInter2 = Interface2()

see chapters 8 and 10 of my "introduction to tkinter" book for
more information on toplevels:

    http://www.pythonware.com/library/tkinter/introduction/application-windows.htm
    http://www.pythonware.com/library/tkinter/introduction/dialog-windows.htm

</F>








More information about the Python-list mailing list