[PythonReports-checkins] PythonReports/PythonReports design.py, 1.4, 1.5
Brought to you by:
a1s
From: alexander s. <a1...@us...> - 2006-11-03 12:49:39
|
Update of /cvsroot/pythonreports/PythonReports/PythonReports In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24875 Modified Files: design.py Log Message: fix ColorSelection: hide indicator when color is unset, bell when invalid value entered, pass rgb string to askcolor(), retake focus after askcolor Index: design.py =================================================================== RCS file: /cvsroot/pythonreports/PythonReports/PythonReports/design.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** design.py 3 Nov 2006 11:29:24 -0000 1.4 --- design.py 3 Nov 2006 12:49:31 -0000 1.5 *************** *** 2,5 **** --- 2,9 ---- """History (most recent first): + 02-nov-2006 [als] fix ColorSelection: hide indicator when color is unset, + bell when invalid value entered, + pass rgb string to askcolor(), + retake focus after askcolor 02-nov-2006 [als] pop up the tree menu on Shift+F10; added element reordering commands "move up" and "move down" *************** *** 287,316 **** self["background"] = self.winfo_toplevel().color_panel _select = CodeSelection(self, editable=True, variable=self.var, ! values=sorted(Color.names.keys()), validatecmd=self.OnEntry) _select.grid(row=0, column=0) ! self.indicator = Frame(self, relief=RIDGE, borderwidth=4, ! background=self.var.get()) ! self.indicator.grid(row=0, column=1, sticky=NE+SW, padx=5, pady=1) ! _btn = Button(self, command=self.OnButton, text=self.winfo_toplevel()._("...")) ! _btn.grid(row=0, column=2) self.columnconfigure(1, weight=1) ! def OnEntry(self, value): ! """Validate the combo box value""" ! try: ! _color = Color.fromValue(value) ! except InvalidLiteral: ! value = self.var.get() else: self.indicator["background"] = _color return value def OnButton(self): # askcolor returns ((r, g, b), "#rrggbb") or (None, None) ! _color = askcolor(self.var.get())[1] if _color: ! self.var.set(_color) ! self.indicator["background"] = _color class PropertyEntry(Frame): --- 291,330 ---- self["background"] = self.winfo_toplevel().color_panel _select = CodeSelection(self, editable=True, variable=self.var, ! values=sorted(Color.names.keys()), validatecmd=self.updateColor) _select.grid(row=0, column=0) ! self.indicator = Frame(self, relief=RIDGE, borderwidth=4) ! self.button = Button(self, command=self.OnButton, text=self.winfo_toplevel()._("...")) ! self.button.grid(row=0, column=2) self.columnconfigure(1, weight=1) + self.updateColor() ! def updateColor(self, value=NOTHING): ! """Validate the combo box value; update color indicator""" ! if value is NOTHING: ! _color = Color.fromValue(self.var.get()) else: + try: + _color = Color.fromValue(value) + except InvalidLiteral: + self.bell() + # validation will return current value + value = self.var.get() + _color = Color.fromValue(value) + else: + self.var.set(value) + if _color: self.indicator["background"] = _color + self.indicator.grid(row=0, column=1, sticky=NE+SW, padx=5, pady=1) + else: + self.indicator.grid_forget() return value def OnButton(self): # askcolor returns ((r, g, b), "#rrggbb") or (None, None) ! _color = askcolor(Color.fromValue(self.var.get()))[1] if _color: ! self.updateColor(_color) ! self.button.focus_set() class PropertyEntry(Frame): |