mirror of
https://github.com/python/cpython.git
synced 2025-08-02 16:13:13 +00:00
Reformatted using 8-space wide tabs
This commit is contained in:
parent
67ef5f3fb6
commit
fea128ecf3
2 changed files with 36 additions and 34 deletions
|
@ -1,7 +1,5 @@
|
||||||
# This module exports classes for the various canvas item types
|
# This module exports classes for the various canvas item types
|
||||||
|
|
||||||
# vi:set tabsize=4:
|
|
||||||
|
|
||||||
from Tkinter import Canvas, _isfunctype
|
from Tkinter import Canvas, _isfunctype
|
||||||
|
|
||||||
class CanvasItem:
|
class CanvasItem:
|
||||||
|
@ -16,19 +14,20 @@ class CanvasItem:
|
||||||
self.canvas.delete(self.id)
|
self.canvas.delete(self.id)
|
||||||
delete = __del__
|
delete = __del__
|
||||||
def __getitem__(self, key):
|
def __getitem__(self, key):
|
||||||
v = self.canvas.tk.split(self.canvas.tk.call(self.canvas.pathName,
|
v = self.canvas.tk.split(self.canvas.tk.call(
|
||||||
'itemconfigure',
|
self.canvas._w, 'itemconfigure',
|
||||||
str(self.id),
|
str(self.id), '-' + key))
|
||||||
'-' + key))
|
|
||||||
return v[4]
|
return v[4]
|
||||||
def __setitem__(self, key, value):
|
def __setitem__(self, key, value):
|
||||||
self.canvas._itemconfig(self.id, {key: value})
|
self.canvas._itemconfig(self.id, {key: value})
|
||||||
def keys(self):
|
def keys(self):
|
||||||
if not hasattr(self, '_keys'):
|
if not hasattr(self, '_keys'):
|
||||||
self._keys = map(lambda x, tk=self.canvas.tk:
|
self._keys = map(lambda x, tk=self.canvas.tk:
|
||||||
tk.splitlist(x)[0][1:],
|
tk.splitlist(x)[0][1:],
|
||||||
self.canvas._splitlist(
|
self.canvas._splitlist(
|
||||||
self.canvas.cmd('itemconfigure', self.id)))
|
self.canvas.cmd(
|
||||||
|
'itemconfigure',
|
||||||
|
self.id)))
|
||||||
return self._keys
|
return self._keys
|
||||||
def has_key(self, key):
|
def has_key(self, key):
|
||||||
return key in self.keys()
|
return key in self.keys()
|
||||||
|
@ -71,27 +70,28 @@ class CanvasItem:
|
||||||
class Arc(CanvasItem):
|
class Arc(CanvasItem):
|
||||||
def __init__(self, canvas, (x1, y1), (x2, y2), cnf={}):
|
def __init__(self, canvas, (x1, y1), (x2, y2), cnf={}):
|
||||||
CanvasItem.__init__(self, canvas, 'arc',
|
CanvasItem.__init__(self, canvas, 'arc',
|
||||||
(str(x1), str(y1), str(x2), str(y2)), cnf)
|
(str(x1), str(y1), str(x2), str(y2)), cnf)
|
||||||
|
|
||||||
class Bitmap(CanvasItem):
|
class Bitmap(CanvasItem):
|
||||||
def __init__(self, canvas, (x1, y1), cnf={}):
|
def __init__(self, canvas, (x1, y1), cnf={}):
|
||||||
CanvasItem.__init__(self, canvas, 'bitmap', (str(x1), str(y1)), cnf)
|
CanvasItem.__init__(self, canvas, 'bitmap',
|
||||||
|
(str(x1), str(y1)), cnf)
|
||||||
|
|
||||||
class Line(CanvasItem):
|
class Line(CanvasItem):
|
||||||
def __init__(self, canvas, pts, cnf={}):
|
def __init__(self, canvas, pts, cnf={}):
|
||||||
pts = reduce(lambda a, b: a+b,
|
pts = reduce(lambda a, b: a+b,
|
||||||
map(lambda pt: (str(pt[0]), str(pt[1])), pts))
|
map(lambda pt: (str(pt[0]), str(pt[1])), pts))
|
||||||
CanvasItem.__init__(self, canvas, 'line', pts, cnf)
|
CanvasItem.__init__(self, canvas, 'line', pts, cnf)
|
||||||
|
|
||||||
class Oval(CanvasItem):
|
class Oval(CanvasItem):
|
||||||
def __init__(self, canvas, (x1, y1), (x2, y2), cnf={}):
|
def __init__(self, canvas, (x1, y1), (x2, y2), cnf={}):
|
||||||
CanvasItem.__init__(self, canvas, 'oval',
|
CanvasItem.__init__(self, canvas, 'oval',
|
||||||
(str(x1), str(y1), str(x2), str(y2)), cnf)
|
(str(x1), str(y1), str(x2), str(y2)), cnf)
|
||||||
|
|
||||||
class Polygon(CanvasItem):
|
class Polygon(CanvasItem):
|
||||||
def __init__(self, canvas, pts, cnf={}):
|
def __init__(self, canvas, pts, cnf={}):
|
||||||
pts = reduce(lambda a, b: a+b,
|
pts = reduce(lambda a, b: a+b,
|
||||||
map(lambda pt: (str(pt[0]), str(pt[1])), pts))
|
map(lambda pt: (str(pt[0]), str(pt[1])), pts))
|
||||||
CanvasItem.__init__(self, canvas, 'polygon', pts, cnf)
|
CanvasItem.__init__(self, canvas, 'polygon', pts, cnf)
|
||||||
|
|
||||||
class Curve(Polygon):
|
class Curve(Polygon):
|
||||||
|
@ -102,14 +102,15 @@ class Curve(Polygon):
|
||||||
class Rectangle(CanvasItem):
|
class Rectangle(CanvasItem):
|
||||||
def __init__(self, canvas, (x1, y1), (x2, y2), cnf={}):
|
def __init__(self, canvas, (x1, y1), (x2, y2), cnf={}):
|
||||||
CanvasItem.__init__(self, canvas, 'rectangle',
|
CanvasItem.__init__(self, canvas, 'rectangle',
|
||||||
(str(x1), str(y1), str(x2), str(y2)), cnf)
|
(str(x1), str(y1), str(x2), str(y2)), cnf)
|
||||||
|
|
||||||
# XXX Can't use name "Text" since that is already taken by the Text widget...
|
# XXX Can't use name "Text" since that is already taken by the Text widget...
|
||||||
class String(CanvasItem):
|
class String(CanvasItem):
|
||||||
def __init__(self, canvas, (x1, y1), cnf={}):
|
def __init__(self, canvas, (x1, y1), cnf={}):
|
||||||
CanvasItem.__init__(self, canvas, 'text', (str(x1), str(y1)), cnf)
|
CanvasItem.__init__(self, canvas, 'text',
|
||||||
|
(str(x1), str(y1)), cnf)
|
||||||
|
|
||||||
class Window(CanvasItem):
|
class Window(CanvasItem):
|
||||||
def __init__(self, canvas, where, cnf={}):
|
def __init__(self, canvas, where, cnf={}):
|
||||||
CanvasItem.__init__(self, canvas, 'window',
|
CanvasItem.__init__(self, canvas, 'window',
|
||||||
(str(where[0]), str(where[1])), cnf)
|
(str(where[0]), str(where[1])), cnf)
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
# This module exports classes for the various canvas item types
|
# This module exports classes for the various canvas item types
|
||||||
|
|
||||||
# vi:set tabsize=4:
|
|
||||||
|
|
||||||
from Tkinter import Canvas, _isfunctype
|
from Tkinter import Canvas, _isfunctype
|
||||||
|
|
||||||
class CanvasItem:
|
class CanvasItem:
|
||||||
|
@ -16,19 +14,20 @@ class CanvasItem:
|
||||||
self.canvas.delete(self.id)
|
self.canvas.delete(self.id)
|
||||||
delete = __del__
|
delete = __del__
|
||||||
def __getitem__(self, key):
|
def __getitem__(self, key):
|
||||||
v = self.canvas.tk.split(self.canvas.tk.call(self.canvas.pathName,
|
v = self.canvas.tk.split(self.canvas.tk.call(
|
||||||
'itemconfigure',
|
self.canvas._w, 'itemconfigure',
|
||||||
str(self.id),
|
str(self.id), '-' + key))
|
||||||
'-' + key))
|
|
||||||
return v[4]
|
return v[4]
|
||||||
def __setitem__(self, key, value):
|
def __setitem__(self, key, value):
|
||||||
self.canvas._itemconfig(self.id, {key: value})
|
self.canvas._itemconfig(self.id, {key: value})
|
||||||
def keys(self):
|
def keys(self):
|
||||||
if not hasattr(self, '_keys'):
|
if not hasattr(self, '_keys'):
|
||||||
self._keys = map(lambda x, tk=self.canvas.tk:
|
self._keys = map(lambda x, tk=self.canvas.tk:
|
||||||
tk.splitlist(x)[0][1:],
|
tk.splitlist(x)[0][1:],
|
||||||
self.canvas._splitlist(
|
self.canvas._splitlist(
|
||||||
self.canvas.cmd('itemconfigure', self.id)))
|
self.canvas.cmd(
|
||||||
|
'itemconfigure',
|
||||||
|
self.id)))
|
||||||
return self._keys
|
return self._keys
|
||||||
def has_key(self, key):
|
def has_key(self, key):
|
||||||
return key in self.keys()
|
return key in self.keys()
|
||||||
|
@ -71,27 +70,28 @@ class CanvasItem:
|
||||||
class Arc(CanvasItem):
|
class Arc(CanvasItem):
|
||||||
def __init__(self, canvas, (x1, y1), (x2, y2), cnf={}):
|
def __init__(self, canvas, (x1, y1), (x2, y2), cnf={}):
|
||||||
CanvasItem.__init__(self, canvas, 'arc',
|
CanvasItem.__init__(self, canvas, 'arc',
|
||||||
(str(x1), str(y1), str(x2), str(y2)), cnf)
|
(str(x1), str(y1), str(x2), str(y2)), cnf)
|
||||||
|
|
||||||
class Bitmap(CanvasItem):
|
class Bitmap(CanvasItem):
|
||||||
def __init__(self, canvas, (x1, y1), cnf={}):
|
def __init__(self, canvas, (x1, y1), cnf={}):
|
||||||
CanvasItem.__init__(self, canvas, 'bitmap', (str(x1), str(y1)), cnf)
|
CanvasItem.__init__(self, canvas, 'bitmap',
|
||||||
|
(str(x1), str(y1)), cnf)
|
||||||
|
|
||||||
class Line(CanvasItem):
|
class Line(CanvasItem):
|
||||||
def __init__(self, canvas, pts, cnf={}):
|
def __init__(self, canvas, pts, cnf={}):
|
||||||
pts = reduce(lambda a, b: a+b,
|
pts = reduce(lambda a, b: a+b,
|
||||||
map(lambda pt: (str(pt[0]), str(pt[1])), pts))
|
map(lambda pt: (str(pt[0]), str(pt[1])), pts))
|
||||||
CanvasItem.__init__(self, canvas, 'line', pts, cnf)
|
CanvasItem.__init__(self, canvas, 'line', pts, cnf)
|
||||||
|
|
||||||
class Oval(CanvasItem):
|
class Oval(CanvasItem):
|
||||||
def __init__(self, canvas, (x1, y1), (x2, y2), cnf={}):
|
def __init__(self, canvas, (x1, y1), (x2, y2), cnf={}):
|
||||||
CanvasItem.__init__(self, canvas, 'oval',
|
CanvasItem.__init__(self, canvas, 'oval',
|
||||||
(str(x1), str(y1), str(x2), str(y2)), cnf)
|
(str(x1), str(y1), str(x2), str(y2)), cnf)
|
||||||
|
|
||||||
class Polygon(CanvasItem):
|
class Polygon(CanvasItem):
|
||||||
def __init__(self, canvas, pts, cnf={}):
|
def __init__(self, canvas, pts, cnf={}):
|
||||||
pts = reduce(lambda a, b: a+b,
|
pts = reduce(lambda a, b: a+b,
|
||||||
map(lambda pt: (str(pt[0]), str(pt[1])), pts))
|
map(lambda pt: (str(pt[0]), str(pt[1])), pts))
|
||||||
CanvasItem.__init__(self, canvas, 'polygon', pts, cnf)
|
CanvasItem.__init__(self, canvas, 'polygon', pts, cnf)
|
||||||
|
|
||||||
class Curve(Polygon):
|
class Curve(Polygon):
|
||||||
|
@ -102,14 +102,15 @@ class Curve(Polygon):
|
||||||
class Rectangle(CanvasItem):
|
class Rectangle(CanvasItem):
|
||||||
def __init__(self, canvas, (x1, y1), (x2, y2), cnf={}):
|
def __init__(self, canvas, (x1, y1), (x2, y2), cnf={}):
|
||||||
CanvasItem.__init__(self, canvas, 'rectangle',
|
CanvasItem.__init__(self, canvas, 'rectangle',
|
||||||
(str(x1), str(y1), str(x2), str(y2)), cnf)
|
(str(x1), str(y1), str(x2), str(y2)), cnf)
|
||||||
|
|
||||||
# XXX Can't use name "Text" since that is already taken by the Text widget...
|
# XXX Can't use name "Text" since that is already taken by the Text widget...
|
||||||
class String(CanvasItem):
|
class String(CanvasItem):
|
||||||
def __init__(self, canvas, (x1, y1), cnf={}):
|
def __init__(self, canvas, (x1, y1), cnf={}):
|
||||||
CanvasItem.__init__(self, canvas, 'text', (str(x1), str(y1)), cnf)
|
CanvasItem.__init__(self, canvas, 'text',
|
||||||
|
(str(x1), str(y1)), cnf)
|
||||||
|
|
||||||
class Window(CanvasItem):
|
class Window(CanvasItem):
|
||||||
def __init__(self, canvas, where, cnf={}):
|
def __init__(self, canvas, where, cnf={}):
|
||||||
CanvasItem.__init__(self, canvas, 'window',
|
CanvasItem.__init__(self, canvas, 'window',
|
||||||
(str(where[0]), str(where[1])), cnf)
|
(str(where[0]), str(where[1])), cnf)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue