AttributeError: 'Seite1' Objekt hat kein Attribut 'TK'. Fehler in Cistomtkinter

Post a reply

Smilies
:) :( :oops: :chelo: :roll: :wink: :muza: :sorry: :angel: :read: *x) :clever:
View more smilies

BBCode is ON
[img] is ON
[flash] is OFF
[url] is ON
Smilies are ON

Topic review
   

Expand view Topic review: AttributeError: 'Seite1' Objekt hat kein Attribut 'TK'. Fehler in Cistomtkinter

by Anonymous » 23 Feb 2025, 16:15

Ich habe dieses Programm. Aber wenn ich ein Bild hinzufügen möchte, erhalte ich Fehler: < /p>

AttributError: 'Seite1' Objekt hat kein Attribut 'tk'. < /P>
< /blockquote>

Code: Select all

from tkinter import *
from customtkinter import *
from PIL import Image

app = CTk()
app.configure(fg_color='#dda15e')
app.title('School Project')
app.resizable(width=False, height=False)
app.geometry('690x520')

def hide_all():
""" Hides all the pages """
page1.hide()

def show_page1():
page1.show()

class Page1:
def __init__(self):
super().__init__()
self.on_img = CTkImage(light_image=Image.open("main1.png"),size=(300,400))
self.il = CTkButton(self, image=self.on_img, text="")
self.lbl1 = CTkLabel(app, text='текст', font=('Calibri', 25),width=10, height=10, text_color='#fefae0')
self.btn1 = CTkButton(app, text='Начать', font=('Arial', 20), command=show_page1, text_color='#fefae0', width=150,
height=50, fg_color='#bc6c25', border_color='#fefae0', border_width=2, hover_color='#d4a373')
def show(self):
hide_all()
self.lbl1.place(x=40,y=230)
self.btn1.place(x=260,y=380)

def hide(self):
self.lbl1.place_forget()
self.btn1.place_forget()
page1 = Page1()
page1.show()
app.mainloop()
Ich habe versucht, Selbst und Seite 1 in Super () hinzuzufügen. init (), aber es hat nicht geholfen.

Top