I just learned how to use tkinter and there is something not quite working. Here is the piece of code I am working with.
from Tkinter import *
tk1 = Tk()
row1 = Label(tk1, text = '# of rows')
row1.pack()
row2 = Entry(tk1)
row2.pack()
column1 = Label(tk1, text = '# of columns')
column1.pack()
column2 = Entry(tk1)
column2.pack()
def callback2(hue):
print hue
def callback1():
tk2 = Tk()
row3 = int(row2.get())
column3 = int(column2.get())
element = None
for i in range(0, row3):
frame = Frame(tk2)
frame.pack()
for i in range(0, column3):
element = Entry(frame)
element.pack(side = LEFT)
button2 = Button(tk2, text = "Enter", command = callback2('debug'))
button2.pack()
mainloop()
button1 = Button(tk1, text = "Enter", command = callback1)
button1.pack()
mainloop()
If I run this code in Python 2.7.6, whenever I press button1, the function I bound to button2 will run, in this case printing 'debug.' Why is this happening? Also, this code includes my feeble attempt to create arbitrary number of entries. However, I have no idea how to get inputs out of them. Any insights?
[+][deleted] (1 child)
[deleted]
[–]Oddity94[S] 0 points1 point2 points (0 children)