【发布时间】:2022-09-23 16:56:22
【问题描述】:
你好我最近一直在学习 python 并且正在练习......我只是无法理解错误的原因,因为在我看来,我在按钮内部定义。 如果有人可以帮助我,我将不胜感激
我不知道该怎么继续了,我不明白错误在哪里,我想能够理解但我做不到,你能给我解释一下吗?
windows = tk.Tk()
windows.geometry(\"400x350\")
windows.title(\"Gym Tracker\")
windows.resizable(False, False)
frame1 = Frame(windows, width=150, height=30, highlightcolor=\"white\",highlightbackground=\"black\", highlightthickness=1).place(x=120, y=2)
label1 = Label(windows, text=\"GYM TRACKER\").place(x=150, y=7)
frame2 = Frame(windows, width=500, height=1, highlightcolor=\"white\",highlightbackground=\"black\", highlightthickness=1).place(x=2, y=45)
labelmes = Label(windows, text=\"Mese\").place(x=110, y=60)
combobox = Combobox(windows, values=[\'Gennaio\', \'Febbraio\', \'Marzo\', \'Aprile\', \'Maggio\', \'Giugno\',\'Luglio\', \'Agosto\', \'Settembre\', \'Ottobre\', \'Novembre\', \'Dicembre\']).place(x=200, y=60)
entry2 = tk.Entry(windows)
labealt = Label(windows, text=\"Altezza\").place(x=110, y=90)
textbox = Text(windows, width=17, height=1).place(x=200, y=90)
entry3 = tk.Entry(windows)
labelpeso = Label(windows, text=\"Peso\").place(x=110, y=120)
textbox = Text(windows, width=17, height=1).place(x=200, y=120)
entry4 = tk.Entry(windows)
labelmmagra = Label(windows, text=\"Massa Magra\").place(x=110, y=150)
textbox = Text(windows, width=17, height=1).place(x=200, y=150)
entry5 = tk.Entry(windows)
labelmgrassa = Label(windows, text=\"Massa Grassa\").place(x=110, y=180)
textbox = Text(windows, width=17, height=1).place(x=200, y=180)
entry6 = tk.Entry(windows)
# Combobox Utente
labelutente = Label(windows, text=\"Utente\").place(x=110, y=210)
combobox = Combobox(windows, values=[\'Erika\', \'Lorenzo\']).place(x=200, y=210)
entry7 = tk.Entry(windows)
b1 = tk.Button(windows, text=\"Importa\", command=delete ,width=8,`enter code here`height=1).place(x=170,y=310)
b2 = tk.Button(windows, text=\"Avanti\", width=8,height=1,command=nextpage).place(x=300,y=310)
b3 = tk.Button(windows, text=\'Salva\', width=8, height=1, command=save).place(x=50, y=310)
def delete():
entry2.delete(0, tk.END)
entry3.delete(0, tk.END)
entry4.delete(0, tk.END)
entry5.delete(0, tk.END)
entry6.delete(0, tk.END)
entry7.delete(0, tk.END)
def nextpage():
labelmes.destroy()
labealt.destroy()
labelpeso.destroy()
labelmmagra.destroy()
labelmgrassa.destroy()
labelutente.destroy()
b1.destroy()
b2.destroy()
b3.destroy()
def save():
mese = entry2.get()
altezza = entry3.get()
peso = entry4.get()
mmagra = entry5.get()
mgrassa = entry6.get()
utente = entry7.get()
wb = Workbook()
ws = wb.active
ws[\'A1\'] = \"Mese\"
ws[\'B1\'] = \"Altezza\"
ws[\'C1\'] = \"Peso\"
ws[\'D1\'] = \"Massa Magra\"
ws[\'E1\'] = \"Massa Grassa\"
ws[\'F1\'] = \"Utente\"
ws[\'A2\'] = mese
ws[\'B2\'] = altezza
ws[\'C2\'] = peso
ws[\'D2\'] = mmagra
ws[\'E2\'] = mgrassa
ws[\'F2\'] = utente
wb.save(r\'C:\\Users\\lricci\\Desktop\\SERVER\\web\\Gym Tracker\\Gym Tracker v1.0\\track.xlsx\')
showinfo(\"Hai salvato correttamente\")
file = pd.read_excel(\"track.xlsx\")
all = [file]
append = pd.concat(all)
append.to_excel(\"track.xlsx\",index=False)
windows.mainloop()
标签: python-3.x