Anonymous
Python GUIZero – AttributeError: объект «NoneType» не имеет атрибута «tk»
Сообщение
Anonymous » 13 янв 2025, 08:43
Опишите ошибку
Использование нескольких «Изображений» приводит к сбою программы.
Для воспроизведения
Шаги по воспроизведению поведения:
Код: Выделить всё
#GUI Classes
from guizero import App, PushButton, Picture, Text, Box, Window
import os
appDir = os.path.dirname(os.path.realpath(__file__))
app = App("Testing")
options = Box(app, layout="grid", width="fill")
Picture(options, appDir + '/images/icons/dark/100x100Filters-Icon@4x.png', width=100, height=100, grid=[0,0])
Picture(options, appDir + '/images/icons/dark/100x100PhotoFrames-Icon@4x.png', width=100, height=100, grid=[1,0])
Picture(options, appDir + '/images/icons/dark/100x100Stickers-Icon@4x.png', width=100, height=100, grid=[2,0])
Picture(options, appDir + '/images/icons/dark/100x100Timer-Icon@4x.png', width=100, height=100, grid=[3,0])
Picture(options, appDir + '/images/icons/dark/100x100Lights-Icon@4x.png', width=100, height=100, grid=[4,0])
filters = Box(app, layout="grid", width="fill").hide()
Picture(filters, appDir + '/images/icons/dark/100x100Smooth-Icon@4x.png', width=100, height=100, grid=[0,0])
Picture(filters, appDir + '/images/icons/dark/100x100SmoothM-con@4x.png', width=100, height=100, grid=[1,0])
Picture(filters, appDir + '/images/icons/dark/100x100Reset-Icon@4x.png', width=100, height=100, grid=[2,0])
Picture(filters, appDir + '/images/icons/dark/100x100Back-Icon@4x.png', width=100, height=100, grid=[3,0])
app.display()
Ожидаемое поведение
Отображение изображений с помощью GUI Zero
Снимки экрана
Информация о системе:
ОС: Windows и Pi 4
Версия Guizero: Windows (1.50) — Pi (1.40)
Дополнительный контекст
Код: Выделить всё
C:\Users\youca\Desktop\Photobooth App>python Test.py Traceback (most recent call last): File "C:\Users\youca\Desktop\Photobooth App\Test.py", line 16, in Picture(filters, appDir + '/images/icons/dark/100x100Smooth-Icon@4x.png', width=100, height=100, grid=[0,0]) File "C:\Users\youca\AppData\Local\Programs\Python\Python312\Lib\site-packages\guizero\Picture.py", line 55, in __init__ tk = Label(master.tk) ^^^^^^^^^ AttributeError: 'NoneType' object has no attribute 'tk'
Подробнее здесь:
https://stackoverflow.com/questions/793 ... tribute-tk
1736746993
Anonymous
[b]Опишите ошибку[/b] Использование нескольких «Изображений» приводит к сбою программы. [b]Для воспроизведения[/b] Шаги по воспроизведению поведения: [code]#GUI Classes from guizero import App, PushButton, Picture, Text, Box, Window import os appDir = os.path.dirname(os.path.realpath(__file__)) app = App("Testing") options = Box(app, layout="grid", width="fill") Picture(options, appDir + '/images/icons/dark/100x100Filters-Icon@4x.png', width=100, height=100, grid=[0,0]) Picture(options, appDir + '/images/icons/dark/100x100PhotoFrames-Icon@4x.png', width=100, height=100, grid=[1,0]) Picture(options, appDir + '/images/icons/dark/100x100Stickers-Icon@4x.png', width=100, height=100, grid=[2,0]) Picture(options, appDir + '/images/icons/dark/100x100Timer-Icon@4x.png', width=100, height=100, grid=[3,0]) Picture(options, appDir + '/images/icons/dark/100x100Lights-Icon@4x.png', width=100, height=100, grid=[4,0]) filters = Box(app, layout="grid", width="fill").hide() Picture(filters, appDir + '/images/icons/dark/100x100Smooth-Icon@4x.png', width=100, height=100, grid=[0,0]) Picture(filters, appDir + '/images/icons/dark/100x100SmoothM-con@4x.png', width=100, height=100, grid=[1,0]) Picture(filters, appDir + '/images/icons/dark/100x100Reset-Icon@4x.png', width=100, height=100, grid=[2,0]) Picture(filters, appDir + '/images/icons/dark/100x100Back-Icon@4x.png', width=100, height=100, grid=[3,0]) app.display() [/code] [b]Ожидаемое поведение[/b] Отображение изображений с помощью GUI Zero [b]Снимки экрана[/b] [img]https://github.com/user-attachments/assets/56e240fa-b498-45c3-a33d-fbbdf84dc08e[/img] [b]Информация о системе:[/b] [list] [*]ОС: Windows и Pi 4 Версия Guizero: Windows (1.50) — Pi (1.40) [/list] [b]Дополнительный контекст[/b] [code]C:\Users\youca\Desktop\Photobooth App>python Test.py Traceback (most recent call last): File "C:\Users\youca\Desktop\Photobooth App\Test.py", line 16, in Picture(filters, appDir + '/images/icons/dark/100x100Smooth-Icon@4x.png', width=100, height=100, grid=[0,0]) File "C:\Users\youca\AppData\Local\Programs\Python\Python312\Lib\site-packages\guizero\Picture.py", line 55, in __init__ tk = Label(master.tk) ^^^^^^^^^ AttributeError: 'NoneType' object has no attribute 'tk'[/code] Подробнее здесь: [url]https://stackoverflow.com/questions/79348985/python-guizero-attributeerror-nonetype-object-has-no-attribute-tk[/url]