Tkinter --> Why multiple windows

kevind0718 at gmail.com kevind0718 at gmail.com
Thu Mar 24 16:24:16 EDT 2016


Hello:

newbie Tkinter question

If I run the code below two windows appear.
One empty and one with the text box and button.

Why?  please

KD



from Tkinter import *

class MyDialog:
    def __init__(self, parent):

        top = self.top = Toplevel(parent)

        Label(top, text="Value").pack()

        self.e = Entry(top)
        self.e.pack(padx=5)

        b = Button(top, text="OK", command=self.ok)
        b.pack(pady=5)

    def ok(self):

        print "value is", self.e.get()

        self.top.destroy()


root = Tk()

d = MyDialog(root)

root.wait_window(d.top)



More information about the Python-list mailing list