Search code examples
pythonmacostkinter

Tk label not displaying on MacOS 13.0.1


I'm new to tkinter. I tried the execute the following:

from tkinter import *
root = Tk()
myLabel1 = Label(root, text="Hello World!")
myLabel1.pack()
root.mainloop()

An window shows up but there is no labels.

I'm running MacOS 13.0.1, Python 3.9.6.

Is this a bug? Am I running an obsolete version of tk?

I've tried to add a root.update() before calling mainloop() as someone suggested. That didn't resolve the issue. I've also tried to set geometry to root and that just give me a bigger empty window.


Solution

  • pip install tkmacosx
    

    Try this:

    from tkinter import Tk
    from tkmacosx import Label
    
    root = Tk()
    
    myLabel1 = Label(root, text="Hello World!")
    myLabel1.pack()
    
    root.mainloop()