77from ChipWidget import ChipWidget
88from TypeinWidget import TypeinWidget
99from StripWidget import StripWidget
10- from OptionsWidget import OptionsWidget
10+ from OptionsWidget import PyncheOptions
1111
1212
1313
@@ -114,11 +114,12 @@ def __init__(self, colordb, parent=None, **kw):
114114
115115 # create chip window
116116 group = Pmw .Group (parent , tag_text = 'Current Color' )
117+ interior = group .interior ()
117118 group .pack (side = LEFT , expand = YES , fill = BOTH )
118- self .__selected = ChipWidget (group . interior () ,
119+ self .__selected = ChipWidget (interior ,
119120 label_text = 'Selected' )
120121 self .__selected .grid ()
121- self .__nearest = ChipWidget (group . interior () ,
122+ self .__nearest = ChipWidget (interior ,
122123 label_text = 'Nearest' )
123124 self .__nearest .grid (row = 0 , column = 1 )
124125
@@ -128,10 +129,19 @@ def __init__(self, colordb, parent=None, **kw):
128129 self .__chip .bind ('<ButtonPress-1>' , self .__buttonpress )
129130 self .__chip .bind ('<ButtonRelease-1>' , self .__buttonrelease )
130131
131- # create the options window
132- self .__typein = TypeinWidget (group . interior () )
132+ # create the type-in window
133+ self .__typein = TypeinWidget (interior )
133134 self .__typein .grid (row = 0 , column = 2 )
134135
136+ # create the type-in color name field
137+ ## self.__colorname = self.createcomponent(
138+ ## 'colorname', (), None,
139+ ## Pmw.EntryField, (interior,),
140+ ## label_text='Color Name'
141+ ## )
142+ ## self.__colorname.pack()
143+ ## self.__colorname.configure(command=self.__set_color_by_name())
144+
135145 # Check keywords and initialize options
136146 self .initialiseoptions (PyncheWidget )
137147
@@ -173,6 +183,11 @@ def set_color(self, obj, rgbtuple):
173183 def __set_color (self ):
174184 self .set_color (self , self ['color' ])
175185
186+ def __set_color_by_name (self ):
187+ colorname = self .__colorname .get ()
188+ rgbtuple = self .__colordb .find_byname (colorname )
189+ self .set_color (self , rgbtuple )
190+
176191 def __buttonpress (self , event = None ):
177192 self .__chip .configure (relief = SUNKEN )
178193
@@ -200,8 +215,15 @@ def __popup_about(self, event=None):
200215
201216 def __popup_options (self , event = None ):
202217 if not self .__options_dialog :
203- self .__options_dialog = OptionsWidget ()
204- self .__options_dialog .activate ()
205- # now gather up the new options
218+ self .__options_dialog = PyncheOptions (
219+ title = 'Pynche Options' ,
220+ applycommand = self .__apply )
221+ # pop up the window, non-modal
222+ self .__options_dialog .deiconify ()
223+
224+ def __apply (self ):
206225 self .__typein .set_update_on_typing (
207226 self .__options_dialog .get_value ('typing' ))
227+ flag = self .__options_dialog .get_value ('dragging' )
228+ for strip in (self .__reds , self .__greens , self .__blues ):
229+ strip .set_update_while_dragging (flag )
0 commit comments