简体   繁体   中英

Tkinter Entry Not Updating

from tkinter import *
from PIL import Image, ImageTk
import datetime
import os

root = Tk()
root.title("To-do List")
root.geometry("400x600")
root.resizable(width=False, height=False)
# Balance
global be
bet = settings_main_canvas.create_text(110, 165, text="Balance: ", font="Helvetica 14") # Balance Entry Text
be = Entry(root, width=20, font="Helvetica 10", borderwidth=2, bg="#f0f0f0") # Balance Entry
be.insert(0, "Amount in USD")
settings_main_canvas.create_window(170, 165, window=be, anchor=W)



# Text
global acc_name
global balance
global progress_bar_tasks
acc_name = sidebar_canvas.create_text(65, 18, text=ane.get(), font="TimesNewRoman 10 bold", anchor=NW)
balance = sidebar_canvas.create_text(65, 35, text=be.get() + "$", font="TimesNewRoman 8", anchor=NW)
progress_bar_tasks = sidebar_canvas.create_text(180, 30, text="{} / {} Complete".format(len(inbox_finished_tasks), len(inbox_tasks_num)), font="TimesNewRoman 9", anchor=NW)
root.mainloop()

I don't know why but when I print be.get() it always returns the value that I inserted, even though I changed the text in the entry

The reason this happens is, before you can edit the text in the entry, balance already is created and does not update constantly. So the text in balance doesn't update.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM