[Tkinter-discuss] Change ttk.Notebook tab's font or font height?
Michael Lange
klappnase at web.de
Wed Dec 15 16:44:09 CET 2010
Hi,
Thus spoketh python at bdurham.com
unto us on Wed, 15 Dec 2010 00:54:37 -0500:
> Is there a way to change the ttk.Notebook tab's font or font
> height?
>
The following example seems to do what you want, at least unless you
change the theme in use:
##########################
from Tkinter import *
import ttk
import tkFont
root = Tk()
f = tkFont.Font(family='helvetica', size=-12)
s = ttk.Style()
s.configure('.', font=f)
nb = ttk.Notebook(root)
nb.pack(fill='both', expand=1)
t = Text(nb, font=f)
nb.add(t, text='foo')
c = Canvas(nb)
nb.add(c, text='bar')
def toggle_font(event):
if event.keysym == '0':
f['size'] = -12
elif event.keysym == 'plus':
if f['size'] > -31:
f['size'] = f['size'] - 1
elif event.keysym == 'minus':
if f['size'] < -6:
f['size'] = f['size'] + 1
root.bind('<Control-plus>', toggle_font)
root.bind('<Control-minus>', toggle_font)
root.bind('<Control-0>', toggle_font)
root.mainloop()
#########################
Regards
Michael
.-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-.
Lots of people drink from the wrong bottle sometimes.
-- Edith Keeler, "The City on the Edge of Forever",
stardate unknown
More information about the Tkinter-discuss
mailing list