From 76df41b5d4a2333bb233841fc01d8fd4e902da26 Mon Sep 17 00:00:00 2001 From: saal Date: Mon, 19 Feb 2007 10:00:56 +0000 Subject: add method clone and __init__ in ZincItem class and modification of method clone of Zinc class now the magicLens example in python should work fine --- Python/library/Zinc.py | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) (limited to 'Python') diff --git a/Python/library/Zinc.py b/Python/library/Zinc.py index 965a5f6..f9cb22d 100644 --- a/Python/library/Zinc.py +++ b/Python/library/Zinc.py @@ -233,7 +233,7 @@ class Zinc( Widget ): def cget( self, option ): """ - val = zinc.cgetz(option) + val = zinc.cget(option) """ return self.tk.call( self._w, 'cget', '-' + option ) @@ -243,12 +243,12 @@ class Zinc( Widget ): """ self.tk.call( self._w, 'chggroup', *args ) - def clone( self, *args ): + def clone( self, *args, **kw): """ id = zinc.clone(tagOrId, **attributs) """ - return self.tk.call( self._w, 'clone', *args ) - + args = list( args ) + list( self._options( kw ) ) + return self.tk.call( self._w, 'clone', *args) def __oldconfigure( self, **kw ): return Widget.configure( self, **kw ) @@ -900,9 +900,18 @@ class ZincItem: translate = kw['translate'] del kw['translate'] + if kw.has_key( 'cloneid' ): + cloneid = kw['cloneid'] + del kw['cloneid'] + else: + cloneid = 0 group = str( group ) - sys.stdout.flush() - self.id = zinc.add( itemType, group, *args, **kw ) + # sys.stdout.flush() + if cloneid == 0 : + self.id = zinc.add( itemType, group, *args, **kw ) + else : + self.id = self.zinc.clone(cloneid, *args, **kw) + zinc.items[self.id] = self texture = None if fillpatern: @@ -922,6 +931,19 @@ class ZincItem: def bbox( self, *args ): return self.zinc.bbox( self.id, *args ) + def clone( self, *args, **kw): + '''id = zincitem.clone(*args,**kw) ''' + # print "ZincItem::clone" + # on cherche tagOrId + # nidcloned = self.find_above(tagOrId) + sclonedtype = self.type() + sclonedgroupid = self.zinc.group(self.id) + + # ajout cle 'cloneid' (voir ZincItem::__init__) + kw['cloneid'] = self.id + # on cree un nouveau ZincItem meme type, + return(ZincItem(self.zinc, sclonedtype, sclonedgroupid, **kw )) + def delete( self ): del self.zinc.items[self.id] try: -- cgit v1.1