Python Tkinter small window pops up momentarily before main window

寵の児 提交于 2019-12-24 14:52:26

问题


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()

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.


回答1:


Try this:

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

app.mainloop()

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, .."

Hope this helps!



来源:https://stackoverflow.com/questions/34156037/python-tkinter-small-window-pops-up-momentarily-before-main-window

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!