【问题标题】:Tkinter showing black screen and flickering in latest macos monetereyTkinter 在最新的 macos monterey 中显示黑屏和闪烁
【发布时间】:2022-12-05 07:00:27
【问题描述】:

我正在使用 Tkinter 为我的任务构建一个聊天应用程序 GUI, 但是当我创建一个基本屏幕时,它没有正确加载,GUI 背景是黑色的(不是颜色)并且什么都看不见,按钮也在闪烁。

添加下面的代码。 (它非常基本的代码)

class ChatGUI: 
    
    def __init__(self) -> None:
        
        #setup window size
        self.Window = Tk()
        self.Window.withdraw()

        #login window 
        self.login = Toplevel()
        self.login.title("Chat - Login")
        self.login.resizable(width=True, height=True)
        self.login.configure(width=400, height=400, bg='blue')
        self.pls = Label(self.login,
                       text = "Please login to continue",
                       justify = CENTER,
                       font = "Helvetica 14 bold")
         
        self.pls.place(relheight = 0.15,
                       relx = 0.2,
                       rely = 0.07)
        # create a Label
        self.labelName = Label(self.login,
                               text = "Name: ",
                               font = "Helvetica 12")
         
        self.labelName.place(relheight = 0.2,
                             relx = 0.1,
                             rely = 0.2)

                             # create a entry box for
        # tyoing the message
        self.entryName = Entry(self.login,
                             font = "Helvetica 14",)
         
        self.entryName.place(relwidth = 0.4,
                             relheight = 0.12,
                             relx = 0.35,
                             rely = 0.2)
         
        # set the focus of the cursor
        self.entryName.focus()
         
        # create a Continue Button
        # along with action
        self.go = Button(self.login,
                         text = "CONTINUE",
                         font = "Helvetica 14 bold",
                         command = lambda: self.goAhead(self.entryName.get()))
         
        self.go.place(relx = 0.4,
                      rely = 0.55)
        self.Window.mainloop()


    def goAhead(self, name):
        pass

附上下面的截图: Output screenshot

【问题讨论】:

  • 为什么要创建一个主窗口然后退出
  • @DelriusEuphoria 我是 tkinter sdk 的新手,我正在学习本教程,是不是错了。链接:geeksforgeeks.org/gui-chat-application-using-tkinter-in-python
  • 任何人都可以对此发表评论吗,我在这里被屏蔽了。
  • 先做一个tkinter的基础教程
  • 即使是基本教程也有同样的问题,tkinter 和新的 Mac OS Monterey 的组合有些可疑

标签: python-3.x tkinter


【解决方案1】:

同样的问题,你找到解决方案了吗?

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-07-17
    • 1970-01-01
    • 2011-11-04
    • 2015-04-01
    相关资源
    最近更新 更多