Tkfont buggy for two Tk() top level windows

Jack Diederich jack at performancedrivers.com
Mon Mar 29 23:57:26 EST 2004


I'm calling Tk() twice to create two top level windows,
which works fine in every respect except fonts.
Assigning a Tkfont to widgets in the first Tk() window I create works
fine, the font looks good as it should.  But if I start a another
window by calling Tk() again the second window will always use some
awful default font.  Swapping the two lines that call Tk() will
change which one actually uses the font and which doesn't.

The code looks like:
  win_one = Tk()
  win_two = Tk()
  myfont = tkFont.Font(family="Courier", size=12)
  
  Entry(win_one, font=myfont).pack(fill='both',expand=1)
  Entry(win_two, font=myfont).pack(fill='both',expand=1)

Any text on the first window obeys the font, the second
one will always use some system default.  switching the two lines
that call Tk() reverses which window goes font happy.

If calling Tk() twice has undefined behavior I would rather it
raise a useful exception instead of continuing partially gimpy.

Debian testing, python 2.3.3, tk 8.2.3-5
This has been the behavior for 6-12 months (as long as I've been using
Tk).  Until now I just assumed I had missed a call, after checking it
out it seems to be a Tk thing.

TIA,

-jackdied






More information about the Python-list mailing list