@nochnoy_koshmar

Не выводится фотография в дочернем окне tkinter. Выдаёт ошибку image «pyimage1» doesn't exist. Как это поправить?

import tkinter
from tkinter import *
import tkinter as tk
from tkinter import ttk
from PIL import ImageTk, Image


def Help():
    
    def Destroy():
        window.destroy()   
    

    window=tk.Tk()
    window.title("Новое окно")
    window.geometry("300x180")
    
    label = ttk.Label(window, text="Высота", foreground='black',
                       font='Arial 10').place(relx=0.5, rely=0.5, anchor="c") 
    
    
    submit = Button(window, text='Cancel',
                     command=Destroy).place(relx=0.8, rely=0.8, anchor="c", width=70, height=30) 
    
    
    ph=Image.open('pop.png')
    ph=ph.resize((300,300), Image.LANCZOS)
    ph=ImageTk.PhotoImage(ph)
    ph=Label(window, image=ph)
    ph.image=ph
    ph.place(x=10, y=10)
    

def OK():
    p = entry1.get()
    print(p)
    entry1.delete(0, END)
    entry2.delete(0, END)
    entry2.insert(0,p)


def Cancel():
    root.destroy()


root = Tk()
root.title("Параметры стандартной атмосферы")
root.geometry("700x400")
root.resizable(False, False)


label1 = ttk.Label(text="Высота", foreground='black',
                   font='Arial 10').place(relx=0.6, rely=0.1, anchor="c")
label2 = ttk.Label(text="Поле ввода высоты", foreground='black',
                   font='Arial 10').place(relx=0.1, rely=0.2, anchor="c")
label3 = ttk.Label(text="Давление", foreground='black',
                   font='Arial 10').place(relx=0.2, rely=0.6, anchor="c")
label4 = ttk.Label(text="Плотность", foreground='black',
                   font='Arial 10').place(relx=0.4, rely=0.6, anchor="c")
label5 = ttk.Label(text="Температура", foreground='black',
                   font='Arial 10').place(relx=0.6, rely=0.6, anchor="c")
label6 = ttk.Label(text="Скорость звука", foreground='black',
                   font='Arial 10').place(relx=0.8, rely=0.6, anchor="c")


entry1 = ttk.Entry()
entry1.place(relx=0.75, rely=0.1, anchor="c")
entry2 = ttk.Entry()
entry2.place(relx=0.3, rely=0.2, anchor="c")
entry3 = ttk.Entry().place(relx=0.2, rely=0.5, anchor="c")
entry4 = ttk.Entry().place(relx=0.4, rely=0.5, anchor="c")
entry5 = ttk.Entry().place(relx=0.6, rely=0.5, anchor="c")
entry6 = ttk.Entry().place(relx=0.8, rely=0.5, anchor="c")


submit1 = Button(root, text='Cancel',
                 command=Cancel).place(relx=0.2, rely=0.8, anchor="c", width=70, height=30)
submit2 = Button(root, text='Help',
                 command=Help).place(relx=0.5, rely=0.8, anchor="c", width=70, height=30)
submit3 = Button(root, text='OK',
                 command=OK).place(relx=0.7, rely=0.8, anchor="c", width=70, height=30)


root.mainloop()
  • Вопрос задан
  • 253 просмотра
Решения вопроса 1
sergey-gornostaev
@sergey-gornostaev Куратор тега Tkinter
Седой и строгий
Логично, в коде же нет ничего с именем pyimage1. Кроме того, методы менеджера компановки ничего не возвращают, так что в большинстве переменных вашей программы находится None, а не то, что вы ожидаете.
Ответ написан
Комментировать
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы