[Tkinter-discuss] Opening one frame after closing another
Russell E. Owen
rowen at cesmail.net
Mon Jul 9 21:44:25 CEST 2007
In article <469267AF.1060803 at sevasys.com>,
Surya Prakash Garg <surya.garg at sevasys.com> wrote:
> Hello,
>
> I am a newbie in the field of python. I want to create a wizard using
> python language. in which i am creating some buttons to open another
> frame and closing the parent frame. Right now i am facing problems in
> passing arguments from one frame to another frame. for example to
> dispose current frame i use frame1.destroy but am not able to navigate.
> Here is the code.........
Here's a few thoughts:
- Instead of thinking in terms of "passing data from one frame to
another" I suggest you keep the data in an object (the "model").
The different frames then can read and write the data in the model as
necessary. This split (between GUI elements and model) allows you to
tweak the GUI more easily.
To share that model data, create an instance of the data model object as
an attribute of your Application class. Then all methods of the class
can easily get to the data model.
- At the moment it looks as if create_frame1 creates and packs a frame
and then destroys it. I suspect you want create_frame1 to only create
and pack it. Then have callback functions from the various buttons do
the "navigation" by hiding the current frame and showing the next
desired frame.
- The frames might be wanted again (if the user backs up in the process)
so instead of destroying each frame when done I suggest you hang onto
them and just pack_forget/pack (or better yet, grid_remove/grid) as
appropriate.
-- Russell
More information about the Tkinter-discuss
mailing list