summaryrefslogtreecommitdiffstats
path: root/Tools
diff options
context:
space:
mode:
authorBarry Warsaw <barry@python.org>1998-02-12 19:52:31 (GMT)
committerBarry Warsaw <barry@python.org>1998-02-12 19:52:31 (GMT)
commit29fe4ddd206750c827b4cd9fa598e95b4ff7bb07 (patch)
tree553069715e73d022a41328d5f3727ec2dfa04af6 /Tools
parent9d882bc4de6c8f1e857f352787cfab95ff223b15 (diff)
downloadcpython-29fe4ddd206750c827b4cd9fa598e95b4ff7bb07.zip
cpython-29fe4ddd206750c827b4cd9fa598e95b4ff7bb07.tar.gz
cpython-29fe4ddd206750c827b4cd9fa598e95b4ff7bb07.tar.bz2
Added color strip widgets
Diffstat (limited to 'Tools')
-rw-r--r--Tools/pynche/PyncheWidget.py48
1 files changed, 45 insertions, 3 deletions
diff --git a/Tools/pynche/PyncheWidget.py b/Tools/pynche/PyncheWidget.py
index 855c6f7..106dd1f 100644
--- a/Tools/pynche/PyncheWidget.py
+++ b/Tools/pynche/PyncheWidget.py
@@ -6,7 +6,36 @@ import Pmw
import ColorDB
from ChipWidget import ChipWidget
from TypeinWidget import TypeinWidget
+from StripWidget import StripWidget
+
+def constant(numchips):
+ step = 255.0 / (numchips - 1)
+ start = 0.0
+ seq = []
+ while numchips > 0:
+ seq.append(int(start))
+ start = start + step
+ numchips = numchips - 1
+ return seq
+
+def constant_red_generator(numchips, rgbtuple):
+ red = rgbtuple[0]
+ seq = constant(numchips)
+ return map(None, [red] * numchips, seq, seq)
+
+def constant_green_generator(numchips, rgbtuple):
+ green = rgbtuple[1]
+ seq = constant(numchips)
+ return map(None, seq, [green] * numchips, seq)
+
+def constant_blue_generator(numchips, rgbtuple):
+ blue = rgbtuple[2]
+ seq = constant(numchips)
+ return map(None, seq, seq, [blue] * numchips)
+
+
+
class PyncheWidget(Pmw.MegaWidget):
def __init__(self, colordb, parent=None, **kw):
self.__colordb = colordb
@@ -21,8 +50,17 @@ class PyncheWidget(Pmw.MegaWidget):
interiorarg = (self.interior(),)
# create color selectors
- self.__selectors = Pmw.Group(parent, tag_text='Color Selectors')
- self.__selectors.pack(side=TOP, expand=YES, fill=BOTH)
+ group = Pmw.Group(parent, tag_text='Color Selectors')
+ group.pack(side=TOP, expand=YES, fill=BOTH)
+ self.__reds = StripWidget(group.interior(),
+ generator=constant_red_generator)
+ self.__reds.pack()
+ self.__blues = StripWidget(group.interior(),
+ generator=constant_blue_generator)
+ self.__blues.pack()
+ self.__greens = StripWidget(group.interior(),
+ generator=constant_green_generator)
+ self.__greens.pack()
# create chip window
group = Pmw.Group(parent, tag_text='Current Color')
@@ -51,7 +89,6 @@ class PyncheWidget(Pmw.MegaWidget):
def set_color(self, obj, rgbtuple):
- print 'setting color to:', rgbtuple
nearest = self.__colordb.nearest(rgbtuple)
red, green, blue = self.__colordb.find_byname(nearest)
# for an exact match, use the color name
@@ -61,8 +98,13 @@ class PyncheWidget(Pmw.MegaWidget):
else:
rrggbb = ColorDB.triplet_to_rrggbb(rgbtuple)
self.__selected.configure(color=rrggbb)
+
+ # configure all subwidgets
self.__nearest.configure(color=nearest)
self.__typein.configure(color=rgbtuple)
+ self.__reds.configure(color=rgbtuple)
+ self.__greens.configure(color=rgbtuple)
+ self.__blues.configure(color=rgbtuple)
delegate = self['delegate']
if delegate:
delegate.set_color(self, rgbtuple)