[Tkinter-discuss] Can't configure ttk.Entry font
Michael Lange
klappnase at web.de
Wed Nov 28 13:47:24 CET 2012
Hi John,
On Tue, 27 Nov 2012 22:30:16 -0700 (MST)
"John W. Shipman" <john at nmt.edu> wrote:
> Below my signature is a trivial ttk script with two widgets: an
> Entry and a quit button. Styling the font on the quit button
> works great. But styling the font on the Entry widget does not;
> I always get the default font, which is a bit small for many
> people over the age of 40.
>
> I've tried a number of things, but either I'm missing something
> really stupid in my code, or there is a defect in the ttk.Entry
> code that it does not pick up a font.
>
> Here's our version:
>
> >>> tk.__version__
> '$Revision: 81008 $'
> >>> ttk.__version__
> '0.3.1'
here (debian squeeze) it is the same, however if I change your example
a little into:
self._entry = ttk.Entry(self,
font=('helvetica', '30'), textvariable=self._entryVar)
self._entry.grid()
the requested font is actually used. I guess this is a bug in man
ttk_entry, which does not mention the font configuration option.
Now when I try:
print(self._entryStyle.configure('TEntry'))
the result is
{'padding': 1, 'relief': 'sunken', 'fieldbackground': 'white'}
whereas
print(self._entry.cget('font'))
returns
TkTextFont
So apparently the default entry style does not define a font at all, but
the ttk entry uses a standard tk font instead and ignores fonts defined
in styles.
Regards
Michael
.-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-.
"That unit is a woman."
"A mass of conflicting impulses."
-- Spock and Nomad, "The Changeling", stardate 3541.9
More information about the Tkinter-discuss
mailing list