#!/usr/bin/env python
#
# $Id: CanvasGroup.py,v 1.3 2001/11/03 11:05:22 doughellmann Exp $
#
# Copyright 2001 Doug Hellmann.
#
#
# All Rights Reserved
#
# Permission to use, copy, modify, and distribute this software and
# its documentation for any purpose and without fee is hereby
# granted, provided that the above copyright notice appear in all
# copies and that both that copyright notice and this permission
# notice appear in supporting documentation, and that the name of Doug
# Hellmann not be used in advertising or publicity pertaining to
# distribution of the software without specific, written prior
# permission.
#
# DOUG HELLMANN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
# INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
# NO EVENT SHALL DOUG HELLMANN BE LIABLE FOR ANY SPECIAL, INDIRECT OR
# CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
# OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
# NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
# CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#
"""A subclass of Canvas.Group that knows how to do bbox.
"""
__rcs_info__ = {
#
# Creation Information
#
'module_name' : '$RCSfile: CanvasGroup.py,v $',
'rcs_id' : '$Id: CanvasGroup.py,v 1.3 2001/11/03 11:05:22 doughellmann Exp $',
'creator' : 'Doug Hellmann <doug@hellfly.net>',
'project' : 'PmwContribD',
'created' : 'Sun, 01-Apr-2001 15:02:38 EDT',
#
# Current Information
#
'author' : '$Author: doughellmann $',
'version' : '$Revision: 1.3 $',
'date' : '$Date: 2001/11/03 11:05:22 $',
}
#
# Import system modules
#
import Tkinter
import Canvas
#
# Import Local modules
#
#
# Module
#
class CanvasGroup(Canvas.Group):
"""A subclass of Canvas.Group which knows how to do bbox.
"""
def bbox(self):
"Returns the bounding box of the items in the group."
objs = self.canvas.find_withtag(self.tag)
#ulx,uly,lrx,lry = 0,0, 0,0
ulx,uly,lrx,lry = 100000,100000, 0,0
for item in objs:
x1,y1,x2,y2 = self.canvas.bbox(item)
if x1 < ulx: ulx = x1
if x2 > lrx: lrx = x2
if y1 < uly: uly = y1
if y2 > lry: lry = y2
return ( (ulx,uly), (lrx,lry) )
|