Python Tkinter 小窗口在主窗口之前瞬间弹出 [英] Python Tkinter small window pops up momentarily before main window

查看:41
本文介绍了Python Tkinter 小窗口在主窗口之前瞬间弹出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我正在制作 Python Tkinter GUI 程序,但在制作过程中,我注意到弹出一个小 Tkinter 窗口,然后在主窗口弹出之前关闭.这是非常分散注意力的,显然是您在专业软件中会拥有的东西.下面是问题的一个例子:

Hello I am making a Python Tkinter GUI program but as I was making it I noticed that a small Tkinter window pops up then closes before the main window pops up. It is very distracting and obviously something that you would have in a professional piece of software. Here is an example of the problem:

from tkinter import *

app = Tk()
app.title("My GUI")
app.iconbitmap(r"C:\Program Files (x86)\Notepad++\Files\journalicon.ico")
app.resizable(0,0)

button = Button(text = "Text")
button.pack()

app.mainloop()

iconbitmap 选项是我从另一个堆栈溢出页面中找到并使用的.如果您知道更好的选择,我将不胜感激.我很迷茫,非常感谢您的回答.

The iconbitmap option was something I found from another stack overflow page and used it. If you know of a better option I would appreciate the help. I am quite lost and would really appreciate any answers.

推荐答案

试试这个:

app = Tk()
app.title("My GUI")
app.iconbitmap(app, "C:\Program Files (x86)\Notepad++\Files\icon.ico")
app.resizable(0,0)

app.mainloop()

您通过调用 mainloop 来让 tkinter 知道窗口内事物的定义已停止.我已经定义了调用 iconbitmap 的窗口,使用 "(app, .."

You let tkinter know that the definition for things inside the window have stopped by calling mainloop. I have defined the window for the iconbitmap when it is called, using "(app, .."

希望这会有所帮助!

这篇关于Python Tkinter 小窗口在主窗口之前瞬间弹出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆