#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2004
    Posts
    136
    Rep Power
    11

    Another Tk question...


    This is probably a simple question..
    I have 2 classes. one class is for one dialog, the other is for another dialog. When I click on a button in dialog number 1 the other dialog will open.

    here's my code:


    Code:
    from Tkinter import *
    
    
    root = Tk()
    
    
    
    class MyGUI(object):
        def __init__(self, parent):
            self.parent = parent
            frame = Frame(parent, width=500, height=200).pack()
            self.b1 = Button(frame, text="Click here", command=self.open_new_dialog).pack(side=LEFT)
    
    
        def open_new_dialog(self):
            t = MyTEST(self.parent)
    
            
    
    
    
    class MyTEST(object):
        def __init__(self, parent):
            frame = Frame(parent, width=100, height=100).pack()
            self.b2 = Button(frame, text="Close this", command=parent.destroy).pack(side=LEFT)
    
    
    
    
    MyGUI(root)
    
    root.mainloop(0)

    what happends is the other dialog opens IN the same dialog as the other some way... What am I missing?

    thanks in advance!
    Dag
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2004
    Posts
    136
    Rep Power
    11

    Never mind...


    Never mind... I found out, Toplevel() was my answer!
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Nov 2004
    Location
    There where the rabbits jump
    Posts
    556
    Rep Power
    12
    Yup Toplevel()
    Since you open a new window
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2004
    Posts
    394
    Rep Power
    52
    Hi!

    I don't know how your dialog should look like, but Tkinter has some standard-dialogs. If you want, have a look at tkSimpleDialog, tkFileDialog, tkMessageBox.

    Regards, mawe

IMN logo majestic logo threadwatch logo seochat tools logo