Piszę małą aplikacje dla znajomego używając tej biblioteki: customtkinter, uczę się pythona i domyślam się że błąd to jakaś głupota więc będę was prosił o pomoc.
class App(customtkinter.CTk):
def __init__(self):
super().__init__()
# Configure window
self.title("Figury")
self.geometry(f"{1100}x{600}")
# Configure grid layout (4x4)
self.grid_columnconfigure((0, 2), weight=1)
self.grid_columnconfigure((1), weight=5)
self.grid_rowconfigure((0, 1, 2), weight=1)
checkText = "Sprawdź czy może \n powstać taka figura"
checkText1 = "Skalowanie interfejsu\n użytkownika"
self.logo_label = customtkinter.CTkLabel(self.sidebar_frame, text=checkText, font=customtkinter.CTkFont(size=18, weight="bold"))
self.logo_label.grid(row=0, column=0, padx=8, pady=(20, 10))
self.appearance_mode_label = customtkinter.CTkLabel(self.sidebar_frame, text="Tryb wyglądu:", anchor="w")
self.appearance_mode_label.grid(row=5, column=0, padx=2, pady=(10, 0))
self.appearance_mode_optionemenu = customtkinter.CTkOptionMenu(self.sidebar_frame, values=["Dark", "Light"],
command=self.change_appearance_mode_event) # linia 34 z błędu
self.appearance_mode_optionemenu.grid(row=6, column=0, padx=20, pady=(10, 10))
self.scaling_label = customtkinter.CTkLabel(self.sidebar_frame, text=checkText1, anchor="w")
self.scaling_label.grid(row=7, column=0, padx=20, pady=(10, 0))
self.scaling_optionemenu = customtkinter.CTkOptionMenu(self.sidebar_frame, values=["80%", "90%", "100%", "110%", "120%"],
command=self.change_scaling_event)
self.scaling_optionemenu.grid(row=8, column=0, padx=20, pady=(10, 20))
# Create checkbox and switch frame
self.checkbox_slider_frame = customtkinter.CTkFrame(self)
self.checkbox_slider_frame.grid(row=0, column=2, rowspan = 4, sticky="nsew")
self.checkbox_slider_frame.grid_columnconfigure(0, minsize=20)
# Check button
self.button = customtkinter.CTkButton(master=self.checkbox_slider_frame, text="Sprawdź")
self.button.grid(row=15, column=1, padx=2, pady=5,sticky="nsew")
self.button.configure(command=self.on_button_click)
def czy_trojkat_prostokatny(at,bt,ct):
if at <= 0 or bt <= 0 or ct <= 0:
return "Przynajmniej jeden z boków jest ujemny lub równy zero"
elif ct > at + bt:
return "Bok c jest za długi"
elif ct < abs(at - bt):
return "Bok c jest za krótki"
elif ct ** 2 == at ** 2 + bt ** 2:
return True
else:
return False
def on_button_click(self, event=None):
at = float(self.entry_0.get())
bt = float(self.entry_1.get())
ct = float(self.entry_2.get())
result = self.czy_trojkat_prostokatny(at, bt, ct)
if __name__ == "__main__": #
app = App() # linia 220 z błędu
app.mainloop()
Mogę wysłać cały kod jeśli potrzeba. Błąd:
PS C:\Users\Lukasz\python> c:; cd 'c:\Users\Lukasz\python'; & 'C:\Users\Lukasz\AppData\Local\Programs\Python\Python311\python.exe' 'c:\Users\Lukasz\.vscode\extensions\ms-python.python-2022.20.1\pythonFiles\lib\python\debugpy\adapter/../..\debugpy\launcher' '56068' '--' 'c:\Users\Lukasz\python\GUI\tkiner.py'
Traceback (most recent call last):
File "c:\Users\Lukasz\python\GUI\tkiner.py", line 220, in <module>
app = App()
^^^^^
File "c:\Users\Lukasz\python\GUI\tkiner.py", line 34, in __init__
command=self.change_appearance_mode_event)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Lukasz\AppData\Local\Programs\Python\Python311\Lib\tkinter\__init__.py", line 2410, in __getattr__
return getattr(self.tk, attr)
^^^^^^^^^^^^^^^^^^^^^^
AttributeError: '_tkinter.tkapp' object has no attribute 'change_appearance_mode_event'
coś źle przekazuję ale nie mogę wpaść co :/
W kodzie zaznaczyłem linie z błędami
Dzięki z góry za podpowiedzi