summaryrefslogtreecommitdiffstats
path: root/Tools/pynche/ChipViewer.py
diff options
context:
space:
mode:
authorBarry Warsaw <barry@python.org>1998-10-22 03:25:59 (GMT)
committerBarry Warsaw <barry@python.org>1998-10-22 03:25:59 (GMT)
commitca07ba00acdd020e0c179277ed829a8ce1664245 (patch)
tree03ddbed7626ca441d4c90d599b2028773f8e298c /Tools/pynche/ChipViewer.py
parent04da10c7a2fa0bd060e8052a9fe3d47623324b94 (diff)
downloadcpython-ca07ba00acdd020e0c179277ed829a8ce1664245.zip
cpython-ca07ba00acdd020e0c179277ed829a8ce1664245.tar.gz
cpython-ca07ba00acdd020e0c179277ed829a8ce1664245.tar.bz2
Many changes to support a second mode of operation. Pynche can now be
run either as a standalone application (by running pynche or pynche.pyw), or as a modal dialog inside another application. This can be done by importing pyColorChooser and running askcolor(). The API for this is the same as the tkColorChooser.askcolor() API, namely: When `Okay' is hit, askcolor() returns ((r, g, b), "name"). When `Cancel' is hit, askcolor() returns (None, None). Note the following differences: 1. pyColorChooser.askcolor() takes an optional keyword `master' which if set tells Pynche to run as a modal dialog. `master' is a Tkinter parent window. Without the `master' keyword Pynche runs standalone. 2. in pyColorChooser.askcolor() will return a Tk/X11 color name as "name" if there is an exact match, otherwise it will return a color spec, e.g. "#rrggbb". tkColorChooser can't return a color name. There are also some UI differences when running standalone vs. modal. When modal, there is no "File" menu, but instead there are "Okay" and "Cancel" buttons. The implementation of all this is a bit of a hack, but it seems to work moderately well. I'm not guaranteeing the pyColorChooser.Chooser class has the same semantics as the tkColorChooser.Chooser class.
Diffstat (limited to 'Tools/pynche/ChipViewer.py')
-rw-r--r--Tools/pynche/ChipViewer.py22
1 files changed, 7 insertions, 15 deletions
diff --git a/Tools/pynche/ChipViewer.py b/Tools/pynche/ChipViewer.py
index fbf9aad..5bd0bdf 100644
--- a/Tools/pynche/ChipViewer.py
+++ b/Tools/pynche/ChipViewer.py
@@ -23,7 +23,7 @@ class ChipWidget:
_HEIGHT = 80
def __init__(self,
- parent = None,
+ master = None,
width = _WIDTH,
height = _HEIGHT,
text = 'Color',
@@ -31,16 +31,16 @@ class ChipWidget:
presscmd = None,
releasecmd = None):
# create the text label
- self.__label = Label(parent, text=text)
+ self.__label = Label(master, text=text)
self.__label.grid(row=0, column=0)
# create the color chip, implemented as a frame
- self.__chip = Frame(parent, relief=RAISED, borderwidth=2,
+ self.__chip = Frame(master, relief=RAISED, borderwidth=2,
width=width,
height=height,
background=initialcolor)
self.__chip.grid(row=1, column=0)
# create the color name, ctor argument must be a string
- self.__name = Label(parent, text=initialcolor)
+ self.__name = Label(master, text=initialcolor)
self.__name.grid(row=2, column=0)
#
# set bindings
@@ -65,10 +65,10 @@ class ChipWidget:
class ChipViewer:
- def __init__(self, switchboard, parent=None):
+ def __init__(self, switchboard, master=None):
self.__sb = switchboard
- self.__frame = Frame(parent) #, relief=GROOVE, borderwidth=2)
- self.__frame.grid(row=3, column=0)
+ self.__frame = Frame(master, relief=RAISED, borderwidth=1)
+ self.__frame.grid(row=3, column=0, ipadx=5)
# create the chip that will display the currently selected color
# exactly
self.__sframe = Frame(self.__frame)
@@ -81,11 +81,6 @@ class ChipViewer:
self.__nearest = ChipWidget(self.__nframe, text='Nearest',
presscmd = self.__buttonpress,
releasecmd = self.__buttonrelease)
- self.__div = Frame(self.__frame,
- width=2,
- borderwidth=2,
- relief=RAISED)
- self.__div.grid(row=0, column=2, sticky='NS', padx=5)
def update_yourself(self, red, green, blue):
# TBD: should exactname default to X11 color name if their is an exact
@@ -110,6 +105,3 @@ class ChipViewer:
colorname = self.__nearest.get_color()
red, green, blue = self.__sb.colordb().find_byname(colorname)
self.__sb.update_views(red, green, blue)
-
- def save_options(self, optiondb):
- pass