基本上,我正在尝试制作一个每秒更新自己的变量列表,但我只能获取要更新的最后一个标签。我对 tkinter 不太熟悉,没有任何帮助。我认为主要问题是我已经得到了它,但我不知道任何其他方式,如果有人可以帮助我解决我的问题,甚至帮助检修程序,那将非常感激。
import time
import textwrap
from tkinter import Tk, Label, Button
from pathlib import Path
while True:
print(textwrap.fill("Please enter the name that you entered for the main document. It must have the exact same characters and is case sensitive.", 70))
Name = input()
FileName = Name+".txt"
P = Path(FileName)
if P.exists():
class MyFirstGUI:
def __init__(self, master):
with open(FileName, "r") as file:
global Points
global Item1
global Item2
global Item3
global PPC
global PPS
global Item1Cost
global Item2Cost
global Item3Cost
read = file.read().splitlines()
Points = read[0]
Item1 = read[1]
Item2 = read[2]
Item3 = read[3]
PPC = 1 + int(Item3)
PPS = int(Item1)*1 + int(Item2)*5
Item1Cost = read[6]
Item2Cost = read[7]
Item3Cost = read[8]
Points = int(Points) + int(PPS)
VarList = [str(Points), str(Item1), str(Item2), str(Item3), str(PPC), str(PPS), str(Item1Cost), str(Item2Cost), str(Item3Cost)]
with open(FileName, "w") as file:
for List in VarList:
file.write(List+'\n')
root = Tk()
self.master = master
master.title("Menu")
self.label = Label(master, text=Points, anchor='w')
self.label.pack(fill='both', padx=10)
self.label = Label(master, text=Item1, anchor='w')
self.label.pack(fill='both', padx=10)
慕勒3428872
相关分类