I’m following this intro to tkinter, specifically the dialog entry example on page 29. http://www.ittc.ku.edu/~niehaus/classes/448-s04/448-standard/tkinter-intro.pdf
I’m getting the following error:
d = MyDialog(root)
TypeError: this constructor takes no arguments
I deleted the argument from the variable d, and the argument for wait_window (see the code below) and the program will run, however there is no entry field.
Here is the code
from Tkinter import *
class MyDialog:
def init(self, parent):
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()
Button(root, text="Hello!").pack()
root.update()
d = MyDialog(root)
root.wait_window(d.top)
Change
to
See the documentation of
object.__init__.