【发布时间】:2022-06-28 04:13:56
【问题描述】:
我正在尝试在 Mac 上使用 tkinter 制作一个基本的 GUI
脚本运行良好,但按钮闪烁。我注意到这种闪烁似乎与光标移动有关。我该如何解决这个问题?
我正在使用 Pycharm,Python 3.8
闪烁视频:https://imgur.com/a/wExBaH9
源代码:
from tkinter import *
class Window(Frame):
def __init__(self, master=None):
Frame.__init__(self, master)
self.master = master
self.pack(fill=BOTH, expand=1)
exitButton = Button(self, text="Exit", command=self.clickExitButton)
exitButton.place(x=0, y=0)
loggerButton = Button(self, text='Run Logger', command=self.clickLoggerButton)
loggerButton.place(x=100, y=100)
def clickExitButton(self):
exit()
def clickLoggerButton(self):
print('seen')
root = Tk()
app = Window(root)
root.wm_title("Fard")
root.geometry("500x500")
root.configure(background='red')
root.mainloop()
编辑:我在 Repl.it 上测试了相同的代码,它运行良好,这让我认为这个错误与渲染窗口有关
【问题讨论】: