Kaydet (Commit) 5c1d1ee8 authored tarafından Guido van Rossum's avatar Guido van Rossum

Change to allow keyword args for Group,

 suggested by Nils Fischbeck, adapted by Fred
üst 8130054c
# This module exports classes for the various canvas item types # This module exports classes for the various canvas item types
from Tkinter import Canvas, _flatten from Tkinter import Canvas, _cnfmerge, _flatten
class CanvasItem: class CanvasItem:
...@@ -42,8 +42,8 @@ class CanvasItem: ...@@ -42,8 +42,8 @@ class CanvasItem:
return (x1, y1), (x2, y2) return (x1, y1), (x2, y2)
def bind(self, sequence=None, command=None): def bind(self, sequence=None, command=None):
return self.canvas.tag_bind(self.id, sequence, command) return self.canvas.tag_bind(self.id, sequence, command)
def config(self, cnf=None): def config(self, cnf={}, **kw):
return self.canvas.itemconfig(self.id, cnf) return self.canvas.itemconfig(self.id, _cnfmerge((cnf, kw)))
def coords(self, pts = ()): def coords(self, pts = ()):
flat = () flat = ()
for x, y in pts: flat = flat + (x, y) for x, y in pts: flat = flat + (x, y)
...@@ -120,6 +120,7 @@ class Group: ...@@ -120,6 +120,7 @@ class Group:
self.canvas.dtag(self.tag) self.canvas.dtag(self.tag)
def str(self): def str(self):
return self.tag return self.tag
__str__ = str
def _do(self, cmd, *args): def _do(self, cmd, *args):
return self.canvas._do(cmd, (self.tag,) + _flatten(args)) return self.canvas._do(cmd, (self.tag,) + _flatten(args))
def addtag_above(self, tagOrId): def addtag_above(self, tagOrId):
...@@ -158,8 +159,8 @@ class Group: ...@@ -158,8 +159,8 @@ class Group:
return self.canvas.tk.getint(self._do('index', index)) return self.canvas.tk.getint(self._do('index', index))
def insert(self, beforeThis, string): def insert(self, beforeThis, string):
self._do('insert', beforeThis, string) self._do('insert', beforeThis, string)
def config(self, cnf=None): def config(self, cnf={}, **kw):
return self.canvas.itemconfigure(self.tag, cnf) return self.canvas.itemconfigure(self.tag, _cnfmerge((cnf,kw)))
def lower(self, belowThis=None): def lower(self, belowThis=None):
self._do('lower', belowThis) self._do('lower', belowThis)
def move(self, xAmount, yAmount): def move(self, xAmount, yAmount):
......
# This module exports classes for the various canvas item types # This module exports classes for the various canvas item types
from Tkinter import Canvas, _flatten from Tkinter import Canvas, _cnfmerge, _flatten
class CanvasItem: class CanvasItem:
...@@ -42,8 +42,8 @@ class CanvasItem: ...@@ -42,8 +42,8 @@ class CanvasItem:
return (x1, y1), (x2, y2) return (x1, y1), (x2, y2)
def bind(self, sequence=None, command=None): def bind(self, sequence=None, command=None):
return self.canvas.tag_bind(self.id, sequence, command) return self.canvas.tag_bind(self.id, sequence, command)
def config(self, cnf=None): def config(self, cnf={}, **kw):
return self.canvas.itemconfig(self.id, cnf) return self.canvas.itemconfig(self.id, _cnfmerge((cnf, kw)))
def coords(self, pts = ()): def coords(self, pts = ()):
flat = () flat = ()
for x, y in pts: flat = flat + (x, y) for x, y in pts: flat = flat + (x, y)
...@@ -120,6 +120,7 @@ class Group: ...@@ -120,6 +120,7 @@ class Group:
self.canvas.dtag(self.tag) self.canvas.dtag(self.tag)
def str(self): def str(self):
return self.tag return self.tag
__str__ = str
def _do(self, cmd, *args): def _do(self, cmd, *args):
return self.canvas._do(cmd, (self.tag,) + _flatten(args)) return self.canvas._do(cmd, (self.tag,) + _flatten(args))
def addtag_above(self, tagOrId): def addtag_above(self, tagOrId):
...@@ -158,8 +159,8 @@ class Group: ...@@ -158,8 +159,8 @@ class Group:
return self.canvas.tk.getint(self._do('index', index)) return self.canvas.tk.getint(self._do('index', index))
def insert(self, beforeThis, string): def insert(self, beforeThis, string):
self._do('insert', beforeThis, string) self._do('insert', beforeThis, string)
def config(self, cnf=None): def config(self, cnf={}, **kw):
return self.canvas.itemconfigure(self.tag, cnf) return self.canvas.itemconfigure(self.tag, _cnfmerge((cnf,kw)))
def lower(self, belowThis=None): def lower(self, belowThis=None):
self._do('lower', belowThis) self._do('lower', belowThis)
def move(self, xAmount, yAmount): def move(self, xAmount, yAmount):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment