[Python-bugs-list] Tkinter canvas blow-up: bbox(ALL) == None (PR#133)
aa8vb@yahoo.com
aa8vb@yahoo.com
Thu, 18 Nov 1999 13:34:45 -0500 (EST)
Full_Name: Randall Hopper
Version: 1.5.2
OS: IRIX 6.5
Submission from: ethyl-f.rtpfddi.epa.gov (134.67.65.11)
From: "Fredrik Lundh" <fredrik@pythonware.com>
Date: Tue, 2 Nov 1999 09:53:17 +0100
Subject: Re: Tkinter canvas blow-up: bbox(ALL) == None
Randall Hopper <aa8vb@yahoo.com> wrote:
> Apparently if the bounds of the items in a Tk canvas widget exceed
> MAXINT, bbox(ALL) returns None. The attached Python script demonstrates
> this.
>
> Intuitively it seems like this is a bug since the contents of the
> canvas are maintained in floating point; integer bounds shouldn't be
> involved, should they?
>
> Is this a Tk bug or a Tkinter bug?
both.
Tkinter uses _getints instead of _getdoubles to
convert the bounding box to a tuple...
...but the reason you get None instead of an over-
flow error is that Tk returns an empty string in this
case (at least in 8.0.5).
-------------------------------------------------------------------------------
#!/usr/bin/env python
#
# canvas_test.py - Demonstrates a bug in Tkinter's Canvas widget
# where bbox = None when the bbox exceeds signed MAXINT
# (2^31 on most machines).
from Tkinter import *
#
# Create widgets
#
root = Tk()
canvas = Canvas( root, width = 300, height = 300 )
canvas.pack()
canvas.create_rectangle( (-100,-100,100,100),
outline = "#008000", fill="#800000", width = 3 )
canvas.create_line( (-100,-100,100,100),
fill="blue", width=3 )
canvas.create_line( (-100,100,100,-100),
fill="blue", width=3 )
canvas.config( scrollregion = canvas.bbox( ALL ) )
#
# Zoom the canvas until it's bounds get toasted because they exceed MAXINT
#
def TimerCB( canvas=canvas ):
old = canvas.bbox( ALL )
canvas.scale( ALL, 0.0, 0.0, 2.0, 2.0 )
new = canvas.bbox( ALL )
print "Old = %s, New = %s" % ( old, new )
if new == None:
raise SystemError, "canvas's bbox is toast (exceeds signed MAXINT)"
canvas.after( 300, TimerCB )
print "CANVAS ZOOM BLOW-UP TEST:\n"
canvas.after( 1500, TimerCB )
root.mainloop()