]> granicus.if.org Git - python/commitdiff
Integrate with OptionsWindow... need to hook into Tab key
authorBarry Warsaw <barry@python.org>
Tue, 10 Mar 1998 00:17:30 +0000 (00:17 +0000)
committerBarry Warsaw <barry@python.org>
Tue, 10 Mar 1998 00:17:30 +0000 (00:17 +0000)
Tools/pynche/TypeinViewer.py

index 44c4b3629aee9e15074309269914241f68323aa0..2782799dd8483fab6eb09decd3e84d225cefc32b 100644 (file)
@@ -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']