我在窗户上扣了三个钮扣。我选择主窗口应该有一个特定的背景图像和全屏。
现在有个问题。我想通过单击按钮3转到一个新窗口(页面)(带有其他背景和其他内容)。
我尝试的事情:
从Main.Info.travelhistory导入*
我在开头添加了root1=Tk(),在结尾添加了root1.mainloop(),在它们之间添加了另一个窗口的代码。但这也不起作用,它打开了两个窗口,就像上面一样。
这些都是我的努力,我想不出更好的办法。我可以,但背景不会改变。但我必须把新窗口的背景改成我做的背景图片。。。
知道我做错了什么吗?
from tkinter import *
from tkinter.messagebox import showinfo
from Main.Info.travelhistry import *
def clicked1():
bericht = 'Deze functie is uitgeschakeld.'
showinfo(title='popup', message=bericht)
root = Tk()
a = root.wm_attributes('-fullscreen', 1)
#Hoofdmenu achtergrond
C = Canvas(root, bg="blue", height=250, width=300)
filename = PhotoImage(file = "test1.png")
background_label = Label(root, image=filename)
background_label.place(x=0, y=0, relwidth=1, relheight=1)
C.pack()
# Geen OV-chipkaart button
b=Button(master=root, command=clicked1)
photo=PhotoImage(file="button1.png")
b.config(image=photo,width="136",height="53", background='black')
b.place(x=310, y=340)
#Buitenland button
b2=Button(master=root, command=clicked1)
photo1=PhotoImage(file="button2.png")
b2.config(image=photo1,width="136",height="53", background='black')
b2.place(x=490, y=340)
#Reis informatie
b3=Button(master=root)
photo2=PhotoImage(file="button3.png")
b3.config(image=photo2,width="136",height="53", background='black')
b3.place(x=680, y=340)
root.mainloop()
root2.mainloop()
不能调用多个
Tk()
窗口。相反,tkinter还有一个名为
Toplevel
的小部件,可以用来生成一个新窗口。示例如下:
这一个打开新窗口,您可以编辑。
相关问题 更多 >
编程相关推荐