[Tkinter-discuss] A Hello and a Question

Peter Lacroix pjlacroix at hotmail.com
Wed May 3 17:21:03 CEST 2006

Thanks to Olivier for the sample structure. I think I understand it although 
I'm not very familiar with 'lambda'. Now Cameron has brought up a good 
point. By the way, this is an end-of-semester project for students. I am 
teaching Python for the first time to a high school class - so my knowledge 
is certainly limited. We have created a few simple programs but all have 
been command line. So ultimately the goal is simply to learn what GUIs are 
and play around, not to create anything professional. But Cameron's point is 
interesting. That is, have a set of tabs that display where in the process 
of the program the user is. This way they know how far they easily have a 
visual hold on how far they have to go and how far they've been. Of course, 
these tabs would not be clickable. I would want the buttons to cause the 
switch. I think I like that idea. Does it fit with the structure that 
Olivier offered below?

import Tkinter as tk
def change_frame(i, j):

frames = []

r = tk.Tk()

#frames that you fill with your widgets
f1 = tk.Frame(r)
tk.Button(f1, command=lambda :change_frame(0,1),text='go to step 1').pack()

f2 = tk.Frame(r)
tk.Button(f2, command=lambda :change_frame(1,2),text='go to step 2').pack()

f3 = tk.Frame(r)
tk.Label(f3, text = 'step2').pack()

frames = [f1,f2,f3]


From: Cameron Laird <Cameron at phaseit.net>
Reply-To: claird-dated-1146917583.79ef72 at phaseit.net
To: Peter Lacroix <pjlacroix at hotmail.com>
CC: tkinter-discuss at python.org
Subject: Re: [Tkinter-discuss] A Hello and a Question
Date: Wed, 3 May 2006 12:17:02 +0000

On Wed, May 03, 2006 at 11:53:31AM +0000, Peter Lacroix wrote:
 > Hello, I'm new to this list. I've come in search of some answers to
 > questions I hope I can articulate enough to be understood.
 > I would like to know how one would create a button that when clicked 
 > clear the entire set of widgets (including the clicked button itself) and
 > then display a whole new set of widgets.
 > The goal is to write a program that has about 6 different steps the user
 > goes through to submit information. So for instance the first frame would
 > welcome the user and display a "Click to Continue" button. When the 
 > is clicked, the widgets would all disappear and be replaced by a new set 
 > widgets. When these widgets are finsihed being used and the "Continue" or
 > "Submit" button is clicked, again a new set of widgets would replace the
 > old...and so on.
 > I am lost as to how I would design a class(?) that would carry out such a
 > task. Ultimately, when the last set of widgets is finished, the program
 > would revert back to the first set of widgets.
 > Is what I am asking clear? Any help would be appreciated.
It's certainly feasible.  Before answering the technical
question, I recommend a moment more of discussion.

*My* first reaction to your description is that your users
might like a tabbed display, where finishing the interaction
with one tab automatically activates the next.  How does
that sound to you?  My general experience is that it's
disquieting to users to erase an entire application display,
to start over with a new set of widgets; they do better with
an indication of an unchanging "foundation" that structures
the display and interaction.

Express yourself instantly with MSN Messenger! Download today it's FREE! 

More information about the Tkinter-discuss mailing list