Changes for Canvas by Fred
This commit is contained in:
parent
ad8997887b
commit
5c8c91bbc5
|
@ -1,17 +1,7 @@
|
|||
# This module exports classes for the various canvas item types
|
||||
|
||||
from Tkinter import Canvas
|
||||
from Tkinter import Canvas, _flatten
|
||||
|
||||
from types import *
|
||||
|
||||
def _flatten(tuple):
|
||||
res = ()
|
||||
for item in tuple:
|
||||
if type(item) in (TupleType, ListType):
|
||||
res = res + _flatten(item)
|
||||
elif item is not None:
|
||||
res = res + (item,)
|
||||
return res
|
||||
|
||||
class CanvasItem:
|
||||
def __init__(self, canvas, itemType, *args, **kw):
|
||||
|
@ -85,41 +75,41 @@ class CanvasItem:
|
|||
return self.canvas.type(self.id)
|
||||
|
||||
class Arc(CanvasItem):
|
||||
def __init__(self, canvas, *args):
|
||||
CanvasItem.__init__(self, canvas, 'arc', args)
|
||||
def __init__(self, canvas, *args, **kw):
|
||||
apply(CanvasItem.__init__, (self, canvas, 'arc') + args, kw)
|
||||
|
||||
class Bitmap(CanvasItem):
|
||||
def __init__(self, canvas, *args):
|
||||
CanvasItem.__init__(self, canvas, 'bitmap', args)
|
||||
def __init__(self, canvas, *args, **kw):
|
||||
apply(CanvasItem.__init__, (self, canvas, 'bitmap') + args, kw)
|
||||
|
||||
class ImageItem(CanvasItem):
|
||||
def __init__(self, canvas, *args):
|
||||
CanvasItem.__init__(self, canvas, 'image', args)
|
||||
def __init__(self, canvas, *args, **kw):
|
||||
apply(CanvasItem.__init__, (self, canvas, 'image') + args, kw)
|
||||
|
||||
class Line(CanvasItem):
|
||||
def __init__(self, canvas, *args):
|
||||
CanvasItem.__init__(self, canvas, 'line', args)
|
||||
def __init__(self, canvas, *args, **kw):
|
||||
apply(CanvasItem.__init__, (self, canvas, 'line') + args, kw)
|
||||
|
||||
class Oval(CanvasItem):
|
||||
def __init__(self, canvas, *args):
|
||||
CanvasItem.__init__(self, canvas, 'oval', args)
|
||||
def __init__(self, canvas, *args, **kw):
|
||||
apply(CanvasItem.__init__, (self, canvas, 'oval') + args, kw)
|
||||
|
||||
class Polygon(CanvasItem):
|
||||
def __init__(self, canvas, *args):
|
||||
CanvasItem.__init__(self, canvas, 'polygon', args)
|
||||
def __init__(self, canvas, *args, **kw):
|
||||
apply(CanvasItem.__init__, (self, canvas, 'polygon') + args, kw)
|
||||
|
||||
class Rectangle(CanvasItem):
|
||||
def __init__(self, canvas, *args):
|
||||
CanvasItem.__init__(self, canvas, 'rectangle', args)
|
||||
def __init__(self, canvas, *args, **kw):
|
||||
apply(CanvasItem.__init__, (self, canvas, 'rectangle') + args, kw)
|
||||
|
||||
# XXX "Text" is taken by the Text widget...
|
||||
class CanvasText(CanvasItem):
|
||||
def __init__(self, canvas, *args):
|
||||
CanvasItem.__init__(self, canvas, 'text', args)
|
||||
def __init__(self, canvas, *args, **kw):
|
||||
apply(CanvasItem.__init__, (self, canvas, 'text') + args, kw)
|
||||
|
||||
class Window(CanvasItem):
|
||||
def __init__(self, canvas, *args):
|
||||
CanvasItem.__init__(self, canvas, 'window', args)
|
||||
def __init__(self, canvas, *args, **kw):
|
||||
apply(CanvasItem.__init__, (self, canvas, 'window') + args, kw)
|
||||
|
||||
class Group:
|
||||
def __init__(self, canvas, tag=None):
|
||||
|
|
|
@ -935,20 +935,20 @@ class Canvas(Widget):
|
|||
Widget.__init__(self, master, 'canvas', cnf, kw)
|
||||
def addtag(self, *args):
|
||||
self._do('addtag', args)
|
||||
def addtag_above(self, tagOrId):
|
||||
self.addtag('above', tagOrId)
|
||||
def addtag_all(self):
|
||||
self.addtag('all')
|
||||
def addtag_below(self, tagOrId):
|
||||
self.addtag('below', tagOrId)
|
||||
def addtag_closest(self, x, y, halo=None, start=None):
|
||||
self.addtag('closest', x, y, halo, start)
|
||||
def addtag_enclosed(self, x1, y1, x2, y2):
|
||||
self.addtag('enclosed', x1, y1, x2, y2)
|
||||
def addtag_overlapping(self, x1, y1, x2, y2):
|
||||
self.addtag('overlapping', x1, y1, x2, y2)
|
||||
def addtag_withtag(self, tagOrId):
|
||||
self.addtag('withtag', tagOrId)
|
||||
def addtag_above(self, newtag, tagOrId):
|
||||
self.addtag(newtag, 'above', tagOrId)
|
||||
def addtag_all(self, newtag):
|
||||
self.addtag(newtag, 'all')
|
||||
def addtag_below(self, newtag, tagOrId):
|
||||
self.addtag(newtag, 'below', tagOrId)
|
||||
def addtag_closest(self, newtag, x, y, halo=None, start=None):
|
||||
self.addtag(newtag, 'closest', x, y, halo, start)
|
||||
def addtag_enclosed(self, newtag, x1, y1, x2, y2):
|
||||
self.addtag(newtag, 'enclosed', x1, y1, x2, y2)
|
||||
def addtag_overlapping(self, newtag, x1, y1, x2, y2):
|
||||
self.addtag(newtag, 'overlapping', x1, y1, x2, y2)
|
||||
def addtag_withtag(self, newtag, tagOrId):
|
||||
self.addtag(newtag, 'withtag', tagOrId)
|
||||
def bbox(self, *args):
|
||||
return self._getints(self._do('bbox', args)) or None
|
||||
def tag_unbind(self, tagOrId, sequence):
|
||||
|
|
|
@ -1,17 +1,7 @@
|
|||
# This module exports classes for the various canvas item types
|
||||
|
||||
from Tkinter import Canvas
|
||||
from Tkinter import Canvas, _flatten
|
||||
|
||||
from types import *
|
||||
|
||||
def _flatten(tuple):
|
||||
res = ()
|
||||
for item in tuple:
|
||||
if type(item) in (TupleType, ListType):
|
||||
res = res + _flatten(item)
|
||||
elif item is not None:
|
||||
res = res + (item,)
|
||||
return res
|
||||
|
||||
class CanvasItem:
|
||||
def __init__(self, canvas, itemType, *args, **kw):
|
||||
|
@ -85,41 +75,41 @@ class CanvasItem:
|
|||
return self.canvas.type(self.id)
|
||||
|
||||
class Arc(CanvasItem):
|
||||
def __init__(self, canvas, *args):
|
||||
CanvasItem.__init__(self, canvas, 'arc', args)
|
||||
def __init__(self, canvas, *args, **kw):
|
||||
apply(CanvasItem.__init__, (self, canvas, 'arc') + args, kw)
|
||||
|
||||
class Bitmap(CanvasItem):
|
||||
def __init__(self, canvas, *args):
|
||||
CanvasItem.__init__(self, canvas, 'bitmap', args)
|
||||
def __init__(self, canvas, *args, **kw):
|
||||
apply(CanvasItem.__init__, (self, canvas, 'bitmap') + args, kw)
|
||||
|
||||
class ImageItem(CanvasItem):
|
||||
def __init__(self, canvas, *args):
|
||||
CanvasItem.__init__(self, canvas, 'image', args)
|
||||
def __init__(self, canvas, *args, **kw):
|
||||
apply(CanvasItem.__init__, (self, canvas, 'image') + args, kw)
|
||||
|
||||
class Line(CanvasItem):
|
||||
def __init__(self, canvas, *args):
|
||||
CanvasItem.__init__(self, canvas, 'line', args)
|
||||
def __init__(self, canvas, *args, **kw):
|
||||
apply(CanvasItem.__init__, (self, canvas, 'line') + args, kw)
|
||||
|
||||
class Oval(CanvasItem):
|
||||
def __init__(self, canvas, *args):
|
||||
CanvasItem.__init__(self, canvas, 'oval', args)
|
||||
def __init__(self, canvas, *args, **kw):
|
||||
apply(CanvasItem.__init__, (self, canvas, 'oval') + args, kw)
|
||||
|
||||
class Polygon(CanvasItem):
|
||||
def __init__(self, canvas, *args):
|
||||
CanvasItem.__init__(self, canvas, 'polygon', args)
|
||||
def __init__(self, canvas, *args, **kw):
|
||||
apply(CanvasItem.__init__, (self, canvas, 'polygon') + args, kw)
|
||||
|
||||
class Rectangle(CanvasItem):
|
||||
def __init__(self, canvas, *args):
|
||||
CanvasItem.__init__(self, canvas, 'rectangle', args)
|
||||
def __init__(self, canvas, *args, **kw):
|
||||
apply(CanvasItem.__init__, (self, canvas, 'rectangle') + args, kw)
|
||||
|
||||
# XXX "Text" is taken by the Text widget...
|
||||
class CanvasText(CanvasItem):
|
||||
def __init__(self, canvas, *args):
|
||||
CanvasItem.__init__(self, canvas, 'text', args)
|
||||
def __init__(self, canvas, *args, **kw):
|
||||
apply(CanvasItem.__init__, (self, canvas, 'text') + args, kw)
|
||||
|
||||
class Window(CanvasItem):
|
||||
def __init__(self, canvas, *args):
|
||||
CanvasItem.__init__(self, canvas, 'window', args)
|
||||
def __init__(self, canvas, *args, **kw):
|
||||
apply(CanvasItem.__init__, (self, canvas, 'window') + args, kw)
|
||||
|
||||
class Group:
|
||||
def __init__(self, canvas, tag=None):
|
||||
|
|
|
@ -935,20 +935,20 @@ class Canvas(Widget):
|
|||
Widget.__init__(self, master, 'canvas', cnf, kw)
|
||||
def addtag(self, *args):
|
||||
self._do('addtag', args)
|
||||
def addtag_above(self, tagOrId):
|
||||
self.addtag('above', tagOrId)
|
||||
def addtag_all(self):
|
||||
self.addtag('all')
|
||||
def addtag_below(self, tagOrId):
|
||||
self.addtag('below', tagOrId)
|
||||
def addtag_closest(self, x, y, halo=None, start=None):
|
||||
self.addtag('closest', x, y, halo, start)
|
||||
def addtag_enclosed(self, x1, y1, x2, y2):
|
||||
self.addtag('enclosed', x1, y1, x2, y2)
|
||||
def addtag_overlapping(self, x1, y1, x2, y2):
|
||||
self.addtag('overlapping', x1, y1, x2, y2)
|
||||
def addtag_withtag(self, tagOrId):
|
||||
self.addtag('withtag', tagOrId)
|
||||
def addtag_above(self, newtag, tagOrId):
|
||||
self.addtag(newtag, 'above', tagOrId)
|
||||
def addtag_all(self, newtag):
|
||||
self.addtag(newtag, 'all')
|
||||
def addtag_below(self, newtag, tagOrId):
|
||||
self.addtag(newtag, 'below', tagOrId)
|
||||
def addtag_closest(self, newtag, x, y, halo=None, start=None):
|
||||
self.addtag(newtag, 'closest', x, y, halo, start)
|
||||
def addtag_enclosed(self, newtag, x1, y1, x2, y2):
|
||||
self.addtag(newtag, 'enclosed', x1, y1, x2, y2)
|
||||
def addtag_overlapping(self, newtag, x1, y1, x2, y2):
|
||||
self.addtag(newtag, 'overlapping', x1, y1, x2, y2)
|
||||
def addtag_withtag(self, newtag, tagOrId):
|
||||
self.addtag(newtag, 'withtag', tagOrId)
|
||||
def bbox(self, *args):
|
||||
return self._getints(self._do('bbox', args)) or None
|
||||
def tag_unbind(self, tagOrId, sequence):
|
||||
|
|
Loading…
Reference in New Issue