diff options
author | Barry Warsaw <barry@python.org> | 1998-02-18 16:22:22 (GMT) |
---|---|---|
committer | Barry Warsaw <barry@python.org> | 1998-02-18 16:22:22 (GMT) |
commit | 4c2fab51ed0d77a9035026dbb4c1221252921d52 (patch) | |
tree | 9223d88442543195b28e5838128c84cce1756aa9 /Tools/pynche | |
parent | aeca79b0f6b1bc7e9e3b415254b353a5288eefbb (diff) | |
download | cpython-4c2fab51ed0d77a9035026dbb4c1221252921d52.zip cpython-4c2fab51ed0d77a9035026dbb4c1221252921d52.tar.gz cpython-4c2fab51ed0d77a9035026dbb4c1221252921d52.tar.bz2 |
Implementation using TCLPROC loaded into the Tcl interpreter
Diffstat (limited to 'Tools/pynche')
-rw-r--r-- | Tools/pynche/StripViewer.py | 42 |
1 files changed, 32 insertions, 10 deletions
diff --git a/Tools/pynche/StripViewer.py b/Tools/pynche/StripViewer.py index 2b5691f..a7c2b3a 100644 --- a/Tools/pynche/StripViewer.py +++ b/Tools/pynche/StripViewer.py @@ -3,6 +3,20 @@ from Tkinter import * import Pmw import ColorDB +# Load this script into the Tcl interpreter and call it in +# StripWidget.set_color(). This is about as fast as it can be with the +# current _tkinter.c interface, which doesn't support Tcl Objects. +TCLPROC = '''\ +proc setcolor {canv colors} { + set i 1 + foreach c $colors { + $canv itemconfigure $i -fill $c -outline $c + incr i + } +} +''' + + class LeftArrow: _ARROWWIDTH = 30 @@ -113,6 +127,10 @@ class StripWidget(Pmw.MegaWidget): self.__canvas.bind('<B1-Motion>', self.__select_chip) + # Load a proc into the Tcl interpreter. This is used in the + # set_color() method to speed up setting the chip colors. + self.__canvas.tk.eval(TCLPROC) + # create the color strip chips = self.__chips = [] x = 1 @@ -187,27 +205,31 @@ class StripWidget(Pmw.MegaWidget): chip = 0 chips = self.__chips = [] tclcmd = [] + tk = self.__canvas.tk for t in self.__generator(self.__numchips, rgbtuple): rrggbb = ColorDB.triplet_to_rrggbb(t) chips.append(rrggbb) ## self.__canvas.itemconfigure(i, ## fill=rrggbb, ## outline=rrggbb) - tclcmd.append(self.__canvas._w) - tclcmd.append('itemconfigure') - tclcmd.append(`i`) - tclcmd.append('-fill') - tclcmd.append(rrggbb) - tclcmd.append('-outline') - tclcmd.append(rrggbb) - tclcmd.append('\n') +## tclcmd.append(self.__canvas._w) +## tclcmd.append('itemconfigure') +## tclcmd.append(`i`) +## tclcmd.append('-fill') +## tclcmd.append(rrggbb) +## tclcmd.append('-outline') +## tclcmd.append(rrggbb) +## tclcmd.append('\n') tred, tgreen, tblue = t if tred <= red and tgreen <= green and tblue <= blue: chip = i i = i + 1 # call the raw tcl script - script = string.join(tclcmd, ' ') - self.__canvas.tk.eval(script) +## script = string.join(tclcmd, ' ') +## self.__canvas.tk.eval(script) +## colors = tk.merge(chips) + colors = string.join(chips) + tk.eval('setcolor %s {%s}' % (self.__canvas._w, colors)) # get the arrow's text coloraxis = rgbtuple[self.__axis] |