0

My GUI programing in winXP by tkinter, but i found it appears different size. I learn it because the system defult font is different. When using "control /name Microsoft.Personalization /page pageColorization" in CMD can open this page. But how i can set the project and font in python code?

xxx88qqq
  • 3
  • 3
  • why does it need to be the exact same size? Usually tkinter is really good about handling font and resolution differences, unless you are relying on a layout with explicit coordinates for windows (eg: `place`) which is usually a bad idea. – Bryan Oakley Mar 11 '17 at 10:21
  • I use grid for layout, but the left and rigth edges of different frames not in a line in win7,and it is alignment in winXP. – xxx88qqq Mar 13 '17 at 02:16
  • Why not explain that in your question? The solution to that problem is probably not the same as the answer to how you can "set the project and font in python code". – Bryan Oakley Mar 13 '17 at 02:26
  • Sorry, I am a newcomer, i'll make more details in next question. – xxx88qqq Mar 13 '17 at 02:38

1 Answers1

0

Since version 8.5 Tk defines some global named fonts that are initialized on Windows by reading the system theme defined fonts. So TkDefaultFont is the named font used by most Tk controls if not overridden. This means you change change TkDefaultFont and most of you controls will use the new font definition.

Otherwise, each control has a -font configuration option to pass in a font to use. And there is the option database for assigning options by widget class.

In tkinter the Tk font handling is provided by the tkinter.font package and using this the built-in named font objects can be accessed and modified.

import tkinter.font
# show the defined fonts
print(tkinter.font.names())
# access the default UI font
f = tkinter.font.nametofont('TkDefaultFont')
print(f.configure())
# modify the default font
f.configure(family='Tahoma')
print(f.configure())
patthoyts
  • 32,320
  • 3
  • 62
  • 93