Null commit with -f option to force an uprev and put HEADs firmly on the trunk.
[python/dscho.git] / Tools / pynche / README
blob33a7fc250ae1290d479280674627feacbf2b88cc
1 Pynche - The PYthonically Natural Color and Hue Editor
3 Contact: Barry A. Warsaw
4 Email:   bwarsaw@python.org
5 Version: 1.1
7 Introduction
9     Pynche is a color editor based largely on a similar program that I
10     originally wrote back in 1987 for the Sunview window system.  That
11     editor was called ICE, the Interactive Color Editor.  I'd always
12     wanted to port this program to X but didn't feel like hacking X
13     and C code to do it.  Fast forward many years, to where Python +
14     Tkinter provides such a nice programming environment, with enough
15     power, that I finally buckled down and re-implemented it.  I
16     changed the name because these days, too many other systems have
17     the acronym `ICE'.
19     Pynche should work with Python 1.5.2, 2.0, or 2.1, using Tk 8.0.x.
20     It's been tested on Solaris 2.6, Windows NT 4, and various Linux
21     distros.  You'll want to be sure to have at least Tk 8.0.3 for
22     Windows.  Also, Pynche is very colormap intensive, so it doesn't
23     work very well on 8-bit graphics cards; 24bit+ graphics cards are
24     so cheap these days, I'll probably never "fix" that.
26     Pynche must find a text database of colors names in order to
27     provide `nearest' color matching.  Pynche is distributed with an
28     rgb.txt file from the X11R6.4 distribution for this reason, along
29     with other "Web related" database (see below).  You can use a
30     different file with the -d option.  The file xlicense.txt contains
31     the license only for rgb.txt and both files are in the X/
32     subdirectory.
34     Pynche is pronounced `Pinch-ee'.
36 Running Standalone
38     On Unix, start it by running the `pynche' script.  On Windows, run
39     pynche.pyw to inhibit the console window.  When run from the
40     command line, the following options are recognized:
42     --database file
43     -d file
44         Alternate location of the color database file.  Without this
45         option, the first valid file found will be used (see below).
47     --initfile file
48     -i file
49         Alternate location of the persistent initialization file.  See 
50         the section on Persistency below.
52     --ignore
53     -X
54         Ignore the persistent initialization file when starting up.
55         Pynche will still write the current option settings to the
56         persistent init file when it quits.
58     --help
59     -h
60         Print the help message.
62     initialcolor
63         a Tk color name or #rrggbb color spec to be used as the
64         initially selected color.  This overrides any color saved in
65         the persistent init file.  Since `#' needs to be escaped in
66         many shells, it is optional in the spec (e.g. #45dd1f is the
67         same as 45dd1f).
69 Running as a Modal Dialog
71     Pynche can be run as a modal dialog, inside another application,
72     say as a general color chooser.  In fact, Grail 0.6 already uses
73     Pynche and a future version of IDLE may as well.  Pynche supports
74     the API implemented by the Tkinter standard tkColorChooser module,
75     with a few changes as described below.  By importing pyColorChooser
76     from the Pynche package, you can run
78         pyColorChooser.askcolor()
80     which will popup Pynche as a modal dialog, and return the selected 
81     color.
83     There are some UI differences when running as a modal
84     vs. standalone.  When running as a modal, there is no "Quit" menu
85     item under the "File" menu.  Instead there are "Okay" and "Cancel"
86     buttons.
88     When "Okay" is hit, askcolor() returns the tuple
90         ((r, g, b), "name")
92     where r, g, and b are red, green, and blue color values
93     respectively (in the range 0 to 255).  "name" will be a color name
94     from the color database if there is an exact match, otherwise it
95     will be an X11 color spec of the form "#rrggbb".  Note that this
96     is different than tkColorChooser, which doesn't know anything
97     about color names.
99     askcolor() supports the following optional keyword arguments:
101         color
102             the color to set as the initial selected color
104         master[*]
105             the master window to use as the parent of the modal
106             dialog.  Without this argument, pyColorChooser will create 
107             it's own Tkinter.Tk instance as the master.  This may not
108             be what you want.
110         databasefile
111             similar to the --database option, the value must be a
112             file name
114         initfile[*]
115             similar to the --initfile option, the value must be a
116             file name
118         ignore[*]
119             similar to the --ignore flag, the value is a boolean
121         wantspec
122             When this is true, the "name" field in the return tuple
123             will always be a color spec of the form "#rrggbb".  It
124             will not return a color name even if there is a match;
125             this is so pyColorChooser can exactly match the API of
126             tkColorChooser.
128         [*] these arguments must be specified the first time
129         askcolor() is used and cannot be changed on subsequent calls.
131 The Colorstrip Window
133     The top part of the main Pynche window contains the "variation
134     strips".  Each strip contains a number of "color chips".  The
135     strips always indicate the currently selected color by a highlight
136     rectangle around the selected color chip, with an arrow pointing
137     to the chip.  Each arrow has an associated number giving you the
138     color value along the variation's axis.  Each variation strip
139     shows you the colors that are reachable from the selected color by
140     varying just one axis of the color solid.
142     For example, when the selected color is (in Red/Green/Blue
143     notation) 127/127/127, the Red Variations strip shows you every
144     color in the range 0/127/127 to 255/127/127.  Similarly for the
145     green and blue axes.  You can select any color by clicking on its
146     chip.  This will update the highlight rectangle and the arrow, as
147     well as other displays in Pynche.
149     Click on "Update while dragging" if you want Pynche to update the
150     selected color while you drag along any variation strip (this will
151     be slower).  Click on "Hexadecimal" to display the arrow numbers
152     in hex.
154     There are also two shortcut buttons in this window, which
155     auto-select Black (0/0/0) and White (255/255/255).
157 The Proof Window
159     In the lower left corner of the main window you see two larger
160     color chips.  The Selected chip shows you a larger version of the
161     color selected in the variation strips, along with its X11 color
162     specification.  The Nearest chip shows you the closest color in
163     the X11 database to the selected color, giving its X11 color name.
164     Clicking on the Nearest color chip selects that color.  Color
165     distance is calculated in the 3D space of the RGB color solid and
166     if more than one color name is the same distance from the selected
167     color, the first one found will be chosen.
169     Note that there may be more than one X11 color name for the same
170     RGB value.  In that case, the first one found in the text database
171     is designated the "primary" name, and this is shown under the
172     Nearest chip.  The other names are "aliases" and they are visible
173     in the Color List Window (see below).
175 The Type-in Window
177     At the lower right of the main window are three entry fields.
178     Here you can type numeric values for any of the three color axes.
179     Legal values are between 0 and 255, and these fields do not allow
180     you to enter illegal values.  You must hit Enter or Tab to select
181     the new color.
183     Click on "Update while typing" if you want Pynche to select the
184     color on every keystroke (well, every one that produces a legal
185     value!)  Click on "Hexadecimal" to display and enter color values
186     in hex.
188 Other Views
190     There are three secondary windows which are not displayed by
191     default.  You can bring these up via the "View" menu on the main
192     Pynche window.
194 The Text Window
196     The "Text Window" allows you to see what effects various colors
197     have on the standard Tk text widget elements.  In the upper part
198     of the window is a plain Tk text widget and here you can edit the
199     text, select a region of text, etc.  Below this is a button "Track
200     color changes".  When this is turned on, any colors selected in
201     the other windows will change the text widget element specified in
202     the radio buttons below.  When this is turned off, text widget
203     elements are not affected by color selection.
205     You can choose which element gets changed by color selection by
206     clicking on one of the radio buttons in the bottom part of this
207     window.  Text foreground and background affect the text in the
208     upper part of the window.  Selection foreground and background
209     affect the colors of the primary selection which is what you see
210     when you click the middle button (depending on window system) and
211     drag it through some text.
213     The Insertion is the insertion cursor in the text window, where
214     new text will be inserted as you type.  The insertion cursor only
215     has a background.
217 The Color List Window
219     The "Color List" window shows every named color in the color name
220     database (this window may take a while to come up).  In the upper
221     part of the window you see a scrolling list of all the color names
222     in the database, in alphabetical order.  Click on any color to
223     select it.  In the bottom part of the window is displayed any
224     aliases for the selected color (those color names that have the
225     same RGB value, but were found later in the text database).  For
226     example, find the color "Black" and you'll see that its aliases
227     are "gray0" and "grey0".
229     If the color has no aliases you'll see "<no aliases>" here.  If you
230     just want to see if a color has an alias, and do not want to select a
231     color when you click on it, turn off "Update on Click".
233     Note that the color list is always updated when a color is selected
234     from the main window.  There's no way to turn this feature off.  If
235     the selected color has no matching color name you'll see
236     "<no matching color>" in the Aliases window.
238 The Details Window
240     The "Details" window gives you more control over color selection
241     than just clicking on a color chip in the main window.  The row of
242     buttons along the top apply the specified increment and decrement
243     amounts to the selected color.  These delta amounts are applied to
244     the variation strips specified by the check boxes labeled "Move
245     Sliders".  Thus if just Red and Green are selected, hitting -10
246     will subtract 10 from the color value along the red and green
247     variation only.  Note the message under the checkboxes; this
248     indicates the primary color level being changed when more than one
249     slider is tied together.  For example, if Red and Green are
250     selected, you will be changing the Yellow level of the selected
251     color.
253     The "At Boundary" behavior determines what happens when any color
254     variation hits either the lower or upper boundaries (0 or 255) as
255     a result of clicking on the top row buttons:
257     Stop
258         When the increment or decrement would send any of the tied
259         variations out of bounds, the entire delta is discarded.
261     Wrap Around
262         When the increment or decrement would send any of the tied
263         variations out of bounds, the out of bounds value is wrapped
264         around to the other side.  Thus if red were at 238 and +25
265         were clicked, red would have the value 7.
267     Preserve Distance
268         When the increment or decrement would send any of the tied
269         variations out of bounds, all tied variations are wrapped as
270         one, so as to preserve the distance between them.  Thus if
271         green and blue were tied, and green was at 238 while blue was
272         at 223, and +25 were clicked, green would be at 15 and blue
273         would be at 0.
275     Squash
276         When the increment or decrement would send any of the tied
277         variations out of bounds, the out of bounds variation is set
278         to the ceiling of 255 or floor of 0, as appropriate.  In this
279         way, all tied variations are squashed to one edge or the
280         other.
282     The top row buttons have the following keyboard accelerators:
284     -25 == Shift Left Arrow
285     -10 == Control Left Arrow
286      -1 == Left Arrow
287      +1 == Right Arrow
288     +10 == Control Right Arrow
289     +25 == Shift Right Arrow
291 Keyboard Accelerators
293     Alt-w in any secondary window dismisses the window.  In the main
294     window it exits Pynche (except when running as a modal).
296     Alt-q in any window exits Pynche (except when running as a modal).
298 Persistency
300     Pynche remembers various settings of options and colors between
301     invocations, storing these values in a `persistent initialization
302     file'.  The actual location of this file is specified by the
303     --initfile option (see above), and defaults to ~/.pynche.
305     When Pynche exits, it saves these values in the init file, and
306     re-reads them when it starts up.  There is no locking on this
307     file, so if you run multiple instances of Pynche at a time, you
308     may clobber the init file.
310     The actual options stored include
312     - the currently selected color
314     - all settings of checkbox and radio button options in all windows
316     - the contents of the text window, the current text selection and
317       insertion point, and all current text widget element color
318       settings.
320     - the name of the color database file (but not its contents)
322     You can inhibit Pynche from reading the init file by supplying the
323     --ignore option on the command line.  However, you cannot suppress
324     the storing of the settings in the init file on Pynche exit.  If
325     you really want to do this, use /dev/null as the init file, using
326     --initfile.
328 Color Name Database Files
330     Pynche uses a color name database file to calculate the nearest
331     color to the selected color, and to display in the Color List
332     view.  Several files are distributed with Pynche, described
333     below.  By default, the X11 color name database file is selected.
334     Other files:
336     html40colors.txt -- the HTML 4.0 guaranteed color names
338     websafe.txt -- the 216 "Web-safe" colors that Netscape and MSIE
339     guarantee will not be dithered.  These are specified in #rrggbb
340     format for both values and names
342     webcolors.txt -- The 140 color names that Tim Peters and his
343     sister say NS and MSIE both understand (with some controversy over 
344     AliceBlue).
346     namedcolors.txt -- an alternative set of Netscape colors.
348     You can switch between files by choosing "Load palette..." from
349     the "File" menu.  This brings up a standard Tk file dialog.
350     Choose the file you want and then click "Ok".  If Pynche
351     understands the format in this file, it will load the database and 
352     update the appropriate windows.  If not, it will bring up an error 
353     dialog.
355 To Do
357     Here's a brief list of things I want to do:
359     - Better support for resizing the top level windows
361     - More output views, e.g. color solids
363     - Have the notion of a `last color selected'; this may require a
364       new output view
366     - Support setting the font in the text view
368     I'm open to suggestions!
372 Local Variables:
373 indent-tabs-mode: nil
374 End: