DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   Python (http://www.daniweb.com/forums/forum114.html)
-   -   Wondering about new windows in Tkinter (http://www.daniweb.com/forums/thread27818.html)

danizzil14 Jul 10th, 2005 1:18 am
Wondering about new windows in Tkinter
 
Hello all!

Ok here's my problem:

I have a Hello World type program that I want to run in steps, and each step is in a new window. When a "next" button is pressed the old window terminates and a new one is created. Now I don't know much about the command = whatever thingy so I was wondering if you could give me some info on it? Oh and I mostly work with .bind so if so can you give me the example in that form?

Help appreciated.

vegaseat Jul 11th, 2005 9:22 am
Re: Wondering about new windows in Tkinter
 
This snippet will bring up a message window using Toplevel() ...
# display message in a child window

from Tkinter import *

def messageWindow(message):
    # create child window
    win = Toplevel()
    # display message
    Label(win, text=message).pack()
    # quit child window and return to root window
    Button(win, text='OK', command=win.destroy).pack()

def createMessage():
    global counter
    counter = counter + 1
    message = "This is message number " + str(counter)
    messageWindow(message)
   

counter = 0
   
# create root window
root = Tk()
# put a button on it, command executes the given function on button-click
Button(root, text='Bring up Message', command=createMessage).pack()
# start event-loop
root.mainloop()


All times are GMT -4. The time now is 8:53 pm.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC