aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlecoanet2008-09-15 09:38:54 +0000
committerlecoanet2008-09-15 09:38:54 +0000
commit9bdf88f4cd99ef9d28db5f5567592082cbc8c61d (patch)
tree823cd4070692ae5a562072b239d3487b402745c8
parent984cd56bebd7e47ef5ded2179a721158335e36d7 (diff)
downloadtkzinc-9bdf88f4cd99ef9d28db5f5567592082cbc8c61d.zip
tkzinc-9bdf88f4cd99ef9d28db5f5567592082cbc8c61d.tar.gz
tkzinc-9bdf88f4cd99ef9d28db5f5567592082cbc8c61d.tar.bz2
tkzinc-9bdf88f4cd99ef9d28db5f5567592082cbc8c61d.tar.xz
Added support for xview and yview methods (scrollbar protocol)
-rw-r--r--Python/library/Zinc.py2225
1 files changed, 1125 insertions, 1100 deletions
diff --git a/Python/library/Zinc.py b/Python/library/Zinc.py
index f9cb22d..f55aa56 100644
--- a/Python/library/Zinc.py
+++ b/Python/library/Zinc.py
@@ -35,1062 +35,1087 @@ ZINC_NO_PART = ""
# current part dictionnary
ZINC_DPART = { 'position' : ZINC_CURRENT_POSITION,
- 'speedvector' : ZINC_SPEED_VECTOR ,
- 'leader' : ZINC_LEADER,
- 'connection' : ZINC_CONNECTION}
+ 'speedvector' : ZINC_SPEED_VECTOR ,
+ 'leader' : ZINC_LEADER,
+ 'connection' : ZINC_CONNECTION}
# notes : 'field' will be return when currentpart is a field
def havetkzinc( window ):
- '''load Zinc dynamic sharable object library , test if everything is ok
+ '''load Zinc dynamic sharable object library , test if everything is ok
if ok :return zinc version
if nok : return 0 '''
- global _LIBLOADED
- global _VERSION
- if ( _LIBLOADED == 1 ) :
- return _VERSION
- try:
- if os.environ.has_key( 'auto_path' ):
- ldir = os.environ['auto_path'].split( ':' )
- ldir.reverse()
- for adir in ldir :
- window.tk.call( 'eval',
- "set auto_path "
- + "[linsert $auto_path 0 %s]" % ( adir ) )
- window.tk.call( 'eval', 'package require Tkzinc' )
- # Call a function from the package to autoload it
- # and verify that all is OK.
- sversion = window.tk.call( 'zinc' ) + " Zinc.py %s" % __version__
- except TclError:
- traceback.print_exc()
- return 0
- _LIBLOADED = 1
- _VERSION = sversion
- return sversion
+ global _LIBLOADED
+ global _VERSION
+ if ( _LIBLOADED == 1 ) :
+ return _VERSION
+ try:
+ if os.environ.has_key( 'auto_path' ):
+ ldir = os.environ['auto_path'].split( ':' )
+ ldir.reverse()
+ for adir in ldir :
+ window.tk.call( 'eval',
+ "set auto_path "
+ + "[linsert $auto_path 0 %s]" % ( adir ) )
+ window.tk.call( 'eval', 'package require Tkzinc' )
+ # Call a function from the package to autoload it
+ # and verify that all is OK.
+ sversion = window.tk.call( 'zinc' ) + " Zinc.py %s" % __version__
+ except TclError:
+ traceback.print_exc()
+ return 0
+ _LIBLOADED = 1
+ _VERSION = sversion
+ return sversion
class ZincException:
- def __call__( self ):
- raise self
+ def __call__( self ):
+ raise self
- def __init__( self, message ):
- self.message = message
-
- def __str__( self ):
- return self.message
+ def __init__( self, message ):
+ self.message = message
+
+ def __str__( self ):
+ return self.message
class Zinc( Widget ):
- def __str__( self ):
- return( "Zinc instance" )
- def __init__( self, master = None, cnf = None, **kw ):
- if kw.has_key( 'backward_compatibility' ):
- self.currentpart = self.__oldcurrentpart
- self.configure = self.__oldconfigure
- self.scale = self.__oldscale
- self.translate = self.__oldtranslate
- del kw['backward_compatibility']
- #Pour éviter des effets de bord
- #si on met comme valeur par défaut de cnf
- #à {}
- if cnf is None :
- cnf = {}
- if master :
- self.version = havetkzinc( master )
- else:
- master = Frame()
- master.pack()
- self.version = havetkzinc( master )
- Widget.__init__( self, master, 'zinc', cnf, kw )
- self.items = {}
- #BootStrap Root
- classe = eval( 'Group' )
- obj = None
- kw['id'] = 1
- obj = new.instance( classe, kw )
- self.items[1] = obj
-
- def mainloop( self ):
- """
- Run the events mainloop
- """
- self.tk.mainloop()
-
- def add( self, itemType, *args, **kw ):
- """
- listTypes = zinc.add()
- id = zinc.add(type, group)
- id = zinc.add(type, group, initargs, **options)
- type=[arc|curve|rectangle|triangles|tabular|track|waypoint|group|icon|map|reticle|text|window]
- """
- args = list( args )
- args = args+list( self._options( kw ) )
- try:
- return self.tk.getint(
- self.tk.call( self._w, 'add', itemType, *args ) )
- except TclError, excpt :
- ZincException( "%s\nType %s\nArgs : %s"%( excpt, itemType, args ) )()
-
- def addtag( self, *args ):
- """
- zinc.addtag(tag, searchSpec)
- This command add the given tag to all items matching
- the search specification.
- If the tag is already present on some item,
- nothing is done for that item.
- The command has no effect if no item satisfy
- the given criteria. The command returns an empty string.
- """
- self.tk.call( self._w, 'addtag', *args )
-
- def addtag_above( self, newtag, tagOrId ):
- """
- zinc.addtag_above(tag, tagOrId)
- """
- self.addtag( newtag, 'above', tagOrId )
-
- def addtag_all( self, newtag ):
- """
- A ne plus utiliser
- Utiliser addtag_withtag
- """
- self.addtag( newtag, 'all' )
-
- def addtag_ancestors( self, newtag, tagOrId, *ltagOrId ):
- """
- zinc.addtag_ancestors(tag, tagOrId, *listTagOrId)
- """
- self.addtag( newtag, 'ancestors', tagOrId, *ltagOrId )
-
- def addtag_atpriority( self, newtag, pri, tagOrId = 1 ):
- """
- zinc.addtag_atpriority(tag, priority, tagOrId = 1)
- """
-
- self.addtag( newtag, 'atpriority', pri, tagOrId )
-
- def addtag_below( self, newtag, tagOrId ):
- """
- zinc.addtag_below(tag, tagOrId)
- """
- self.addtag( newtag, 'below', tagOrId )
-
- def addtag_closest( self, newtag, x, y, halo = None, startItem = 1, recursive = 0 ):
- """
- zinc.addtag_closest(tag, x, y, halo = None, startItem = 1, recursive = 0)
- """
- self.addtag( newtag, 'closest', x, y, halo, startItem, recursive )
-
- def addtag_enclosed( self, newtag, x1, y1, x2, y2, inGroup = 1, recursive = 0 ):
- """
- zinc.addtag_enclosed(tag, x1, y1, x2, y2, inGroup = 1, recursive = 0)
- """
- self.addtag( newtag, 'enclosed', x1, y1, x2, y2, inGroup, recursive )
-
- def addtag_overlapping( self, newtag, x1, y1, x2, y2, inGroup = 1, recursive = 0 ):
- """
- zinc.addtag_overlapping(tag, x1, y1, x2, y2, inGroup = 1, recursive = 0)
- """
- self.addtag( newtag, 'overlapping', x1, y1, x2, y2, inGroup, recursive )
-
- def addtag_withtag( self, newtag, tagOrId ):
- """
- zinc.addtag_withtag(tag, tagOrId)
- """
- self.addtag( newtag, 'withtag', tagOrId )
-
- def addtag_withtype( self, newtag, type, tagOrId = 1 ):
- """
- zinc.addtag_withtype(tag, type, tagOrId = 1)
- """
- self.addtag( newtag, 'withtype', type, tagOrId )
-
- def anchorxy( self, *args ):
- """
- (x, y) = zinc.anchorxy(tagOrId, anchor)
- """
- return self.tk.call( self._w, 'anchorxy', *args )
-
- def bbox( self, *args ):
- """
- (xo, yo, xc, yc) = zinc.bbox(tagOrId, ?fieldIndex?)
- """
- return self.tk.call( self._w, 'bbox', *args )
-
- def becomes( self ):
- """
- zinc.becomes()
- """
- self.tk.call( self._w, 'becomes' )
-
- def bind_tag( self, tagOrId, sequence = None, func = None, add = None ):
- '''
- return a funcid which can be usefull for unbinding
- listBindings = zinc.bind_tag(tagOrId)
- listbindings = zinc.bind_tag(tagOrId, sequence)
- zinc.bind_tag(tagOrId, sequence, '')
- zinc.bind_tag(tagOrId, sequence, command)
- '''
- return self._bind( ( self._w, 'bind', tagOrId ),
- sequence, func, add )
-
- def cget( self, option ):
- """
- val = zinc.cget(option)
- """
- return self.tk.call( self._w, 'cget', '-' + option )
-
- def chggroup( self, *args ):
- """
- zinc.chggroup(tagOrId, group, ?adjustTransform?)
- """
- self.tk.call( self._w, 'chggroup', *args )
-
- def clone( self, *args, **kw):
- """
- id = zinc.clone(tagOrId, **attributs)
- """
- args = list( args ) + list( self._options( kw ) )
- return self.tk.call( self._w, 'clone', *args)
-
- def __oldconfigure( self, **kw ):
- return Widget.configure( self, **kw )
-
- def configure( self, **kw ):
- """
- listOptions = zinc.configurez()
- listOptions = zinc.configurez(option)
- zinc.configurez(**options)
- """
- res = Widget.configure( self, **kw )
- dico = {}
- if res:
- for i, j in res.items():
- dico[i] = j[3:]
- return dico
-
- def contour( self, *args ):
- """
- contourNum = zinc.contour(tagOrId)
- contourNum = zinc.contour(tagOrId, operatorAndFlag, coordListOrTagOrId)
- """
- return self.tk.call( self._w, 'contour', *args )
-
- def coords( self, *args ):
- """
- zinc.coords(tagOrId, contourIndex)
- zinc.coords(tagOrId, contourIndex, coordList)
- zinc.coords(tagOrId, contourIndex, coordIndex)
- zinc.coords(tagOrId, contourIndex, coordIndex, coordList)
- zinc.coords(tagOrId, 'remove', contourIndex, coordIndex)
- zinc.coords(tagOrId, 'add', contourIndex, coordList)
- zinc.coords(tagOrId, 'add', contourIndex, coordIndex, coordList)
- zinc.coords(tagOrId)
- zinc.coords(tagOrId, coordList)
- zinc.coords(tagOrId, 'remove', coordIndex)
- zinc.coords(tagOrId, 'add', coordList)
- """
- return self.tk.call( self._w, 'coords', *args )
-
- def __buggyoldcurrentpart( self ):
- '''
- return a string (result from zinc current part function) and an
- integer representing either the number of the field either
- the number of the item part either ZINC_NO_PART
- '''
- scurrentp = self.tk.call( self._w, 'currentpart' )
- if scurrentp == "":
- rvalue = ZINC_NO_PART
- else:
- try:
- rvalue = locale.atoi( scurrentp )
- except:
- try:
- rvalue = ZINC_DPART[scurrentp]
- except:
- rvalue = ZINC_NO_PART
- else:
- # string to integer succeeded
- scurrentp = "field"
- return( scurrentp, rvalue )
-
- def __oldcurrentpart( self ):
- '''return a string and an integer ;
+ def __str__( self ):
+ return( "Zinc instance" )
+ def __init__( self, master = None, cnf = None, **kw ):
+ if kw.has_key( 'backward_compatibility' ):
+ self.currentpart = self.__oldcurrentpart
+ self.configure = self.__oldconfigure
+ self.scale = self.__oldscale
+ self.translate = self.__oldtranslate
+ del kw['backward_compatibility']
+ #Pour éviter des effets de bord
+ #si on met comme valeur par défaut de cnf
+ #à {}
+ if cnf is None :
+ cnf = {}
+ if master :
+ self.version = havetkzinc( master )
+ else:
+ master = Frame()
+ master.pack()
+ self.version = havetkzinc( master )
+ Widget.__init__( self, master, 'zinc', cnf, kw )
+ self.items = {}
+ #BootStrap Root
+ classe = eval( 'Group' )
+ obj = None
+ kw['id'] = 1
+ obj = new.instance( classe, kw )
+ self.items[1] = obj
+
+ def mainloop( self ):
+ """
+ Run the events mainloop
+ """
+ self.tk.mainloop()
+
+ def add( self, itemType, *args, **kw ):
+ """
+ listTypes = zinc.add()
+ id = zinc.add(type, group)
+ id = zinc.add(type, group, initargs, **options)
+ type=[arc|curve|rectangle|triangles|tabular|track|waypoint|group|icon|map|reticle|text|window]
+ """
+ args = list( args )
+ args = args+list( self._options( kw ) )
+ try:
+ return self.tk.getint(
+ self.tk.call( self._w, 'add', itemType, *args ) )
+ except TclError, excpt :
+ ZincException( "%s\nType %s\nArgs : %s"%( excpt, itemType, args ) )()
+
+ def addtag( self, *args ):
+ """
+ zinc.addtag(tag, searchSpec)
+ This command add the given tag to all items matching
+ the search specification.
+ If the tag is already present on some item,
+ nothing is done for that item.
+ The command has no effect if no item satisfy
+ the given criteria. The command returns an empty string.
+ """
+ self.tk.call( self._w, 'addtag', *args )
+
+ def addtag_above( self, newtag, tagOrId ):
+ """
+ zinc.addtag_above(tag, tagOrId)
+ """
+ self.addtag( newtag, 'above', tagOrId )
+
+ def addtag_all( self, newtag ):
+ """
+ A ne plus utiliser
+ Utiliser addtag_withtag
+ """
+ self.addtag( newtag, 'all' )
+
+ def addtag_ancestors( self, newtag, tagOrId, *ltagOrId ):
+ """
+ zinc.addtag_ancestors(tag, tagOrId, *listTagOrId)
+ """
+ self.addtag( newtag, 'ancestors', tagOrId, *ltagOrId )
+
+ def addtag_atpriority( self, newtag, pri, tagOrId = 1 ):
+ """
+ zinc.addtag_atpriority(tag, priority, tagOrId = 1)
+ """
+
+ self.addtag( newtag, 'atpriority', pri, tagOrId )
+
+ def addtag_below( self, newtag, tagOrId ):
+ """
+ zinc.addtag_below(tag, tagOrId)
+ """
+ self.addtag( newtag, 'below', tagOrId )
+
+ def addtag_closest( self, newtag, x, y, halo = None, startItem = 1, recursive = 0 ):
+ """
+ zinc.addtag_closest(tag, x, y, halo = None, startItem = 1, recursive = 0)
+ """
+ self.addtag( newtag, 'closest', x, y, halo, startItem, recursive )
+
+ def addtag_enclosed( self, newtag, x1, y1, x2, y2, inGroup = 1, recursive = 0 ):
+ """
+ zinc.addtag_enclosed(tag, x1, y1, x2, y2, inGroup = 1, recursive = 0)
+ """
+ self.addtag( newtag, 'enclosed', x1, y1, x2, y2, inGroup, recursive )
+
+ def addtag_overlapping( self, newtag, x1, y1, x2, y2, inGroup = 1, recursive = 0 ):
+ """
+ zinc.addtag_overlapping(tag, x1, y1, x2, y2, inGroup = 1, recursive = 0)
+ """
+ self.addtag( newtag, 'overlapping', x1, y1, x2, y2, inGroup, recursive )
+
+ def addtag_withtag( self, newtag, tagOrId ):
+ """
+ zinc.addtag_withtag(tag, tagOrId)
+ """
+ self.addtag( newtag, 'withtag', tagOrId )
+
+ def addtag_withtype( self, newtag, type, tagOrId = 1 ):
+ """
+ zinc.addtag_withtype(tag, type, tagOrId = 1)
+ """
+ self.addtag( newtag, 'withtype', type, tagOrId )
+
+ def anchorxy( self, *args ):
+ """
+ (x, y) = zinc.anchorxy(tagOrId, anchor)
+ """
+ return self.tk.call( self._w, 'anchorxy', *args )
+
+ def bbox( self, *args ):
+ """
+ (xo, yo, xc, yc) = zinc.bbox(tagOrId, ?fieldIndex?)
+ """
+ return self.tk.call( self._w, 'bbox', *args )
+
+ def becomes( self ):
+ """
+ zinc.becomes()
+ """
+ self.tk.call( self._w, 'becomes' )
+
+ def bind_tag( self, tagOrId, sequence = None, func = None, add = None ):
+ '''
+ return a funcid which can be usefull for unbinding
+ listBindings = zinc.bind_tag(tagOrId)
+ listbindings = zinc.bind_tag(tagOrId, sequence)
+ zinc.bind_tag(tagOrId, sequence, '')
+ zinc.bind_tag(tagOrId, sequence, command)
+ '''
+ return self._bind( ( self._w, 'bind', tagOrId ),
+ sequence, func, add )
+
+ def cget( self, option ):
+ """
+ val = zinc.cget(option)
+ """
+ return self.tk.call( self._w, 'cget', '-' + option )
+
+ def chggroup( self, *args ):
+ """
+ zinc.chggroup(tagOrId, group, ?adjustTransform?)
+ """
+ self.tk.call( self._w, 'chggroup', *args )
+
+ def clone( self, *args, **kw):
+ """
+ id = zinc.clone(tagOrId, **attributs)
+ """
+ args = list( args ) + list( self._options( kw ) )
+ return self.tk.call( self._w, 'clone', *args)
+
+ def __oldconfigure( self, **kw ):
+ return Widget.configure( self, **kw )
+
+ def configure( self, **kw ):
+ """
+ listOptions = zinc.configurez()
+ listOptions = zinc.configurez(option)
+ zinc.configurez(**options)
+ """
+ res = Widget.configure( self, **kw )
+ dico = {}
+ if res:
+ for i, j in res.items():
+ dico[i] = j[3:]
+ return dico
+
+ def contour( self, *args ):
+ """
+ contourNum = zinc.contour(tagOrId)
+ contourNum = zinc.contour(tagOrId, operatorAndFlag, coordListOrTagOrId)
+ """
+ return self.tk.call( self._w, 'contour', *args )
+
+ def coords( self, *args ):
+ """
+ zinc.coords(tagOrId, contourIndex)
+ zinc.coords(tagOrId, contourIndex, coordList)
+ zinc.coords(tagOrId, contourIndex, coordIndex)
+ zinc.coords(tagOrId, contourIndex, coordIndex, coordList)
+ zinc.coords(tagOrId, 'remove', contourIndex, coordIndex)
+ zinc.coords(tagOrId, 'add', contourIndex, coordList)
+ zinc.coords(tagOrId, 'add', contourIndex, coordIndex, coordList)
+ zinc.coords(tagOrId)
+ zinc.coords(tagOrId, coordList)
+ zinc.coords(tagOrId, 'remove', coordIndex)
+ zinc.coords(tagOrId, 'add', coordList)
+ """
+ return self.tk.call( self._w, 'coords', *args )
+
+ def __buggyoldcurrentpart( self ):
+ '''
+ return a string (result from zinc current part function) and an
+ integer representing either the number of the field either
+ the number of the item part either ZINC_NO_PART
+ '''
+ scurrentp = self.tk.call( self._w, 'currentpart' )
+ if scurrentp == "":
+ rvalue = ZINC_NO_PART
+ else:
+ try:
+ rvalue = locale.atoi( scurrentp )
+ except:
+ try:
+ rvalue = ZINC_DPART[scurrentp]
+ except:
+ rvalue = ZINC_NO_PART
+ else:
+ # string to integer succeeded
+ scurrentp = "field"
+ return( scurrentp, rvalue )
+
+ def __oldcurrentpart( self ):
+ '''return a string and an integer ;
the string is among "field", "position", "speedvector", "leader", "connection", "",
the number is the number of the part , or the field number in case of "field";
ex:
no part return '', ZINC_NO_PART
'''
- scurrentp = self.tk.call( self._w, 'currentpart' )
- print "Zinc::__oldcurrentpart scurrentp = [%s]" % scurrentp
- # warning : read this first :
- # return a string among 'position', 'speedvector', 'leader', 'connection' ,''
- # or an int representing the number of a field label
- #
- # print "Zinc::currentpart cp=%s ,type(cp)=%s" % (scurrentp,type(scurrentp))
- if scurrentp == "":
- rvalue = ZINC_NO_PART
- elif type( scurrentp ) == type( 1 ):
- # meaning a field
- # the subtil thing is here ! warning !
- rvalue = scurrentp
- scurrentp = "field"
- else:
- # scurrentp is a string different from ""
- try:
- rvalue = ZINC_DPART[scurrentp]
- except:
- print "Zinc::currentpart unknown item part"
- rvalue = ZINC_NO_PART
-
- return scurrentp, rvalue
-
- def currentpart( self ):
- '''
- num = zinc.currentpart()
- '''
- return str( self.tk.call( self._w, 'currentpart' ) )
-
-
- def cursor( self, *args ):
- """
- zinc.cursor(tagOrId, index)
- """
- self.tk.call( self._w, 'cursor', *args )
-
- def dchars( self, *args ):
- """
- zinc.dchars( tagOrId, first )
- zinc.dchars( tagOrId, first,last )
- """
- self.tk.call( self._w, 'dchars', *args )
-
- def dtag( self, *args ):
- """
- zinc.dtag(tagOrId)
- zinc.dtag(tagOrId, tagToDelete)
- """
- self.tk.call( self._w, 'dtag', *args )
-
- def find( self, *args ):
- return self._getints(
- self.tk.call( self._w, 'find', *args ) ) or ()
-
- def find_above( self, tagOrId ):
- """
- listItems=zinc.find_above(tagOrId)}
- """
- return self.find( 'above', tagOrId )
-
- def find_all( self ):
- return self.find( 'all' )
-
- def find_ancestors( self, newtag, tagOrId, *tagOrId2 ):
- """
- listItems=zinc.find_ancestor(tag, tagOrId, ?tagOrId2?)
- """
- return self.find( newtag, 'ancestors', tagOrId, *tagOrId2 )
-
- def find_atpriority( self, pri, *tagOrId ):
- """
- listItems=zinc.find_atpriority(pri, ?tagOrId?)
- """
- return self.find( 'atpriority', pri, *tagOrId )
-
- def find_below( self, tagOrId ):
- """
- listItems=zinc.find_below(tagOrId)
- """
- return self.find( 'below', tagOrId )
-
- def find_closest( self, x, y, *options ):
- """
- listItems=zinc.find_closest(x, y, ?halo?, ?startItem?, ?recursive?)
- """
- return self.find( 'closest', x, y, *options )
-
- def find_enclosed( self, x1, y1, x2, y2 ):
- """
- listItems=zinc.find_enclosed(x1, y1, x2, y2, inGroup=1, recursive=0)
- """
- return self.find( 'enclosed', x1, y1, x2, y2 )
-
- def find_overlapping( self, x1, y1, x2, y2, *options ):
- """
- listItems=zinc.find_overlapping( x1, y1, x2, y2, ?inGroup?, ?recursive?)
- """
- return self.find( 'overlapping', x1, y1, x2, y2, *options )
-
- def find_withtag( self, tagOrId ):
- """
- listItems=zinc.find_withtag( tagOrId)
- """
- return self.find( 'withtag', tagOrId )
-
- def find_withtype( self, type, *tagOrId ):
- """
- listItems=zinc.find_withtype( type, ?tagOrId?)
- """
- return self.find( 'withtype', type, *tagOrId )
-
-
- def fit( self, *args ):
- """
- listControls=zinc.fit(coordList,error)
- """
- return self.tk.call( self._w, 'fit', *args )
-
- def focus( self, *args ):
- """
- zinc.focus(tagOrId, ?itemPart?)
- """
- self.tk.call( self._w, 'focus', *args )
-
- def gdelete( self, *args ):
- """
- zinc.gdelete(gradientName)
- """
- self.tk.call( self._w, 'gdelete', *args )
-
- def gettags( self, *args ):
- """
- listTags=zinc.gettags(tagorid)
- """
- return self.tk.splitlist( self.tk.call( self._w, 'gettags', *args ) )
-
- def gname( self, *args ):
- """
- zinc.gname(gradientDesc, gradientName)
- bExist=zinc.gname(gradientName)
- """
- return self.tk.call( self._w, 'gname', *args )
-
- def group( self, *args ):
- """
- group=zinc.group(tagOrId)
- """
- return self.tk.call( self._w, 'group', *args )
-
- def hasanchors( self, *args ):
- """
- bool=zinc.hasanchors(tagOrId)
- """
- return self.tk.call( self._w, 'hasanchors', *args )
-
- def hasfields( self, *args ):
- """
- bool=zinc.hasfields(tagOrId)
- """
- return self.tk.call( self._w, 'hasfield', *args )
-
- def hastag( self, *args ):
- """
- bool=zinc.hastag(tagOrId, tag)
- """
- return self.tk.call( self._w, 'hastag', *args )
-
- def index( self, *args ):
- """
- num = zinc.index(tagOrId, index)
- """
- return self.tk.call( self._w, 'tagOrId', *args )
-
- def insert( self, *args ):
- """
- zinc.insert(tagOrId, before, string)
- """
- self.tk.call( self._w, 'insert', *args )
-
- def itemcget( self, tagOrId, option ):
- """
- val=zinc.itemcget(tagOrId, attr)
- """
- return self.tk.call( self._w, 'itemcget', tagOrId, '-'+option )
-
- def itemfieldget( self, tagOrId, field, option ):
- """
- val=zinc.itemcget(tagOrId, field, attr)
- """
- return self.tk.call( self._w, 'itemcget', tagOrId, field, '-'+option )
-
- def itemconfigure( self, tagOrId, field=None, **kw ):
- '''
- either get the dictionnary of possible attributes (if kw is None)
- either allow to set Items attributes or Field attributes
-
- listAttribs=zinc.itemconfigure(tagOrId)
- listAttribs=zinc.itemconfigure(tagOrId, attrib)
- zinc.itemconfigure(tagOrId, **attributs)
- listAttribs=zinc.itemconfigure(tagOrId, fieldIs, attrib)
- zinc.itemconfigure(TagOrId,fieldId,**attributs)
- '''
- if not kw:
- cnf = {}
- for var_x in self.tk.split(
- field != None and self.tk.call( self._w, 'itemconfigure',
- ( tagOrId, field ) ) or
- self.tk.call( self._w, 'itemconfigure', ( tagOrId, ) ) ):
- cnf[var_x[0][1:]] = ( var_x[0][1:], ) + var_x[1:]
- return cnf
- if field != None:
- args = ( tagOrId, str( field ), )+ self._options( {}, kw )
- self.tk.call( self._w, 'itemconfigure', *args )
- else:
- args = ( tagOrId, ) + self._options( {}, kw )
- self.tk.call( self._w, 'itemconfigure', *args )
-
- # _dp voir si cette instruction est a execute ici
- # permet de creer un synonyme de itemconfigure
- itemconfig = itemconfigure
-
- def loweritem( self, *args ):
- """
- zinc.loweritem(tagOrId)
- zinc.loweritem(tagOrId, belowThis)
- Reorder all the items given by tagOrId so that
- they will be under the item given by belowThis.
- If tagOrId name more than one item,
- their relative order will be preserved.
- If tagOrId doesn't name an item, an error is raised.
- If belowThis name more than one item, the bottom most them is used.
- If belowThis doesn't name an item, an error is raised.
- If belowThis is omitted the items are put
- at the bottom most position of their respective groups.
- The command ignore all items named by tagOrId
- that are not in the same group than belowThis or,
- if not specified, in the same group than the first item
- named by tagOrId. The command returns an empty string.
- As a side affect of this command, the -priority attribute
- of all the reordered items is ajusted to match the priority
- of the belowThis item (or the priority of the bottom most item)
- """
- self.tk.call( self._w, 'lower', *args )
-
- def monitor( self, *args ):
- """
- bool = zinc.monitor()
- zinc.monitor(bool)
- """
- return self.tk.call( self._w, 'monitor', *args )
-
- def numparts( self, *args ):
- """
- num = zinc.numparts(tagOrId)
- """
- return self.tk.call( self._w, 'numparts', *args )
-
- def postcript( self, *args ):
- """
- Not Yet Implemented
- zinc.postscript()
- """
- return self.tk.call( self._w, 'postscript', *args )
-
- def raiseitem( self, *args ):
- """
- Correspond à l'appel raise de la documentation
- le mot raise est reservé en python
- zinc.raiseitem(tagOrId)
- zinc.raiseitem(tagOrId, aboveThis)
- """
- self.tk.call( self._w, 'raise', *args )
-
- def remove( self, *args ):
- """
- zinc.remove(tagOrId, ?tagOrId,...?)
- """
- self.tk.call( self._w, 'remove', *args )
-
- def rotate( self, *args ):
- """
- zinc.rotate(tagOrId, angle)
- zinc.rotate(tagOrId, angle, centerX, centerY)
- """
- self.tk.call( self._w, 'rotate', *args )
-
- def __oldscale( self, xFactor=None, yFactor=None, tagOrId=None ):
- if yFactor == None:
- return self.tk.getdouble( self.tk.call( 'scale' ) )
- else:
- if tagOrId == None:
- self.tk.call( self._w, 'scale', xFactor, yFactor )
- else:
- self.tk.call( self._w, 'scale', tagOrId, xFactor, yFactor )
-
- def scale( self, *args ):
- """
- zinc.scale(tagOrIdOrTName, xFactor, yFactor)
- zinc.scale(tagOrIdOrTName, xFactor, yFactor, centerX, centerY)
- Add a scale factor to the items or the transform described
- by tagOrId.
- If tagOrId describes a named transform then this transform
- is used to do the operation. If tagOrId describes more than
- one item then all the items are affected by the operation.
- If tagOrId describes neither a named transform nor an item,
- an error is raised.
- A separate factor is specified for X and Y.
- The optional parameters describe the center of scaling,
- which defaults to the origin.
- """
- if not len( args ):
- return self.tk.getdouble( self.tk.call( self._w, 'scale' ) )
- else:
- self.tk.call( self._w, 'scale', *args )
-
- def select( self, *args ):
- """
- zinc.select('adjust', tagOrId, index)
- Adjust the end of the selection in tagOrId
- that is nearest to the character given by index so
- that it is at index.
- The other end of the selection is made the anchor
- for future select to commands.
- If the selection is not currently in tagOrId,
- this command behaves as the select to command.
- The command returns an empty string.
- zinc.select('clear')
- Clear the selection if it is in the widget.
- If the selection is not in the widget,
- the command has no effect. Return an empty string.
- zinc.select('from', tagOrId, index)
- Set the selection anchor point for the widget
- to be just before the character given by index
- in the item described by tagOrId.
- The command has no effect on the selection,
- it sets one end of the selection so that future
- select to can actually set the selection.
- The command returns an empty string.
- (item,part) = zinc.select('item')
- Returns a list of two elements.
- The first is the id of the selected item
- if the selection is in an item on this widget;
- Otherwise the first element is an empty string.
- The second element is the part of the item
- (track, waypoint or tabular item only) or the empty string.
- zinc.select('to', tagOrId, index)
- Set the selection to be the characters that lies
- between the selection anchor and index in the item described
- by tagOrId. The selection includes the character given
- by index and includes the character given by the anchor point
- if index is greater or equal to the anchor point.
- The anchor point is set by the most recent select adjust
- or select from command issued for this widget.
- If the selection anchor point for the widget is not currently
- in tagOrId, it is set to the character given by index.
- The command returns an empty string.
- Manipulates the selection as requested by option.
- tagOrId describes the target item.
- This item must support text indexing and selection. I
- f more than one item is referred to by tagOrId,
- the first in display list order that support both text
- indexing and selection will be used.
- Some forms of the command include an index parameter,
- this parameter describes a textual position within the
- item and should be a valid index as described in
- Text indices.
- """
- return self.tk.call( self._w, 'select', *args )
-
- def skew( self, *args ):
- """
- zinc.skew(tagOrIdOrTName,xSkewAngle, ySkewAngle)
- Add a skew (or shear) transform to the to the items
- or the transform described by tagOrIdOrTName.
- If tagOrId describes a named transform then this transform
- is used to do the operation.
- If tagOrId describes more than one item then all the
- items are affected by the operation.
- If tagOrId describes neither a named transform nor an item,
- an error is raised. The angles are given in radian.
- """
- return self.tk.call( self._w, 'skew', *args )
-
- def smooth( self, *args ):
- """
- zinc.smooth(coordList)
- This command computes a sequence of segments
- that will smooth the polygon described by the vertices
- in coordList and returns a list of lists describing points
- of the generated segments. These segments are approximating
- a Bezier curve. coordList should be either a flat list
- of an even number of coordinates in x, y order, or a list
- of lists of point coordinates X, Y.
- The returned list can be used to create or change the contour
- of a curve item.
- """
- return self.tk.call( self._w, 'smooth', *args )
-
- def tapply( self, *args ):
- """
- Not Yet Implemented
- zinc.tapply()
- """
- return self.tk.call( self._w, 'tapply', *args )
-
- def tcompose( self, *args ):
- """
- zinc.tcompose(tagOrIdOrTName, tName)
- zinc.tcompose(tagOrIdOrTName, tName, invert)
- """
- return self.tk.call( self._w, 'tapply', *args )
-
- def tdelete( self, *args ):
- """
- zinc.tdelete(tName)
- Destroy a named transform.
- If the given name is not found among the named transforms,
- an error is raised.
- """
- self.tk.call( self._w, 'tdelete', *args )
-
- def transform( self, *args ):
- """
- listCoords=zinc.transform(tagOrIdTo, coordList)
- listCoords=zinc.transform(tagOrIdFrom, tagOrIdTo, coordList)
- This command returns a list of coordinates obtained by transforming the coordinates given in coordList
- from the coordinate space of the transform or item described by tagOrIdFrom to the coordinate space
- of the transform or item described by tagOrIdTo.
- If tagOrIdFrom is omitted it defaults to the window coordinate space.
- If either tagOrIdFrom or tagOrIdTo describes more than one item,
- the topmost in display list order is used. If either tagOrIdFrom or tagOrIdTo
- doesn't describe either a transform or an item, an error is raised.
- The coordList should either be a flat list containing an even number of coordinates
- each point having two coordinates, or a list of lists each sublist of the form [ X Y ?pointtype? ].
- The returned coordinates list will be isomorphic to the list given as argument.
-
- It is possible to convert from window coordinate space to the coordinate space of any item.
- This is done by omitting ?tagOrIdFrom? and specifying in tagOrIdTo, the id of the item.
- It can also be done by using the predefined tag 'device' as first argument.
-
- It is also possible to convert from the coordinate space of an item to the window coordinate
- space by using the predefined tag 'device' as second argument.
-
- """
- return self._getdoubles( self.tk.call( self._w, 'transform', *args ) )
+ scurrentp = self.tk.call( self._w, 'currentpart' )
+ print "Zinc::__oldcurrentpart scurrentp = [%s]" % scurrentp
+ # warning : read this first :
+ # return a string among 'position', 'speedvector', 'leader', 'connection' ,''
+ # or an int representing the number of a field label
+ #
+ # print "Zinc::currentpart cp=%s ,type(cp)=%s" % (scurrentp,type(scurrentp))
+ if scurrentp == "":
+ rvalue = ZINC_NO_PART
+ elif type( scurrentp ) == type( 1 ):
+ # meaning a field
+ # the subtil thing is here ! warning !
+ rvalue = scurrentp
+ scurrentp = "field"
+ else:
+ # scurrentp is a string different from ""
+ try:
+ rvalue = ZINC_DPART[scurrentp]
+ except:
+ print "Zinc::currentpart unknown item part"
+ rvalue = ZINC_NO_PART
+
+ return scurrentp, rvalue
+
+ def currentpart( self ):
+ '''
+ num = zinc.currentpart()
+ '''
+ return str( self.tk.call( self._w, 'currentpart' ) )
+
+
+ def cursor( self, *args ):
+ """
+ zinc.cursor(tagOrId, index)
+ """
+ self.tk.call( self._w, 'cursor', *args )
+
+ def dchars( self, *args ):
+ """
+ zinc.dchars( tagOrId, first )
+ zinc.dchars( tagOrId, first,last )
+ """
+ self.tk.call( self._w, 'dchars', *args )
+
+ def dtag( self, *args ):
+ """
+ zinc.dtag(tagOrId)
+ zinc.dtag(tagOrId, tagToDelete)
+ """
+ self.tk.call( self._w, 'dtag', *args )
+
+ def find( self, *args ):
+ return self._getints(
+ self.tk.call( self._w, 'find', *args ) ) or ()
+
+ def find_above( self, tagOrId ):
+ """
+ listItems=zinc.find_above(tagOrId)}
+ """
+ return self.find( 'above', tagOrId )
+
+ def find_all( self ):
+ return self.find( 'all' )
+
+ def find_ancestors( self, newtag, tagOrId, *tagOrId2 ):
+ """
+ listItems=zinc.find_ancestor(tag, tagOrId, ?tagOrId2?)
+ """
+ return self.find( newtag, 'ancestors', tagOrId, *tagOrId2 )
+
+ def find_atpriority( self, pri, *tagOrId ):
+ """
+ listItems=zinc.find_atpriority(pri, ?tagOrId?)
+ """
+ return self.find( 'atpriority', pri, *tagOrId )
+
+ def find_below( self, tagOrId ):
+ """
+ listItems=zinc.find_below(tagOrId)
+ """
+ return self.find( 'below', tagOrId )
+
+ def find_closest( self, x, y, *options ):
+ """
+ listItems=zinc.find_closest(x, y, ?halo?, ?startItem?, ?recursive?)
+ """
+ return self.find( 'closest', x, y, *options )
+
+ def find_enclosed( self, x1, y1, x2, y2 ):
+ """
+ listItems=zinc.find_enclosed(x1, y1, x2, y2, inGroup=1, recursive=0)
+ """
+ return self.find( 'enclosed', x1, y1, x2, y2 )
+
+ def find_overlapping( self, x1, y1, x2, y2, *options ):
+ """
+ listItems=zinc.find_overlapping( x1, y1, x2, y2, ?inGroup?, ?recursive?)
+ """
+ return self.find( 'overlapping', x1, y1, x2, y2, *options )
+
+ def find_withtag( self, tagOrId ):
+ """
+ listItems=zinc.find_withtag( tagOrId)
+ """
+ return self.find( 'withtag', tagOrId )
+
+ def find_withtype( self, type, *tagOrId ):
+ """
+ listItems=zinc.find_withtype( type, ?tagOrId?)
+ """
+ return self.find( 'withtype', type, *tagOrId )
+
+
+ def fit( self, *args ):
+ """
+ listControls=zinc.fit(coordList,error)
+ """
+ return self.tk.call( self._w, 'fit', *args )
+
+ def focus( self, *args ):
+ """
+ zinc.focus(tagOrId, ?itemPart?)
+ """
+ self.tk.call( self._w, 'focus', *args )
+
+ def gdelete( self, *args ):
+ """
+ zinc.gdelete(gradientName)
+ """
+ self.tk.call( self._w, 'gdelete', *args )
+
+ def gettags( self, *args ):
+ """
+ listTags=zinc.gettags(tagorid)
+ """
+ return self.tk.splitlist( self.tk.call( self._w, 'gettags', *args ) )
+
+ def gname( self, *args ):
+ """
+ zinc.gname(gradientDesc, gradientName)
+ bExist=zinc.gname(gradientName)
+ """
+ return self.tk.call( self._w, 'gname', *args )
+
+ def group( self, *args ):
+ """
+ group=zinc.group(tagOrId)
+ """
+ return self.tk.call( self._w, 'group', *args )
+
+ def hasanchors( self, *args ):
+ """
+ bool=zinc.hasanchors(tagOrId)
+ """
+ return self.tk.call( self._w, 'hasanchors', *args )
+
+ def hasfields( self, *args ):
+ """
+ bool=zinc.hasfields(tagOrId)
+ """
+ return self.tk.call( self._w, 'hasfield', *args )
+
+ def hastag( self, *args ):
+ """
+ bool=zinc.hastag(tagOrId, tag)
+ """
+ return self.tk.call( self._w, 'hastag', *args )
+
+ def index( self, *args ):
+ """
+ num = zinc.index(tagOrId, index)
+ """
+ return self.tk.call( self._w, 'tagOrId', *args )
+
+ def insert( self, *args ):
+ """
+ zinc.insert(tagOrId, before, string)
+ """
+ self.tk.call( self._w, 'insert', *args )
+
+ def itemcget( self, tagOrId, option ):
+ """
+ val=zinc.itemcget(tagOrId, attr)
+ """
+ return self.tk.call( self._w, 'itemcget', tagOrId, '-'+option )
+
+ def itemfieldget( self, tagOrId, field, option ):
+ """
+ val=zinc.itemcget(tagOrId, field, attr)
+ """
+ return self.tk.call( self._w, 'itemcget', tagOrId, field, '-'+option )
+
+ def itemconfigure( self, tagOrId, field=None, **kw ):
+ '''
+ either get the dictionnary of possible attributes (if kw is None)
+ either allow to set Items attributes or Field attributes
+
+ listAttribs=zinc.itemconfigure(tagOrId)
+ listAttribs=zinc.itemconfigure(tagOrId, attrib)
+ zinc.itemconfigure(tagOrId, **attributs)
+ listAttribs=zinc.itemconfigure(tagOrId, fieldIs, attrib)
+ zinc.itemconfigure(TagOrId,fieldId,**attributs)
+ '''
+ if not kw:
+ cnf = {}
+ for var_x in self.tk.split(
+ field != None and self.tk.call( self._w, 'itemconfigure',
+ ( tagOrId, field ) ) or
+ self.tk.call( self._w, 'itemconfigure', ( tagOrId, ) ) ):
+ cnf[var_x[0][1:]] = ( var_x[0][1:], ) + var_x[1:]
+ return cnf
+ if field != None:
+ args = ( tagOrId, str( field ), )+ self._options( {}, kw )
+ self.tk.call( self._w, 'itemconfigure', *args )
+ else:
+ args = ( tagOrId, ) + self._options( {}, kw )
+ self.tk.call( self._w, 'itemconfigure', *args )
+
+ # _dp voir si cette instruction est a execute ici
+ # permet de creer un synonyme de itemconfigure
+ itemconfig = itemconfigure
+
+ def loweritem( self, *args ):
+ """
+ zinc.loweritem(tagOrId)
+ zinc.loweritem(tagOrId, belowThis)
+ Reorder all the items given by tagOrId so that
+ they will be under the item given by belowThis.
+ If tagOrId name more than one item,
+ their relative order will be preserved.
+ If tagOrId doesn't name an item, an error is raised.
+ If belowThis name more than one item, the bottom most them is used.
+ If belowThis doesn't name an item, an error is raised.
+ If belowThis is omitted the items are put
+ at the bottom most position of their respective groups.
+ The command ignore all items named by tagOrId
+ that are not in the same group than belowThis or,
+ if not specified, in the same group than the first item
+ named by tagOrId. The command returns an empty string.
+ As a side affect of this command, the -priority attribute
+ of all the reordered items is ajusted to match the priority
+ of the belowThis item (or the priority of the bottom most item)
+ """
+ self.tk.call( self._w, 'lower', *args )
+
+ def monitor( self, *args ):
+ """
+ bool = zinc.monitor()
+ zinc.monitor(bool)
+ """
+ return self.tk.call( self._w, 'monitor', *args )
+
+ def numparts( self, *args ):
+ """
+ num = zinc.numparts(tagOrId)
+ """
+ return self.tk.call( self._w, 'numparts', *args )
+
+ def postcript( self, *args ):
+ """
+ Not Yet Implemented
+ zinc.postscript()
+ """
+ return self.tk.call( self._w, 'postscript', *args )
+
+ def raiseitem( self, *args ):
+ """
+ Correspond à l'appel raise de la documentation
+ le mot raise est reservé en python
+ zinc.raiseitem(tagOrId)
+ zinc.raiseitem(tagOrId, aboveThis)
+ """
+ self.tk.call( self._w, 'raise', *args )
+
+ def remove( self, *args ):
+ """
+ zinc.remove(tagOrId, ?tagOrId,...?)
+ """
+ self.tk.call( self._w, 'remove', *args )
+
+ def rotate( self, *args ):
+ """
+ zinc.rotate(tagOrId, angle)
+ zinc.rotate(tagOrId, angle, centerX, centerY)
+ """
+ self.tk.call( self._w, 'rotate', *args )
+
+ def __oldscale( self, xFactor=None, yFactor=None, tagOrId=None ):
+ if yFactor == None:
+ return self.tk.getdouble( self.tk.call( 'scale' ) )
+ else:
+ if tagOrId == None:
+ self.tk.call( self._w, 'scale', xFactor, yFactor )
+ else:
+ self.tk.call( self._w, 'scale', tagOrId, xFactor, yFactor )
+
+ def scale( self, *args ):
+ """
+ zinc.scale(tagOrIdOrTName, xFactor, yFactor)
+ zinc.scale(tagOrIdOrTName, xFactor, yFactor, centerX, centerY)
+ Add a scale factor to the items or the transform described
+ by tagOrId.
+ If tagOrId describes a named transform then this transform
+ is used to do the operation. If tagOrId describes more than
+ one item then all the items are affected by the operation.
+ If tagOrId describes neither a named transform nor an item,
+ an error is raised.
+ A separate factor is specified for X and Y.
+ The optional parameters describe the center of scaling,
+ which defaults to the origin.
+ """
+ if not len( args ):
+ return self.tk.getdouble( self.tk.call( self._w, 'scale' ) )
+ else:
+ self.tk.call( self._w, 'scale', *args )
+
+ def select( self, *args ):
+ """
+ zinc.select('adjust', tagOrId, index)
+ Adjust the end of the selection in tagOrId
+ that is nearest to the character given by index so
+ that it is at index.
+ The other end of the selection is made the anchor
+ for future select to commands.
+ If the selection is not currently in tagOrId,
+ this command behaves as the select to command.
+ The command returns an empty string.
+ zinc.select('clear')
+ Clear the selection if it is in the widget.
+ If the selection is not in the widget,
+ the command has no effect. Return an empty string.
+ zinc.select('from', tagOrId, index)
+ Set the selection anchor point for the widget
+ to be just before the character given by index
+ in the item described by tagOrId.
+ The command has no effect on the selection,
+ it sets one end of the selection so that future
+ select to can actually set the selection.
+ The command returns an empty string.
+ (item,part) = zinc.select('item')
+ Returns a list of two elements.
+ The first is the id of the selected item
+ if the selection is in an item on this widget;
+ Otherwise the first element is an empty string.
+ The second element is the part of the item
+ (track, waypoint or tabular item only) or the empty string.
+ zinc.select('to', tagOrId, index)
+ Set the selection to be the characters that lies
+ between the selection anchor and index in the item described
+ by tagOrId. The selection includes the character given
+ by index and includes the character given by the anchor point
+ if index is greater or equal to the anchor point.
+ The anchor point is set by the most recent select adjust
+ or select from command issued for this widget.
+ If the selection anchor point for the widget is not currently
+ in tagOrId, it is set to the character given by index.
+ The command returns an empty string.
+ Manipulates the selection as requested by option.
+ tagOrId describes the target item.
+ This item must support text indexing and selection. I
+ f more than one item is referred to by tagOrId,
+ the first in display list order that support both text
+ indexing and selection will be used.
+ Some forms of the command include an index parameter,
+ this parameter describes a textual position within the
+ item and should be a valid index as described in
+ Text indices.
+ """
+ return self.tk.call( self._w, 'select', *args )
+
+ def skew( self, *args ):
+ """
+ zinc.skew(tagOrIdOrTName,xSkewAngle, ySkewAngle)
+ Add a skew (or shear) transform to the to the items
+ or the transform described by tagOrIdOrTName.
+ If tagOrId describes a named transform then this transform
+ is used to do the operation.
+ If tagOrId describes more than one item then all the
+ items are affected by the operation.
+ If tagOrId describes neither a named transform nor an item,
+ an error is raised. The angles are given in radian.
+ """
+ return self.tk.call( self._w, 'skew', *args )
+
+ def smooth( self, *args ):
+ """
+ zinc.smooth(coordList)
+ This command computes a sequence of segments
+ that will smooth the polygon described by the vertices
+ in coordList and returns a list of lists describing points
+ of the generated segments. These segments are approximating
+ a Bezier curve. coordList should be either a flat list
+ of an even number of coordinates in x, y order, or a list
+ of lists of point coordinates X, Y.
+ The returned list can be used to create or change the contour
+ of a curve item.
+ """
+ return self.tk.call( self._w, 'smooth', *args )
+
+ def tapply( self, *args ):
+ """
+ Not Yet Implemented
+ zinc.tapply()
+ """
+ return self.tk.call( self._w, 'tapply', *args )
+
+ def tcompose( self, *args ):
+ """
+ zinc.tcompose(tagOrIdOrTName, tName)
+ zinc.tcompose(tagOrIdOrTName, tName, invert)
+ """
+ return self.tk.call( self._w, 'tapply', *args )
+
+ def tdelete( self, *args ):
+ """
+ zinc.tdelete(tName)
+ Destroy a named transform.
+ If the given name is not found among the named transforms,
+ an error is raised.
+ """
+ self.tk.call( self._w, 'tdelete', *args )
+
+ def transform( self, *args ):
+ """
+ listCoords=zinc.transform(tagOrIdTo, coordList)
+ listCoords=zinc.transform(tagOrIdFrom, tagOrIdTo, coordList)
+ This command returns a list of coordinates obtained by transforming the coordinates given in coordList
+ from the coordinate space of the transform or item described by tagOrIdFrom to the coordinate space
+ of the transform or item described by tagOrIdTo.
+ If tagOrIdFrom is omitted it defaults to the window coordinate space.
+ If either tagOrIdFrom or tagOrIdTo describes more than one item,
+ the topmost in display list order is used. If either tagOrIdFrom or tagOrIdTo
+ doesn't describe either a transform or an item, an error is raised.
+ The coordList should either be a flat list containing an even number of coordinates
+ each point having two coordinates, or a list of lists each sublist of the form [ X Y ?pointtype? ].
+ The returned coordinates list will be isomorphic to the list given as argument.
+
+ It is possible to convert from window coordinate space to the coordinate space of any item.
+ This is done by omitting ?tagOrIdFrom? and specifying in tagOrIdTo, the id of the item.
+ It can also be done by using the predefined tag 'device' as first argument.
+
+ It is also possible to convert from the coordinate space of an item to the window coordinate
+ space by using the predefined tag 'device' as second argument.
+
+ """
+ return self._getdoubles( self.tk.call( self._w, 'transform', *args ) )
#ANCIENNE IMPLEMENTATION
- def __oldtranslate( self, dx=None, dy=None, tagOrId=None ):
- if dx == None:
- return self._getints( self.tk.call( 'translate' ) )
- else:
- if tagOrId == None:
- self.tk.call( self._w, 'translate', dx, dy )
- else:
- self.tk.call( self._w, 'translate', tagOrId, dx, dy )
-
- def translate( self, *args ):
- """
- zinc.translate(tagOrIdOrTName, xAmount, yAmount)
- zinc.translate(tagOrIdOrTName, xAmount, yAmount, absolute)
- Add a translation to the items or the transform described by tagOrIdOrTName.
- If tagOrIdOrTName describes a named transform then this transform is used
- to do the operation.
- If tagOrIdOrTName describes more than one item then all the items are affected
- by the opration.
- If tagOrIdOrTName describes neither a named transform nor an item,
- an error is raised. A separate value is specified for X and Y.
- If the optionnal ?absolute? parameter is true,
- it will set an absolute translation to the tagOrIdOrTName
- """
- if ( len( args ) == 1 ):
- return self._getints( self.tk.call( self._w, 'translate' ) )
- else:
- self.tk.call( self._w, 'translate', *args )
-
- def treset( self, *args ):
- """
- zinc.treset(tagOrIdOrTName)
- Set the named transform or the transform for the items described by tagOrIdOrTName
- to identity. If tagOrIdOrTName describes neither a named transform nor an item,
- an error is raised.
- """
- self.tk.call( self._w, 'treset', *args )
-
- def trestore( self, *args ):
- """
- zinc.trestore(tagOrId, tName)
- Set the transform for the items described by tagOrId to the transform named by tName.
- If tagOrId doesn't describe any item or if the transform named tName doesn't exist,
- an error is raised.
- """
- self.tk.call( self._w, 'trestore', *args )
-
- def tsave( self, *args ):
- """
- zinc.tsave(tName)
- zinc.tsave(tagOrIdOrTName, tName)
- zinc.tsave(tagOrIdOrTName, tName, invert)
- Create (or reset) a transform associated with the name tName
- with initial value the transform associated with the item tagOrIdOrTName.
- If tagOrIdOrTName describes more than one item, the topmost in display list order is used.
- If tagOrIdOrTName doesn't describe any item or named transformation, an error is raised.
- If tName already exists, the transform is set to the new value.
- This command is the only way to create a named transform.
- If tagOrIdOrTName is not specified, the command returns a boolean telling
- if the name is already in use.
- The invert boolean, if specified, cause the transform to be inverted prior to be saved.
-
- It is possible to create a new named transformation from the identity
- by using the predefined tag 'identity': $zinc->tsave('identity', 'myTransfo');
- """
- return self.tk.call( self._w, 'tsave', *args )
-
- def tget( self, *args ):
- """
- zinc.tget(tagOrId)
- zinc.tget(tagOrIdOrTName, selector)
- selector:={'all'|'translation'|'scale'|'rotation'|'skew'}
- With only one argument, get the six elements of the 3x4 matrix
- used in affine transformation for tagOrIdOrTName.
- The result is compatible with the tset method.
- With optional second parameter 'all' returns the transform
- decomposed in translation, scale, rotation, skew
- and return the list in this order,
- With 'translation', 'scale', 'rotation', 'skew' optional
- second parameter, returns the corresponding values.
- """
- return self.tk.call( self._w, 'tget', *args )
-
- def tset( self, *args ):
- """
- zinc.tset(tagOrIdOrName, m00, m01, m10, m11, m20, m21)
- Set the six elements of the 3x4 matrix used in affine transformation for tagOrIdOrTName.
- BEWARE that depending on mij values,
- it is possible to define a not inversible matrix which will end up in core dump.
- This method must BE USED CAUTIOUSLY.
- """
- return self.tk.call( self._w, 'tset', *args )
-
- def type( self, tagOrId ):
- """
- name=zinc.type(tagOrId)
- If more than one item is named by tagOrId,
- then the type of the topmost item in display list order is returned.
- If no items are named by tagOrId, an error is raised.
- """
- return self.tk.call( self._w, 'type', tagOrId )
-
- def vertexat( self, *args ):
- """
- (contour,vertex,edgevertex)=zinc.vertexat(tagOrId,x,y)
- """
- return self.tk.call( self._w, 'vertexat', *args )
+ def __oldtranslate( self, dx=None, dy=None, tagOrId=None ):
+ if dx == None:
+ return self._getints( self.tk.call( 'translate' ) )
+ else:
+ if tagOrId == None:
+ self.tk.call( self._w, 'translate', dx, dy )
+ else:
+ self.tk.call( self._w, 'translate', tagOrId, dx, dy )
+
+ def translate( self, *args ):
+ """
+ zinc.translate(tagOrIdOrTName, xAmount, yAmount)
+ zinc.translate(tagOrIdOrTName, xAmount, yAmount, absolute)
+ Add a translation to the items or the transform described by tagOrIdOrTName.
+ If tagOrIdOrTName describes a named transform then this transform is used
+ to do the operation.
+ If tagOrIdOrTName describes more than one item then all the items are affected
+ by the opration.
+ If tagOrIdOrTName describes neither a named transform nor an item,
+ an error is raised. A separate value is specified for X and Y.
+ If the optionnal ?absolute? parameter is true,
+ it will set an absolute translation to the tagOrIdOrTName
+ """
+ if ( len( args ) == 1 ):
+ return self._getints( self.tk.call( self._w, 'translate' ) )
+ else:
+ self.tk.call( self._w, 'translate', *args )
+
+ def treset( self, *args ):
+ """
+ zinc.treset(tagOrIdOrTName)
+ Set the named transform or the transform for the items described by tagOrIdOrTName
+ to identity. If tagOrIdOrTName describes neither a named transform nor an item,
+ an error is raised.
+ """
+ self.tk.call( self._w, 'treset', *args )
+
+ def trestore( self, *args ):
+ """
+ zinc.trestore(tagOrId, tName)
+ Set the transform for the items described by tagOrId to the transform named by tName.
+ If tagOrId doesn't describe any item or if the transform named tName doesn't exist,
+ an error is raised.
+ """
+ self.tk.call( self._w, 'trestore', *args )
+
+ def tsave( self, *args ):
+ """
+ zinc.tsave(tName)
+ zinc.tsave(tagOrIdOrTName, tName)
+ zinc.tsave(tagOrIdOrTName, tName, invert)
+ Create (or reset) a transform associated with the name tName
+ with initial value the transform associated with the item tagOrIdOrTName.
+ If tagOrIdOrTName describes more than one item, the topmost in display list order is used.
+ If tagOrIdOrTName doesn't describe any item or named transformation, an error is raised.
+ If tName already exists, the transform is set to the new value.
+ This command is the only way to create a named transform.
+ If tagOrIdOrTName is not specified, the command returns a boolean telling
+ if the name is already in use.
+ The invert boolean, if specified, cause the transform to be inverted prior to be saved.
+
+ It is possible to create a new named transformation from the identity
+ by using the predefined tag 'identity': $zinc->tsave('identity', 'myTransfo');
+ """
+ return self.tk.call( self._w, 'tsave', *args )
+
+ def tget( self, *args ):
+ """
+ zinc.tget(tagOrId)
+ zinc.tget(tagOrIdOrTName, selector)
+ selector:={'all'|'translation'|'scale'|'rotation'|'skew'}
+ With only one argument, get the six elements of the 3x4 matrix
+ used in affine transformation for tagOrIdOrTName.
+ The result is compatible with the tset method.
+ With optional second parameter 'all' returns the transform
+ decomposed in translation, scale, rotation, skew
+ and return the list in this order,
+ With 'translation', 'scale', 'rotation', 'skew' optional
+ second parameter, returns the corresponding values.
+ """
+ return self.tk.call( self._w, 'tget', *args )
+
+ def tset( self, *args ):
+ """
+ zinc.tset(tagOrIdOrName, m00, m01, m10, m11, m20, m21)
+ Set the six elements of the 3x4 matrix used in affine transformation for tagOrIdOrTName.
+ BEWARE that depending on mij values,
+ it is possible to define a not inversible matrix which will end up in core dump.
+ This method must BE USED CAUTIOUSLY.
+ """
+ return self.tk.call( self._w, 'tset', *args )
+
+ def type( self, tagOrId ):
+ """
+ name=zinc.type(tagOrId)
+ If more than one item is named by tagOrId,
+ then the type of the topmost item in display list order is returned.
+ If no items are named by tagOrId, an error is raised.
+ """
+ return self.tk.call( self._w, 'type', tagOrId )
+
+ def vertexat( self, *args ):
+ """
+ (contour,vertex,edgevertex)=zinc.vertexat(tagOrId,x,y)
+ """
+ return self.tk.call( self._w, 'vertexat', *args )
+
+ def xview(self, *args):
+ """Query and change horizontal position of the view."""
+ if not args:
+ return self._getdoubles(self.tk.call(self._w, 'xview'))
+ self.tk.call((self._w, 'xview') + args)
+ def xview_moveto(self, fraction):
+ """Adjusts the view in the window so that FRACTION of the
+ total width of the canvas is off-screen to the left."""
+ self.tk.call(self._w, 'xview', 'moveto', fraction)
+ def xview_scroll(self, number, what):
+ """Shift the x-view according to NUMBER which is measured in "units" or "pages" (WHAT)."""
+ self.tk.call(self._w, 'xview', 'scroll', number, what)
+ def yview(self, *args):
+ """Query and change vertical position of the view."""
+ if not args:
+ return self._getdoubles(self.tk.call(self._w, 'yview'))
+ self.tk.call((self._w, 'yview') + args)
+ def yview_moveto(self, fraction):
+ """Adjusts the view in the window so that FRACTION of the
+ total height of the canvas is off-screen to the top."""
+ self.tk.call(self._w, 'yview', 'moveto', fraction)
+ def yview_scroll(self, number, what):
+ """Shift the y-view according to NUMBER which is measured in "units" or "pages" (WHAT)."""
+ self.tk.call(self._w, 'yview', 'scroll', number, what)
class ZincItem:
- def __init__( self, zinc, itemType, group = 1, *args, **kw ):
- self.zinc = zinc
- texture = None
- fillpatern = None
- scale = None
- translate = None
- if kw.has_key( 'texture' ):
- texture = kw['texture']
- del kw['texture']
-
- if kw.has_key( 'fillpatern' ):
- fillpastern = kw['fillpatern']
- del kw['fillpatern']
-
- if kw.has_key( 'scale' ):
- scale = kw['scale']
- del kw['scale']
-
- if kw.has_key( 'rotate' ):
- rotate = kw['rotate']
- del kw['rotate']
-
- if kw.has_key( 'translate' ):
- 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()
- 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:
- self.itemconfigure( fillpatern )
- if scale:
- self.scale( scale )
- if translate:
- self.translate( translate )
-
-
- def __str__( self ):
- return str( self.id )
-
- def __repr__( self ):
- return str( self.id )
-
- def bbox( self, *args ):
- return self.zinc.bbox( self.id, *args )
-
- def clone( self, *args, **kw):
- '''id = zincitem.clone(*args,**kw) '''
- # print "ZincItem::clone"
+ def __init__( self, zinc, itemType, group = 1, *args, **kw ):
+ self.zinc = zinc
+ texture = None
+ fillpatern = None
+ scale = None
+ translate = None
+ if kw.has_key( 'texture' ):
+ texture = kw['texture']
+ del kw['texture']
+
+ if kw.has_key( 'fillpatern' ):
+ fillpastern = kw['fillpatern']
+ del kw['fillpatern']
+
+ if kw.has_key( 'scale' ):
+ scale = kw['scale']
+ del kw['scale']
+
+ if kw.has_key( 'rotate' ):
+ rotate = kw['rotate']
+ del kw['rotate']
+
+ if kw.has_key( 'translate' ):
+ 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()
+ 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:
+ self.itemconfigure( fillpatern )
+ if scale:
+ self.scale( scale )
+ if translate:
+ self.translate( translate )
+
+
+ def __str__( self ):
+ return str( self.id )
+
+ def __repr__( self ):
+ return str( self.id )
+
+ 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)
+ # nidcloned = self.find_above(tagOrId)
+ sclonedtype = self.type()
+ sclonedgroupid = self.zinc.group(self.id)
- # ajout cle 'cloneid' (voir ZincItem::__init__)
- kw['cloneid'] = 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:
- self.zinc.remove( self.id )
- except:
- pass
- def __getitem__( self, key ):
- '''allow to get attribute by self["key"] '''
- if ( key == "coords" ):
- return self.zinc.coords( self.id )
- return self.zinc.itemcget( self.id, key )
-
- def __setitem__( self, key, value ):
- '''allow to set item attrbutes, eg. for a track position attributes
- just writing :
- a = ZincItem(myzinc, ...)
- a["position"] = (x,y)
- Notes : when setting multiple attributes
- using itemconfigure is more efficient '''
- if ( key is "coords" ):
- self.zinc.coords( self.id, value )
- else:
- self.zinc.itemconfigure( self.id, **{key:value} )
-
- def getGroup( self ):
- groupid = self.zinc.group( self.id )
- return self.zinc.items[groupid]
-
- def keys( self ):
- if not hasattr( self, '_keys' ):
- self._keys = {}
- config = self.zinc.itemconfig( self.id )
- for x in config.keys():
- self._keys[x] = config[x][1]
- return self._keys
-
- def has_key( self, key ):
- return key in self.keys()
-
- def bind( self, sequence=None, command=None, add=None ):
- '''return a funcid which can be used to unbind
+ return(ZincItem(self.zinc, sclonedtype, sclonedgroupid, **kw ))
+
+ def delete( self ):
+ del self.zinc.items[self.id]
+ try:
+ self.zinc.remove( self.id )
+ except:
+ pass
+ def __getitem__( self, key ):
+ '''allow to get attribute by self["key"] '''
+ if ( key == "coords" ):
+ return self.zinc.coords( self.id )
+ return self.zinc.itemcget( self.id, key )
+
+ def __setitem__( self, key, value ):
+ '''allow to set item attrbutes, eg. for a track position attributes
+ just writing :
+ a = ZincItem(myzinc, ...)
+ a["position"] = (x,y)
+ Notes : when setting multiple attributes
+ using itemconfigure is more efficient '''
+ if ( key is "coords" ):
+ self.zinc.coords( self.id, value )
+ else:
+ self.zinc.itemconfigure( self.id, **{key:value} )
+
+ def getGroup( self ):
+ groupid = self.zinc.group( self.id )
+ return self.zinc.items[groupid]
+
+ def keys( self ):
+ if not hasattr( self, '_keys' ):
+ self._keys = {}
+ config = self.zinc.itemconfig( self.id )
+ for x in config.keys():
+ self._keys[x] = config[x][1]
+ return self._keys
+
+ def has_key( self, key ):
+ return key in self.keys()
+
+ def bind( self, sequence=None, command=None, add=None ):
+ '''return a funcid which can be used to unbind
notes: unbinding can be done by bind("<seq>","") or using native tkinter
unbind method '''
- return( self.zinc.bind_tag( self.id, sequence, command, add ) )
-
- def cget( self, attr ):
- return self.zinc.itemcget( self.id, attr )
-
- def coords( self, *args, **kw ):
- return self.zinc.coords( self.id, *args, **kw )
-
- def fieldcget( self, field, attr ):
- return self.zinc.itemfieldcget( self.id, field, attr )
-
- def itemconfigure( self, field=None, **kw ):
- self.zinc.itemconfigure( self.id, field, **kw )
-
- def rotate( self, *args ):
- return self.zinc.rotate( self.id, *args )
-
- def scale( self, *args ):
- return self.zinc.scale( self.id, *args )
-
- def transforms( self, *args ):
- """
- zincitem.transform(tozincitem, coordList)
- This command returns a list of coordinates obtained by transforming the coordinates given in coordList
- from the coordinate space of item to the coordinate space
- of the tozincitem item.
- The coordList should either be a flat list containing an even number of coordinates
- each point having two coordinates, or a list of lists each sublist of the form [ X Y ?pointtype? ].
- The returned coordinates list will be isomorphic to the list given as argument.
- """
- return self.zinc.transforms( self.id, *args )
-
- def translate( self, *args ):
- """
- zincitem.translate( xAmount, yAmount)
- zincitem.translate( xAmount, yAmount, absolute)
- Add a translation to the item.
- A separate value is specified for X and Y.
- If the optionnal ?absolute? parameter is true,
- it will set an absolute translation to the item
- """
- self.zinc.translate( self.id, *args )
-
- def tset( self, *args ):
- """
- zincitemtset(m00, m01, m10, m11, m20, m21)
- Set the six elements of the 3x4 matrix used in affine transformation.
- BEWARE that depending on mij values,
- it is possible to define a not inversible matrix which will end up in core dump.
- This method must BE USED CAUTIOUSLY.
- """
- self.zinc.tset( self.id, *args )
-
- def type( self ):
- """
- name=zincitemtype()
- This command returns the type of the item.
- """
- return self.zinc.type( self.id )
-
- def tsave( self, *args ):
- """
- zincitemtsave( tName)
- zincitemtsave( tName, invert)
- Create a transform associated with the name tName
- with initial value the transform associated with the item.
- If tName already exists, the transform is set to the new value.
- This command is the only way to create a named transform.
- The invert boolean, if specified, cause the transform to be inverted prior to be saved.
- """
- return self.zinc.tsave( self.id, *args )
-
- def treset( self, *args ):
- """
- zincitemtreset()
- Set the named transform or the transform for the item
- to identity. If there are no named transform,
- an error is raised.
- """
- self.zinc.treset( self.id, *args )
-
- def trestore( self, *args ):
- """
- zincitemtrestore( tName)
- Set the transform for the item to the transform named by tName.
- If the transform named tName doesn't exist, an error is raised.
- """
- self.zinc.trestore( self.id, *args )
-
- def tget( self, *args ):
- """
- zincitemtget()
- zincitemtget(selector)
- selector:={'all'|'translation'|'scale'|'rotation'|'skew'}
- With only one argument, get the six elements of the 3x4 matrix
- used in affine transformation.
- The result is compatible with the tset method.
- With optional second parameter 'all' returns the transform
- decomposed in translation, scale, rotation, skew
- and return the list in this order,
- With 'translation', 'scale', 'rotation', 'skew' optional
- second parameter, returns the corresponding values.
- """
- return self.zinc.tget( self.id, *args )
+ return( self.zinc.bind_tag( self.id, sequence, command, add ) )
+
+ def cget( self, attr ):
+ return self.zinc.itemcget( self.id, attr )
+
+ def coords( self, *args, **kw ):
+ return self.zinc.coords( self.id, *args, **kw )
+
+ def fieldcget( self, field, attr ):
+ return self.zinc.itemfieldcget( self.id, field, attr )
+
+ def itemconfigure( self, field=None, **kw ):
+ self.zinc.itemconfigure( self.id, field, **kw )
+
+ def rotate( self, *args ):
+ return self.zinc.rotate( self.id, *args )
+
+ def scale( self, *args ):
+ return self.zinc.scale( self.id, *args )
+
+ def transforms( self, *args ):
+ """
+ zincitem.transform(tozincitem, coordList)
+ This command returns a list of coordinates obtained by transforming the coordinates given in coordList
+ from the coordinate space of item to the coordinate space
+ of the tozincitem item.
+ The coordList should either be a flat list containing an even number of coordinates
+ each point having two coordinates, or a list of lists each sublist of the form [ X Y ?pointtype? ].
+ The returned coordinates list will be isomorphic to the list given as argument.
+ """
+ return self.zinc.transforms( self.id, *args )
+
+ def translate( self, *args ):
+ """
+ zincitem.translate( xAmount, yAmount)
+ zincitem.translate( xAmount, yAmount, absolute)
+ Add a translation to the item.
+ A separate value is specified for X and Y.
+ If the optionnal ?absolute? parameter is true,
+ it will set an absolute translation to the item
+ """
+ self.zinc.translate( self.id, *args )
+
+ def tset( self, *args ):
+ """
+ zincitemtset(m00, m01, m10, m11, m20, m21)
+ Set the six elements of the 3x4 matrix used in affine transformation.
+ BEWARE that depending on mij values,
+ it is possible to define a not inversible matrix which will end up in core dump.
+ This method must BE USED CAUTIOUSLY.
+ """
+ self.zinc.tset( self.id, *args )
+
+ def type( self ):
+ """
+ name=zincitemtype()
+ This command returns the type of the item.
+ """
+ return self.zinc.type( self.id )
+
+ def tsave( self, *args ):
+ """
+ zincitemtsave( tName)
+ zincitemtsave( tName, invert)
+ Create a transform associated with the name tName
+ with initial value the transform associated with the item.
+ If tName already exists, the transform is set to the new value.
+ This command is the only way to create a named transform.
+ The invert boolean, if specified, cause the transform to be inverted prior to be saved.
+ """
+ return self.zinc.tsave( self.id, *args )
+
+ def treset( self, *args ):
+ """
+ zincitemtreset()
+ Set the named transform or the transform for the item
+ to identity. If there are no named transform,
+ an error is raised.
+ """
+ self.zinc.treset( self.id, *args )
+
+ def trestore( self, *args ):
+ """
+ zincitemtrestore( tName)
+ Set the transform for the item to the transform named by tName.
+ If the transform named tName doesn't exist, an error is raised.
+ """
+ self.zinc.trestore( self.id, *args )
+
+ def tget( self, *args ):
+ """
+ zincitemtget()
+ zincitemtget(selector)
+ selector:={'all'|'translation'|'scale'|'rotation'|'skew'}
+ With only one argument, get the six elements of the 3x4 matrix
+ used in affine transformation.
+ The result is compatible with the tset method.
+ With optional second parameter 'all' returns the transform
+ decomposed in translation, scale, rotation, skew
+ and return the list in this order,
+ With 'translation', 'scale', 'rotation', 'skew' optional
+ second parameter, returns the corresponding values.
+ """
+ return self.zinc.tget( self.id, *args )
class Arc( ZincItem ):
@@ -1119,7 +1144,7 @@ class Group( ZincItem ):
else:
return ZincItem.getGroup( self )
- #TODO: Extension. Renvoie les références aux ZincItems contenus dans le Groupe
+ #TODO: Extension. Renvoie les références aux ZincItems contenus dans le Groupe
def getNode( self ):
"""
"""
@@ -1138,7 +1163,7 @@ class Map( ZincItem ):
These type do not expect type specific arguments.
"""
ZincItem.__init__( self, zinc, 'map', *args, **kw )
-
+
class Curve( ZincItem ):
def __init__( self, zinc, *args, **kw ):
"""
@@ -1173,7 +1198,7 @@ class Curve( ZincItem ):
ZincItem.__init__( self, zinc, 'curve', *args, **kw )
for contour in contours:
self.zinc.contour( self.id, *contour )
-
+
class Rectangle( ZincItem ):
def __init__( self, zinc, *args, **kw ):
@@ -1204,11 +1229,11 @@ class Text( ZincItem ):
class Track( ZincItem ):
def __init__( self, zinc, *args, **kw ):
ZincItem.__init__( self, zinc, 'track', *args, **kw )
-
+
class WayPoint( ZincItem ):
- def __init__( self, zinc, *args, **kw ):
- ZincItem.__init__( self, zinc, 'waypoint', *args, **kw )
-
+ def __init__( self, zinc, *args, **kw ):
+ ZincItem.__init__( self, zinc, 'waypoint', *args, **kw )
+
# Class to hold mapinfos used by the Map Item class
class Mapinfo:
@@ -1225,7 +1250,7 @@ class Mapinfo:
self.name = `id( self )`
self.interp = interp.tk
apply( self.interp.call, ( 'mapinfo', self.name, 'create' ) )
-
+
def __repr__( self ):
return self.name
@@ -1255,7 +1280,7 @@ class Mapinfo:
new_name = str( obj )
self.interp.call( 'mapinfo', self.name, 'duplicate', new_name )
return obj
-
+
def add_text( self, text_style, line_style, x, y, text ):
"""
Add a new graphical element to the mapinfo object text.
@@ -1270,7 +1295,7 @@ class Mapinfo:
@param Y: Coord on Y axe
@type text: string
@param : a string describing the text.
-
+
"""
self.interp.call( 'mapinfo', self.name, 'add', 'text', text_style,
line_style, x, y, text )
@@ -1332,16 +1357,16 @@ class Mapinfo:
"""
self.interp.call( 'mapinfo', self.name, 'add', 'symbol', x, y, index )
-
+
def count( self, type ):
"""
@type type: {text|arc|line|symbol}
@param type:
Return an integer value that is the number of elements matching type in the mapinfo.
- type may be one the legal element types
+ type may be one the legal element types
"""
return self.interp.call( 'mapinfo', self.name, 'count', type )
-
+
def get( self, type, index ):
"""
Return the parameters of the element at index with type type in the mapinfo.
@@ -1360,7 +1385,7 @@ class Mapinfo:
Indices are zero based and elements are listed by type.
"""
return self.interp.call( 'mapinfo', self.name, 'replace',
- type, index, args )
+ type, index, args )
def remove( self, type, index ):
"""
@@ -1378,7 +1403,7 @@ class Mapinfo:
"""
"""
self.interp.call( 'mapinfo', self.name, 'translate', xAmount, yAmount )
-
+
class Videomap ( Mapinfo ):
"""
create a mapinfo from a proprietary
@@ -1410,29 +1435,29 @@ class Videomap ( Mapinfo ):
return self.tk.call( 'videomap', 'ids', filename )
class Colors:
- """
- Classe abstraite utilitaire permettant de gérer sous forme d'objet
- les couleurs aux formats Zinc
- """
- def __init__( self ):
- self.lColors = []
-
- #TODO:
- def getColorsIter( self ):
- """
- Renvoie un itérateur sur les couleurs
- """
- return self.lColors.__iter__()
-
- def addColor( self, color, alpha = 100,
- colorposition = 0, mid_span_position = 50 ):
- self.lColors.append( ( color, alpha, colorposition, mid_span_position ) )
-
- def __repr__( self ):
- res = ""
- for i in self.lColors:
- res = "%s%s;%s %s %s|" % ( res, i[0], i[1], i[2], i[3] )
- return res[:-1]
+ """
+ Classe abstraite utilitaire permettant de gérer sous forme d'objet
+ les couleurs aux formats Zinc
+ """
+ def __init__( self ):
+ self.lColors = []
+
+ #TODO:
+ def getColorsIter( self ):
+ """
+ Renvoie un itérateur sur les couleurs
+ """
+ return self.lColors.__iter__()
+
+ def addColor( self, color, alpha = 100,
+ colorposition = 0, mid_span_position = 50 ):
+ self.lColors.append( ( color, alpha, colorposition, mid_span_position ) )
+
+ def __repr__( self ):
+ res = ""
+ for i in self.lColors:
+ res = "%s%s;%s %s %s|" % ( res, i[0], i[1], i[2], i[3] )
+ return res[:-1]
class AxialGradientColor( Colors ):
def __init__( self, *params ):
@@ -1484,8 +1509,8 @@ class RadialGradientColor( Colors ):
class PathGradientColor( Colors ):
def __init__( self, *params ):
"""
- =path x y | gradient_step1 | ... | gradient_stepn
- The x y parameters define the center of the gradient.
+ =path x y | gradient_step1 | ... | gradient_stepn
+ The x y parameters define the center of the gradient.
"""
Colors.__init__( self )
count = 0
@@ -1493,8 +1518,8 @@ class PathGradientColor( Colors ):
for i in params:
self.params = "%s %s" % ( self.params, str( i ) )
count += 1
- if ( count != 2 ):
- raise Exception( "Bad Format of params %s" % count )
+ if ( count != 2 ):
+ raise Exception( "Bad Format of params %s" % count )
def __repr__( self ):
res = "=path %s " % self.params
@@ -1541,32 +1566,32 @@ class ConicalGradientColor( Colors ):
# ---- self-test ----------------------------------------------------------
if __name__ == '__main__':
- from Tkinter import *
- import Zinc
- def createItem( zinc, group, ev ):
- print >> sys.stdout, "CreateIHM"
- sys.stdout.flush()
- Zinc.Rectangle( zinc, group,
- ( 100, 100, 150, 150 ),
- linewidth = "10", linecolor = '#FFFF00',
- relief = "roundgroove", filled = 1,
- fillcolor = "red", tags = ( "hello", "test" ) )
- sys.stdout.write( "hello_clic" + str( ev ) )
-
- z = Zinc.Zinc( master = None, render = 1, height = 200, width = 400 )
- g1 = Zinc.Group( z, 1 )
- r = Zinc.Rectangle( z, g1, ( 0, 0, 400, 200 ),
- linewidth = "10",
- linecolor = '#FFFF00',
- relief = "roundgroove",
- filled = 1,
- fillcolor = "#FFFFFF",
- tags = ( "hello", "test" ) )
- t = Zinc.Text( z, g1, position = ( 40, 100 ), text = z.version )
-# z.bind_tag("hello","<1>",lambda ev,z=z,g=g1 : createItem(z,g,ev))
- z.configure( backcolor = 'black' )
- z.pack()
- z.mainloop()
+ from Tkinter import *
+ import Zinc
+ def createItem( zinc, group, ev ):
+ print >> sys.stdout, "CreateIHM"
+ sys.stdout.flush()
+ Zinc.Rectangle( zinc, group,
+ ( 100, 100, 150, 150 ),
+ linewidth = "10", linecolor = '#FFFF00',
+ relief = "roundgroove", filled = 1,
+ fillcolor = "red", tags = ( "hello", "test" ) )
+ sys.stdout.write( "hello_clic" + str( ev ) )
+
+ z = Zinc.Zinc( master = None, render = 1, height = 200, width = 400 )
+ g1 = Zinc.Group( z, 1 )
+ r = Zinc.Rectangle( z, g1, ( 0, 0, 400, 200 ),
+ linewidth = "10",
+ linecolor = '#FFFF00',
+ relief = "roundgroove",
+ filled = 1,
+ fillcolor = "#FFFFFF",
+ tags = ( "hello", "test" ) )
+ t = Zinc.Text( z, g1, position = ( 40, 100 ), text = z.version )
+# z.bind_tag("hello","<1>",lambda ev,z=z,g=g1 : createItem(z,g,ev))
+ z.configure( backcolor = 'black' )
+ z.pack()
+ z.mainloop()
# Zinc.py ends here