alessandro
alessandro

Reputation: 3984

Tkinter fonts on Mac OS X

I'm writing a Tkinter/Python program, which I want to run under both Linux and Mac OS X.

In Linux I'm very satisfied by the look of it, but under Mac OS X the fonts look really awful, though I'm using well supported ones: Helvetica, Arial.

Do you have some suggestions for fonts that look good under Tkinter?

Upvotes: 2

Views: 2147

Answers (1)

D K
D K

Reputation: 5760

Try using system fonts like:

  • TkDefaultFont
  • TkTextFont
  • TkFixedFont
  • TkMenuFont
  • TkHeadingFont
  • TkCaptionFont
  • TkSmallCaptionFont
  • TkIconFont
  • TkTooltipFont

Here's a simple code sample:

from Tkinter import *
root = Tk()
l = Label(root, text="Hello World", font="TkSmallCaptionFont")
l.pack()
root.mainloop()

The nice thing about these fonts is that they are cross-platform and they look native.

If the code above does not work, make sure your Tkinter version is at least 8.5. These fonts will not work with Tkinter 8.4 or less.

Upvotes: 3

Related Questions