Tkinter.Canvas.create_line.coords

Arnd Baecker baecker at physik.tu-dresden.de
Sun Jun 1 16:35:48 EDT 2003


_Many_ thanks for the solution and the explanation!
Using  self.plot.coords(self.line, *liste) does the job.

I'll have to meditate a bit about the explanation,
and what the difference between
   Tkinter.Canvas.coords(self, *args)
and
   Tkinter.Canvas.create_line(self, *args, **kw)
is (the latter one works with `list`...).

Using the source maybe points at the origin of the difference
(see the end of this mail, as this is really getting  too technical
for me;-) - a comment in coords says: "# XXX Should use _flatten on args"
...


> [...]
>
> If the above works, we can go on to the next problem, which someone else
> will have to get into if it's going to happen tonight ;-)

Well, on this side of the world the night just starts ;-)
Anyway, there are no further problems left (for the moment).

Best regards,

Arnd



In [10]: Tkinter.Canvas.coords??
Type:           instance method
Base Class:     <type 'instance method'>
String Form:    <unbound method Canvas.coords>
Namespace:      Interactive
File:
/home/abaecker/morepub/PYTHON/lib/python2.2/lib-tk/Tkinter.py
Definition:     Tkinter.Canvas.coords(self, *args)
Source:
def coords(self, *args):
        """Return a list of coordinates for the item given in ARGS."""
        # XXX Should use _flatten on args
        return map(getdouble,
                           self.tk.splitlist(
                   self.tk.call((self._w, 'coords') + args)))


In [11]: Tkinter.Canvas.create_line??
Type:           instance method
Base Class:     <type 'instance method'>
String Form:    <unbound method Canvas.create_line>
Namespace:      Interactive
File:
/home/abaecker/morepub/PYTHON/lib/python2.2/lib-tk/Tkinter.py
Definition:     Tkinter.Canvas.create_line(self, *args, **kw)
Source:
def create_line(self, *args, **kw):
        """Create line with coordinates x1,y1,...,xn,yn."""
        return self._create('line', args, kw)


In [12]: Tkinter.Canvas._create??
Type:           instance method
Base Class:     <type 'instance method'>
String Form:    <unbound method Canvas._create>
Namespace:      Interactive
File:
/home/abaecker/morepub/PYTHON/lib/python2.2/lib-tk/Tkinter.py
Definition:     Tkinter.Canvas._create(self, itemType, args, kw)
Source:
def _create(self, itemType, args, kw): # Args: (val, val, ..., cnf={})
        """Internal function."""
        args = _flatten(args)
        cnf = args[-1]
        if type(cnf) in (DictionaryType, TupleType):
            args = args[:-1]
        else:
            cnf = {}
        return getint(apply(
            self.tk.call,
            (self._w, 'create', itemType)
            + args + self._options(cnf, kw)))







More information about the Python-list mailing list