我的Python Tkinter脚本没有获取c,b,a和epoch的变量值,我尝试了其他方法,例如if,function和stuff,但是它不起作用。
我以前从未尝试过Tkinter,所以我很难理解。
def Assis():
assis = open("ACB/config.ini","w", encoding="utf8")
assis.write("State=%s\n" % a)
assis.write("StartTimestamp=%s\n" % epoch)
assis.close()
def Come():
come = open("ACB/config.ini","w", encoding="utf8")
come.write("State=%s\n" % c)
come.write("Details=Comendo\n")
come.write("StartTimestamp=%s\n" % epoch)
come.close()
def Bebe():
bebe = open("ACB/config.ini","w", encoding="utf8")
bebe.write("State=%s\n" % b)
bebe.write("Details=Bebendo\n")
bebe.write("StartTimestamp=%s\n" % epoch)
bebe.close()
def ACB():
count = 0
while count < 3500:
Bebe()
count += 1
time.sleep(6)
Come()
time.sleep(6)
Assis()
time.sleep(6)
core = tk.Tk()
core.title("Core.py")
core.geometry("800x700")
def B():
B2 = tk.Button(core, text ="/AssisComeBebendo", fg="green", command=C)
B2.pack()
def C():
choice = "yes"
if choice == "yes":
label = Label(core, text="\nAssisComeBebendo: \nTime:")
btn1 = Text(core, bg="white", fg="black", width="10", height="1")
label.pack()
btn1.pack()
webbrowser.open("https://www.epochconverter.com/clock")
label = Label(core, text="\nComendo:")
btn2 = Text(core, bg="white", fg="black", width=lar, height="1")
label.pack()
btn2.pack()
label = Label(core, text="\nBebendo:")
btn3 = Text(core, bg="white", fg="black", width=lar, height="1")
label.pack()
btn3.pack()
label = Label(core, text="\nAssistindo:")
btn4 = Text(core, bg="white", fg="black", width=lar, height="1")
label.pack()
btn4.pack()
B2 = tk.Button(core, text ="/Rodar 2", fg="green", command=ACB)
B2.pack()
epoch = btn1.get("1.0","end-1c")
c = btn2.get("1.0","end-1c")
b = btn3.get("1.0","end-1c")
a = btn4.get("1.0","end-1c")
print(b)
B()
core.mainloop()
也许我应该使用全局变量或尝试在UI之外定义它,我不知道