我正在尝试创建多框架GUI。我正在使用的代码为此目的正常工作。但是,当我在某些帧中添加一些图片时,GUI会出现在两个窗口中:一个具有正常的功能和排列;里面没有东西。如果我关闭他们中的任何一个,他们都关闭。使用Python为Tkinter GUI中的多窗口/框架添加ImageTk图片
我使用Python 2.7。
有人请向我解释发生了什么?
编辑:我现在知道原因。这是因为我使用tk.Toplevel而不是tk.Tk。随着tk.Tk,我没有双窗口的问题,但我不能让我的照片显示。任何帮助?
这里是我的代码:
import tkinter as tk # python3
#import Tkinter as tk # python
from PIL import ImageTk, Image
TITLE_FONT = ("Helvetica", 18, "bold")
img = Image.open('arrow.png')
class SampleApp(tk.Toplevel):
def __init__(self, *args, **kwargs):
tk.Toplevel.__init__(self, *args, **kwargs)
# the container is where we'll stack a bunch of frames
# on top of each other, then the one we want visible
# will be raised above the others
container = tk.Frame(self)
container.pack(side="top",