Я только начал свой первый проект Python (извините, если это глупый вопрос, который я только начинаю) и использую интерфейс Tkinter. Кажется, я продолжаю получать это приглашение:
Исключение в обратном вызове Tkinter Traceback (последний вызов был последним): файл "D: \ Apps \ Python \ lib \ tkinter__init __. Py", строка 1883, в ____call____ return self.fun c (* args) Файл "c: / Users / noahc / Documents / Programming / AppLauncher / AppLauncher.py", строка 62, в resetList = tk.Button (root, текст = «Reset», padx = 10, pady = 5, fg = «white», bg = «# 263D42», command = lambda: [removeSave (), resetList ()]) TypeError: объект «Button» не вызывается
Я предоставил код ниже:
#########################
# CREATED BY NOZZYPOZZY #
#########################
import tkinter as tk
from tkinter import filedialog, Text
import os
root = tk.Tk()
root.title("App Launcher")
root.iconbitmap('C:/Users/noahc/Documents/Programming/AppLauncher/icon.ico')
root.resizable(0,0)
apps = []
if os.path.isfile('save.txt'):
with open('save.txt','r') as f:
tempApps = f.read()
tempApps = tempApps.split(',')
apps = tempApps
apps = [x for x in tempApps if x.strip()]
def addApp():
for widget in frame.winfo_children():
widget.destroy()
filename = filedialog.askopenfilename(initialdir="/", title="Select File", filetypes=(("Executables","*.exe"), ("All Files", "*.*")))\
apps.append(filename)
print(filename)
for app in apps:
label = tk.Label(frame, text=app, bg="gray")
label.pack()
def runApps():
for app in apps:
os.startfile(app)
def resetList():
for widget in frame.winfo_children():
widget.destroy()
def removeSave():
os.remove('save.txt')
canvas = tk.Canvas(root, height=700, width=700, bg="gray")
canvas.pack()
frame = tk.Frame(root, bg="white")
frame.place(relwidth=0.8, relheight=0.8, relx=0.1, rely=0.1)
openFile = tk.Button(root, text="Open File", padx=10, pady=5, fg="white", bg="#263D42", command=addApp)
openFile.pack()
runApps = tk.Button(root, text="Run Apps", padx=10, pady=5, fg="white", bg="#263D42", command=runApps)
runApps.pack()
resetList = tk.Button(root, text="Reset", padx=10, pady=5, fg="white", bg="#263D42", command=lambda:[removeSave(),resetList()])
resetList.pack()
for app in apps:
label = tk.Label(frame, text=app)
label.pack()
root.mainloop()
with open('save.txt', 'w') as f:
for app in apps:
f.write(app + ',')
Спасибо, nozzypozzy