[Tutor] Tkinter - How to get multilple windows

Uppala Babu ubabu at cse.iitk.ac.in
Thu Jan 1 13:42:36 EST 2004


>> I have one window which has some buttons and menus. 
>> On clicking the button, how can i get a new window 
>> which has some other buttons and menus.

>Instantiate a new window object which inherits from 
>TopLevel rather than a simple Frame.



from Tkinter import *  # Interface to TK Widgets


#class which has the test button only
#oncliking the test button i need the One more window but here it is 
coming befo
class App(Frame):
        global quitButton , master
        def __init__(self, master=None):
                Frame.__init__(self,master)
                self.grid()
                self.createWidgets()

        def createWidgets(self):
                self.quitButton = 
Button(self,text="Test",command=self.openNew()
                self.quitButton.grid()


        def openNew(self):
                app1 = App1(self)
                app1.mainloop()


#quit class
class App1(Toplevel):
        def __init__(self,master=None):
                Toplevel.__init__(self,master)
                self.grid()
                self.createWidgets()

        def createWidgets(self):
                textButton = Button(self,text="Quit",command=self.quit)
                textButton.grid()
app = App()     #instance of the Application
app.master.title("Sample program")
app.mainloop()          #wait for the events




1. I am getting two windows
2. I want only the object of APP1 to quit not the entire program.

Can any please help me?



-- 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
" Character is repeated habits and
      Only repeated habits can reform the Character "

			 - Swami Vivekananda.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
U.Babu
Parvathi Puram (village)
Madhavaram - 1 (post)
Sidhout (Mandal)
Kadapa (Dist) AP - 516247
----------------------------------------------------
Phones  : 08589-270716(Home)
	  0512-2597592 (Off)
Mail IDs: uppala_babu at yahoo.co.in
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~




More information about the Tutor mailing list