Starting a Frame dependent on destruction of another Frame... 
Author Message
 Starting a Frame dependent on destruction of another Frame...

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()



Fri, 02 Jan 2004 14:32:10 GMT  
 Starting a Frame dependent on destruction of another Frame...


Quote:
> 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 portugus."



Fri, 02 Jan 2004 16:44:37 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. links in html-frame affecting vrml-frame

2. Java in frame can't get instance of Java EAI + VRML in another frame

3. Movietexture Frame by Frame control

4. Q:wpy - multiple frames within main frame

5. resources for vtcl - hide frames and display new frames

6. How do I pack things in a frame in a toplevel frame

7. Removing widgets from frames, why frames don't resize to 0x0

8. start-frame bug

9. HELP! Dependent Get (was Dependent Get)

10. ??Call to the Unification Algorithm (code) using Frames. Frames???

11. Problem with framing layout on a system using large fonts

12. Video Frame Grab From VW

 

 
Powered by phpBB® Forum Software