tkinter无法使用类
想要做一个门电路编辑器,想要使用类管理各种逻辑门from tkinter import *
root = Tk()
class Gate:
def __init__(self):
ph = PhotoImage(file=r'E:/coding file/MyPythonProjects/Logic gates/AND.gif')
label = Label(root, image=ph)
label.pack()
Gate()
mainloop()
但是出来的窗口无法显示图片,但窗口的大小却又是图片的大小
我class移除,只剩下__init__函数里的内容后,就可以正常显示图片了
求解答
from tkinter import *
root = Tk()
class Gate:
def __init__(self):
ph = PhotoImage(file=r'E:/coding file/MyPythonProjects/Logic gates/AND.gif')
label = Label(root, image=ph)
label.pack()
mainloop()
Gate()
逃兵 发表于 2021-7-5 16:20
谢谢
页:
[1]