summaryrefslogtreecommitdiffstats
path: root/Tools
diff options
context:
space:
mode:
authorBarry Warsaw <barry@python.org>2001-08-23 16:14:45 (GMT)
committerBarry Warsaw <barry@python.org>2001-08-23 16:14:45 (GMT)
commite47e97792a1d1d86b2cbfe540a5e2635c7510a61 (patch)
tree9a80bb824fa0baf31347fc6982fd5d303d3731cd /Tools
parentcf144b0e9eca14f813d2abefd5748c2cf47b5772 (diff)
downloadcpython-e47e97792a1d1d86b2cbfe540a5e2635c7510a61.zip
cpython-e47e97792a1d1d86b2cbfe540a5e2635c7510a61.tar.gz
cpython-e47e97792a1d1d86b2cbfe540a5e2635c7510a61.tar.bz2
Implement some suggestions by Laura Creighton.
ChipWidget.__init__(): Added a message area just below the color name. Both the message and name widgets are now FLAT, DISABLED Entry widgets instead of Labels. This allows users to copy-n-paste the color names or color specs. Also, the contents of both widgets are now driven by StringVars. set_color(): This only sets the chip color; it does not set the name widgets. set_name(): New method which only sets the name widget contents. set_message(): New method which only sets the message widget contents. ChipViewer.update_yourself(): Set the color, name, and message for each chip as follows: the first line always contains the color spec in #rrggbb format. The second line will contain the color name, but slightly differently for each widget. For the Selected widget, if the color exactly matches the Nearest color, the name is shown, otherwise the message field will be empty. The name field of the Nearest widget will always contain the color name.
Diffstat (limited to 'Tools')
-rw-r--r--Tools/pynche/ChipViewer.py34
1 files changed, 28 insertions, 6 deletions
diff --git a/Tools/pynche/ChipViewer.py b/Tools/pynche/ChipViewer.py
index c6b36c5..faa6948 100644
--- a/Tools/pynche/ChipViewer.py
+++ b/Tools/pynche/ChipViewer.py
@@ -39,23 +39,37 @@ class ChipWidget:
height=height,
background=initialcolor)
self.__chip.grid(row=1, column=0)
- # create the color name, ctor argument must be a string
- self.__name = Label(master, text=initialcolor)
+ # create the color name
+ self.__namevar = StringVar()
+ self.__namevar.set(initialcolor)
+ self.__name = Entry(master, textvariable=self.__namevar,
+ relief=FLAT, justify=CENTER, state=DISABLED,
+ font=self.__label['font'])
self.__name.grid(row=2, column=0)
- #
+ # create the message area
+ self.__msgvar = StringVar()
+ self.__name = Entry(master, textvariable=self.__msgvar,
+ relief=FLAT, justify=CENTER, state=DISABLED,
+ font=self.__label['font'])
+ self.__name.grid(row=3, column=0)
# set bindings
if presscmd:
self.__chip.bind('<ButtonPress-1>', presscmd)
if releasecmd:
self.__chip.bind('<ButtonRelease-1>', releasecmd)
- def set_color(self, color, colorname=None):
+ def set_color(self, color):
self.__chip.config(background=color)
- self.__name.config(text=colorname or color)
def get_color(self):
return self.__chip['background']
+ def set_name(self, colorname):
+ self.__namevar.set(colorname)
+
+ def set_message(self, message):
+ self.__msgvar.set(message)
+
def press(self):
self.__chip.configure(relief=SUNKEN)
@@ -97,7 +111,15 @@ class ChipViewer:
nearest_tuple = colordb.find_byname(nearest)
nearest_rrggbb = ColorDB.triplet_to_rrggbb(nearest_tuple)
self.__selected.set_color(rrggbb)
- self.__nearest.set_color(nearest_rrggbb, nearest)
+ self.__nearest.set_color(nearest_rrggbb)
+ # set the name and messages areas
+ self.__selected.set_name(rrggbb)
+ if rrggbb == nearest_rrggbb:
+ self.__selected.set_message(nearest)
+ else:
+ self.__selected.set_message('')
+ self.__nearest.set_name(nearest_rrggbb)
+ self.__nearest.set_message(nearest)
def __buttonpress(self, event=None):
self.__nearest.press()