May-06-2019, 07:28 PM
You have not set the tk StringVar result ie
Also see https://python-forum.io/Thread-Namespace...th-imports
result.set(int(number.get()) * 2)
, the following will make the result update.from tkinter import* main_window = Tk() main_window.title("Calculator") main_window.geometry("300x200") number = StringVar() number.set("0") result = StringVar() result_label = Label(main_window, text="Result").grid(column=1, row=1) result_value = Label(main_window, textvariable=result).grid(column=2, row=1) number_label = Label(main_window, text="Number to calculate").grid(column=1, row=2) number_entry = Entry(main_window, width=10, textvariable=number).grid(column=2, row=2) def kalkuliere(): result.set(int(number.get()) * 2) calc_button = Button(main_window, text="Calculate", command=kalkuliere).grid(column=2, row=3) main_window.mainloop()It would be advisable to start using classes when dealing with GUI code.
Also see https://python-forum.io/Thread-Namespace...th-imports