Tkinter canvas blow-up: bbox(ALL) == None

Randall Hopper aa8vb at yahoo.com
Mon Nov 1 16:21:03 CET 1999


     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?

Thanks,

Randall


-- 
Randall Hopper
aa8vb at yahoo.com
-------------- next part --------------
#!/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()


More information about the Python-list mailing list