【问题标题】:Buttons Flickering while using tkinter Mac OS使用 tkinter Mac OS 时按钮闪烁
【发布时间】: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 上测试了相同的代码,它运行良好,这让我认为这个错误与渲染窗口有关

【问题讨论】:

    标签: python macos tkinter


    【解决方案1】:

    请问您使用的是什么版本的 Mac?我在 Mac 上预装的 python 3.8 遇到了同样的问题,然后找到了this。 所以现在我在 Mac Monterey 12.4 上使用 python 3.9 版,一切似乎都正常工作。 希望对你有帮助。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-11-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-08-26
      • 1970-01-01
      • 2018-01-30
      • 1970-01-01
      相关资源
      最近更新 更多