Python 3.x TKinter Splashscreen不适用于基于GUI的Python 3.6应用程序
我正在尝试构建一个基于GUI的代码,其中会有一个SplashScreen,等待5秒钟,然后主GUI就会出现。我正在使用Python 3.6。这是我的密码:Python 3.x TKinter Splashscreen不适用于基于GUI的Python 3.6应用程序,python-3.x,user-interface,tkinter,Python 3.x,User Interface,Tkinter,我正在尝试构建一个基于GUI的代码,其中会有一个SplashScreen,等待5秒钟,然后主GUI就会出现。我正在使用Python 3.6。这是我的密码: from tkinter import Tk, PhotoImage, Canvas, Label from time import sleep root = Tk() root.overrideredirect(True) width = root.winfo_screenwidth() height = root.winfo
from tkinter import Tk, PhotoImage, Canvas, Label
from time import sleep
root = Tk()
root.overrideredirect(True)
width = root.winfo_screenwidth()
height = root.winfo_screenheight()
image_file = 'splash_fig.png'
splashImage = PhotoImage(file = image_file)
w = splashImage.width()
h = splashImage.height()
y = int((height - h) / 2)
x = int((width - w) / 2)
root.geometry('%dx%d+%d+%d' % (w,h,x,y))
canvas = Canvas(root,height = h, width = w, bg = "brown")
canvas.create_image(0,0,image = splashImage, anchor='nw')
canvas.pack()
root.after(5000, root.destroy)
root.mainloop()
root = Tk()
my_label = Label(root, text="Something something")
my_label.pack()
root.mainloop()
发生的事情是splashscreen没有显示,但是第二个GUI显示了!这里的确切问题在哪里!我的问题是对这一点的扩展,我一直在密切关注所提出的解决方案您的代码对我来说工作得很好。你确定你的splashscreen没有出现吗?尝试通过
root.attributes(“-topmost”,True)
将窗口提升到顶部。确定。我将代码移到Linux上,发现代码可以工作。我在MacOSX上用Python3.6+运行它。似乎是MacOS上的一个小故障。我该如何与社区沟通?