summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBarry Warsaw <barry@python.org>1998-03-10 00:17:30 (GMT)
committerBarry Warsaw <barry@python.org>1998-03-10 00:17:30 (GMT)
commit5bfac8d7fdc600b4143bc9cb6222ec91c814617f (patch)
treea74aef0f1f0a8d80074b526b3e1868137a42d518
parentf67575d69df3a5bb7b69dc91a8da0617daa52907 (diff)
downloadcpython-5bfac8d7fdc600b4143bc9cb6222ec91c814617f.zip
cpython-5bfac8d7fdc600b4143bc9cb6222ec91c814617f.tar.gz
cpython-5bfac8d7fdc600b4143bc9cb6222ec91c814617f.tar.bz2
Integrate with OptionsWindow... need to hook into Tab key
-rw-r--r--Tools/pynche/TypeinViewer.py24
1 files changed, 19 insertions, 5 deletions
diff --git a/Tools/pynche/TypeinViewer.py b/Tools/pynche/TypeinViewer.py
index 44c4b36..2782799 100644
--- a/Tools/pynche/TypeinViewer.py
+++ b/Tools/pynche/TypeinViewer.py
@@ -7,6 +7,7 @@ class TypeinWidget(Pmw.MegaWidget):
options = (('color', (128, 128, 128), self.__set_color),
('delegate', None, None),
)
+ self.__update = 1
self.defineoptions(kw, options)
Pmw.MegaWidget.__init__(self, parent)
@@ -23,7 +24,8 @@ class TypeinWidget(Pmw.MegaWidget):
maxwidth=4,
entry_width=4,
validate=self.__validate,
- modifiedcommand=self.__modified)
+ modifiedcommand=self.__modified,
+ command=self.__force_modify)
self.__x.grid(row=0, column=0)
self.__y = self.createcomponent(
@@ -36,7 +38,8 @@ class TypeinWidget(Pmw.MegaWidget):
maxwidth=4,
entry_width=4,
validate=self.__validate,
- modifiedcommand=self.__modified)
+ modifiedcommand=self.__modified,
+ command=self.__force_modify)
self.__y.grid(row=1, column=0)
self.__z = self.createcomponent(
@@ -49,7 +52,8 @@ class TypeinWidget(Pmw.MegaWidget):
maxwidth=4,
entry_width=4,
validate=self.__validate,
- modifiedcommand=self.__modified)
+ modifiedcommand=self.__modified,
+ command=self.__force_modify)
self.__z.grid(row=2, column=0)
# Check keywords and initialize options
@@ -68,6 +72,9 @@ class TypeinWidget(Pmw.MegaWidget):
if obj == self:
return
+ def set_update_on_typing(self, flag):
+ self.__update = flag
+
#
# PRIVATE INTERFACE
#
@@ -90,15 +97,22 @@ class TypeinWidget(Pmw.MegaWidget):
return -1
# called whenever a text entry is modified
- def __modified(self):
+ def __modified(self, force=None):
# these are guaranteed to be valid, right?
vals = map(lambda x: x.get(), (self.__x, self.__y, self.__z))
rgbs = tuple(map(self.__str_to_int, vals))
valids = map(self.__validate, vals)
delegate = self['delegate']
- if (None not in rgbs) and (-1 not in valids) and delegate:
+ if ((force or self.__update) and
+ (None not in rgbs) and
+ (-1 not in valids) and
+ delegate):
+ #
delegate.set_color(self, rgbs)
+ def __force_modify(self):
+ self.__modified(force=1)
+
# called whenever the color option is changed
def __set_color(self):
rgbtuple = self['color']