Почему у меня не отображается картинка в дочернем окне

Рейтинг: 0Ответов: 0Опубликовано: 22.06.2023

Основное окно:

import tkinter
from tkinter import *
from PIL import ImageTk, Image
from anotherwindow import sevenclass
class Osnova:
    def __init__(self, width=1024, height=721, title="Физика на изи", resizable=(False, False), icon=r"resources/icon.ico"):
        self.osnova = Tk()
        self.osnova.title(title)
        self.osnova.geometry(f"{width}x{height}")
        self.osnova.resizable(resizable[0], resizable[1])
        if icon:
            self.osnova.iconbitmap(icon)
        self.fon_img = PhotoImage(file=r"resources/Ph.png")
        self.fon_imag = Label(self.osnova,image=self.fon_img)



        self.hi = Label(self.osnova, text='Привет, я физика на изи - твой помощник по физике', font=('Colatemta', 14))

    def viget(self):
        self.hi.place(relx=0.01, rely=0.01, anchor=NW)
        def run(self):
        self.viget()
        self.osnova.mainloop()
    def create1(self):
        sevenclass(self.osnova)

if __name__ =="__main__":
    wind = Osnova()
    wind.create1()
    wind.run()

Вот дочернее окно:

from tkinter import *
from PIL import ImageTk, Image


class sevenclass:
    def __init__(self, parent, width=1024, height=721, title="Физика на изи", resizable=(False, False),
                 icon=r"resources/icon.ico"):
        self.okno = Toplevel(parent)
        self.okno.title(title)
        self.okno.geometry(f"{width}x{height}")
        self.okno.resizable(resizable[0], resizable[1])
        if icon:
            self.okno.iconbitmap(icon)

        self.fon_image = PhotoImage(file=r"resources/Ph1.png")
        self.fon = Label(self.okno, image=self.fon_image).place(relx=0.5, rely=0.5, anchor=CENTER)

Ответы

Ответов пока нет.