[Tkinter-discuss] Tk*Font question
Bob Greschke
bob at passcal.nmt.edu
Thu Mar 1 00:27:35 CET 2012
What's the correct way to change the font size? The "Change" button isn't doing what I thought it would. The font changes size, but turns into some proportional font. I'm kinda new (1 day) to using TkFixedFont and its friends. I'm used to ("Monoco", 9) sort of stuff and I'm not sure I understand what's going on.
Thanks!
Bob
Python 2.x, Tcl/Tk 8.5.x
====
#! /usr/bin/python
from Tkinter import *
Root = Tk()
Txt = Text()
Txt.pack()
Txt.insert(END, "WWWWWWWWWWWW\n")
Txt.insert(END, "MMMMMMMMMMMM\n")
Txt.insert(END, "iiiiiiiiiiii\n")
print "Before: ", Txt.cget("font")
def changeFont(e = None):
Txt.configure(font = (Txt.cget("font").split()[0], 9))
Root.update()
print "Change: ", Txt.cget("font")
return
def changeFont2(e = None):
Txt.configure(font = Txt.cget("font").split()[0])
Root.update()
print "Change2:", Txt.cget("font")
return
Button(Root, text = "Change", command = changeFont).pack(side = TOP)
Button(Root, text = "Change2", command = changeFont2).pack(side = TOP)
Root.mainloop()
====
More information about the Tkinter-discuss
mailing list