我正在制作一个组织钱财的程序,但是用户输入无法更新
我尝试使用get()和set(),但似乎无法工作。同样,当我运行该程序时,用户输入值会显示一个我什至没有给出的数字。
root = Tk()
lab = Label(root)
lab.pack()
def clock():
time = datetime.datetime.now().strftime("Time: %H:%M:%S")
lab.config(text=time)
#lab['text'] = time
root.after(1000, clock) # run itself again after 1000 ms
def userInputSaved():
global userInput_1
global userInput_2
global userInput_3
userInput_1 = userInput_1.get()
userInput_2 = userInput_2.get()
userInput_3 = userInput_3.get()
clock()
a = 0
if a >= 0:
moneyPaid = Label(root, text = 'Please enter the amount of money you
have made this month')
moneyPaid.pack()
userInput_1 = Entry(root)
userInput_1.pack()
a = a + 1
if a == 1:
bills = Label(root, text = 'Please enter the amount of money you need
to pay bills with')
bills.pack()
userInput_2 = Entry(root)
userInput_2.pack()
a = a + 1
if a == 2:
saved = Label(root, text = 'Please enter the amount of money you want
the save this month')
saved.pack()
userInput_3 = Entry(root)
userInput_3.pack()
a = a + 1
if a == 3:
afterBills = Label(root, text = 'This is the amount of money you have
after paying the bills: $' + str(userInput_1))
afterBills.pack()
afterSaved = Label(root, text = 'This is the amount of money you after
putting back savings: $')
afterSaved.pack()
spending = Label(root, text = 'So the amount of money that you are
able to use anything with is $')
spending.pack()
root.mainloop()
结果是,当用户输入一个数字时,该数字将在以后存储和使用。