0

I have made a short clock program (from a lesson). On linux and Windows, it all displays as it should like this: linux or windows view

Under OSX is looks like this with the grey box around the text: OSX - same code

Can anyone tell me whats going on? Here is the code:

from tkinter import ttk
from tkinter import *
from tkinter import font
import time
import datetime

def quit(*args):
    root.destroy()

def clock_time():
    time = datetime.datetime.now()
    time = (time.strftime("%H:%M:%S"))
    txt.set(time)
    root.after(1000,clock_time)

root = Tk()
root.title('PyClock')
root.attributes("-fullscreen",False)
root.configure(background='black')
root.bind("x",quit)
root.after(1000,clock_time)

fnt = font.Font(family='Helvetica', size=120, weight='bold')
txt = StringVar()
lbl = ttk.Label(root, textvariable=txt, font=fnt, foreground='white', background='black')
lbl.place(relx=0.5, rely=0.5, anchor=CENTER)

root.mainloop()
Reblochon Masque
  • 35,405
  • 10
  • 55
  • 80

1 Answers1

1

Ttk on MacOS strives to be as native as possible. As such, many of the backgrounds and colors for Ttk widgets cannot be configured.

A standard label can be used instead of the ttk.Label, and it will allow the background to be configured.

Brad Lanam
  • 5,192
  • 2
  • 19
  • 29
  • As a beginner, I am not sure what you mean without an example. I fixed it though by just changing the background color to the same gray as the box the text is in and then making the font black. I am happy with that. – Rick Wohlschlag Nov 03 '20 at 23:10
  • You might be able to select a different theme that lets the foreground and background be configured. – Donal Fellows Nov 04 '20 at 11:45