Tkfont buggy for two Tk() top level windows

Jack Diederich jack at performancedrivers.com
Tue Mar 30 00:06:15 EST 2004


[top post]

Awwww, screw me.
TopLevel() does what I want.

After searching groups.goole and skimming Programming Python
I posted.  And its right there in the docs (and TopLevel is
in the index of PP).

Any Tkinter folks that are listening, consider printing
a warning to stdout when Tk() is called twice or preferably
raising an exception instead of limping along.

On Mon, Mar 29, 2004 at 11:57:26PM -0500, Jack Diederich wrote:
> 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
> 
> 
> 
> -- 
> http://mail.python.org/mailman/listinfo/python-list
> 




More information about the Python-list mailing list