I'm probably just doing something stupid, but I can't spot the error. I hope someone here can see what I'm looking past, or knows of a known issue with these widgets.

I'm writing a GUI app using ttk widgets in Tkinter, which includes text displayed in a regular text widget. Some text in the widget will be in Italics, some bold, some both, some regular. I assigned those font effects as tags for the text widget as you can see in the code below.

However, when I run it, about 10% of the time, the text widget will come up with random fonts (e.g., bold italic instead of plain roman), even though I confirmed that it's using 'rm' as the tag when inserting the text into the widget.

The initial setup code includes:
f = Tkinter.Text(self, ...)
f.tag_config('rm', font=tkFont.Font(family='Helvetica', size=10, weight=tkFont.NORMAL, slant-tkFont.ROMAN)) f.tag_config('bf', font=tkFont.Font(family="Helvetica', size=10, weight=tkFont.BOLD, slant=tkFont.ROMAN)) f.tag_config('it', font=tkFont.Font(family="Helvetica', size=10, weight=tkFont.NORMAL, slant=tkFont.ITALIC)) f.tag_config('bi', font=tkFont.Font(family="Helvetica', size=10, weight=tkFont.BOLD, slant=tkFont.ITALIC)) f.tag_config('ref', font=tkFont.Font(family="Helvetica', size=10, weight=tkFont.NORMAL, slant=tkFont.ITALIC), foreground='blue', underline=True)

text is inserted simply by:
f.insert(END, text, 'rm')

and yet some of the time, even though the 'rm' tag is there, I get one of the other fonts I configured for the other tags. Do I need to keep other references to the tkFont objects somewhere else or something?


--
Steve Willoughby / st...@alchemy.com
"A ship in harbor is safe, but that is not what ships are built for."
PGP Fingerprint 4615 3CCE 0F29 AE6C 8FF4 CA01 73FE 997A 765D 696C
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to