Python Tkinter似乎在打开第二个窗口时模糊了我的图标

Python Tkinter似乎在打开第二个窗口时模糊了我的图标,python,tkinter,Python,Tkinter,我有一个程序,当前在找不到.txt文件时运行四个窗口,在找到文件时只运行一个窗口。在没有文本文件的情况下运行代码时,第一个窗口的图标很好。对于其他三个,它是模糊的。当存在文件时,图标不会模糊。当打开第二个窗口时,它似乎模糊了。我想知道是否有人能帮忙 import os import ctypes from tkinter import * configfile = "config.txt" newname = "" def accept(): global errorbox e

我有一个程序,当前在找不到.txt文件时运行四个窗口,在找到文件时只运行一个窗口。在没有文本文件的情况下运行代码时,第一个窗口的图标很好。对于其他三个,它是模糊的。当存在文件时,图标不会模糊。当打开第二个窗口时,它似乎模糊了。我想知道是否有人能帮忙

import os
import ctypes
from tkinter import *
configfile = "config.txt"
newname = ""

def accept():
    global errorbox
    errorbox.destroy()

def errorrun(title, message, w, h):
    global errorbox
    errorbox = Tk()
    errorbox.title(title)
    errorbox.iconbitmap(default = "favicon.ico")
    errorlabel = Label(errorbox, text = message).pack()
    errorbutton = Button(errorbox, text = "        Ok        ", command = accept).pack()
    ws = errorbox.winfo_screenwidth()
    hs = errorbox.winfo_screenheight()
    x = (ws/2) - (w/2)
    y = (hs/2) - (h/2)
    errorbox.geometry('%dx%d+%d+%d' % (w, h, x, y))
    errorbox.mainloop()

def entryapp():
    global newname
    global entrywindow
    global entering
    newname = entering.get()
    entrywindow.destroy()

def entrybox(title, message, w, h):
    global entrywindow
    global entering
    entrywindow = Tk()
    entrywindow.title(title)
    entrywindow.iconbitmap(default = "favicon.ico")
    entrylabel = Label(entrywindow, text = message).pack()
    entering = Entry(entrywindow)
    entering.pack()
    entrylabelgap = Label(entrywindow, text = " ").pack()
    entrybutton = Button(entrywindow, text = "        Ok        ", command = entryapp).pack()
    ws = entrywindow.winfo_screenwidth()
    hs = entrywindow.winfo_screenheight()
    x = (ws/2) - (w/2)
    y = (hs/2) - (h/2)
    entrywindow.geometry('%dx%d+%d+%d' % (w, h, x, y))
    entrywindow.mainloop()

if os.path.exists(configfile):
    pass
else:
    errorrun("Cannot find file!", "\nThe configuration file was not found.\nCreating one now.\n", 320, 100)
    config = open(configfile,"w")
    config.close()

config = open(configfile,"r")
name = config.readline(1)

if name == "":
    config.close()
    config = open(configfile,"w")
    errorrun("No name detected!", "\nNo name has been detected.\n", 320, 90)
    entrybox("Name entry!", "\nPlease enter your name:\n", 320, 130)
    config.write(newname)

config.close()

def mainmenu():
    mainwindow = Tk()
    mainwindow.iconbitmap(default = "favicon.ico")
    mainwindow.wm_title("Student management system!")
    w = 500
    h = 500
    ws = mainwindow.winfo_screenwidth()
    hs = mainwindow.winfo_screenheight()
    x = (ws/2) - (w/2)
    y = (hs/2) - (h/2)
    mainwindow.geometry('%dx%d+%d+%d' % (w, h, x, y))
    mainwindow.mainloop()

mainmenu()

这听起来像是一个窗口管理器问题。您使用的是什么窗口管理器?不过,您使用Tkinter的方式不寻常,这可能会导致问题。通常,在tkinter程序中,您不应该创建多个
Tk
实例,并且只能调用
mainloop
一次。老实说,我不确定什么是窗口管理器!我将尝试改变系统的运行方式。所有窗口的图标大小是否相同?