Starting a Frame dependent on destruction of another Frame...
Volucris
volucris at hotmail.com
Mon Jul 16 04:44:37 EDT 2001
"Rob Neely" <rneely at home.com> wrote in message
news:6f0b3be9.0107152232.21f297e6 at posting.google.com...
> I have a simple problem I'm trying to solve with Tkinter.
>
> When my application runs, I want a frame to pop up asking the user for
> some info (a directory name). When they hit the "OK" button, I want
> that frame to destroy itself, and start up another toplevel frame
> which will be populated with some widgets based on what was entered in
> the first frame.
>
> I've enclosed a very stripped down example below. If you run this
> program in linux (under KDE), the only way to get to the second frame
> is to close the window with the window manager (ie - clicking the "x"
> in the KDE window decorations). When I run it from MS-windows - even
> that doesn't work...
>
> Can anyone show me how I might configure the following applet so
> clicking the "OK" button will destroy the frame and start up the next
> frame? Or more generally - how should one set up an application where
> one frame is started only after another has destroyed itself.
>
> I've tried as many combinations that I can think of - and this is the
> closest I've gotten!
>
> Thanks in advance!
>
> --Rob
>
> from Tkinter import *
>
> class Splash(Frame):
> def __init__(self, parent=None):
> Frame.__init__(self, parent)
> b = Button(self, text="OK", command=self.splash_done)
> b.pack()
> self.pack()
>
> def splash_done(self):
> print "Clicked OK"
> self.destroy()
>
> class Mainapp(Frame):
> def __init__(self, parent=None):
> Frame.__init__(self, parent)
> l = Label(self, text="Main frame opened")
> l.pack()
> self.pack()
>
> Splash().mainloop()
> Mainapp().mainloop()
In this method, self refers to the button that called it, not the parent
window.
def splash_done(self):
print "Clicked OK"
self.destroy()
All you have to do is destory the button's master (the parent window).
def splash_done(self):
print "Clicked OK"
self.master.destroy()
Cool? Cool.
--
Volucris (a) hotmail.com
"Eu não falo uma única palavra do português."
More information about the Python-list
mailing list