blob: 9b58592d8a5a292588aa2746dbb36c289a224645 [file] [log] [blame]
Barry Warsawe55055d1998-10-06 23:03:22 +00001Pynche - The PYthonically Natural Color and Hue Editor
Barry Warsaweb6b9b71998-12-03 19:49:45 +00002
Barry Warsaw64039911998-12-15 01:02:51 +00003Contact: Barry A. Warsaw
Barry Warsaweb6b9b71998-12-03 19:49:45 +00004Email: bwarsaw@python.org
Barry Warsaw3e481de2001-07-10 21:37:04 +00005Version: 1.2
Barry Warsawe55055d1998-10-06 23:03:22 +00006
Barry Warsaw3dd1c391998-10-22 04:14:24 +00007Introduction
Barry Warsawe55055d1998-10-06 23:03:22 +00008
Barry Warsaw3dd1c391998-10-22 04:14:24 +00009 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'.
Barry Warsawe55055d1998-10-06 23:03:22 +000018
Barry Warsaw6330b522001-04-18 03:48:41 +000019 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.
Barry Warsawe55055d1998-10-06 23:03:22 +000025
Barry Warsaw821d8b71999-04-26 23:46:25 +000026 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.
Barry Warsawe55055d1998-10-06 23:03:22 +000033
Barry Warsaw3e481de2001-07-10 21:37:04 +000034 Pynche is pronounced: Pin'-chee
35
Barry Warsawe55055d1998-10-06 23:03:22 +000036
Barry Warsaw3dd1c391998-10-22 04:14:24 +000037Running Standalone
Barry Warsawe55055d1998-10-06 23:03:22 +000038
Barry Warsaw3dd1c391998-10-22 04:14:24 +000039 On Unix, start it by running the `pynche' script. On Windows, run
40 pynche.pyw to inhibit the console window. When run from the
41 command line, the following options are recognized:
Barry Warsawe55055d1998-10-06 23:03:22 +000042
Barry Warsaw3dd1c391998-10-22 04:14:24 +000043 --database file
44 -d file
45 Alternate location of the color database file. Without this
Barry Warsaw821d8b71999-04-26 23:46:25 +000046 option, the first valid file found will be used (see below).
Barry Warsawe55055d1998-10-06 23:03:22 +000047
Barry Warsaw3dd1c391998-10-22 04:14:24 +000048 --initfile file
49 -i file
50 Alternate location of the persistent initialization file. See
51 the section on Persistency below.
Barry Warsawe55055d1998-10-06 23:03:22 +000052
Barry Warsaw3dd1c391998-10-22 04:14:24 +000053 --ignore
54 -X
55 Ignore the persistent initialization file when starting up.
56 Pynche will still write the current option settings to the
57 persistent init file when it quits.
Barry Warsawe55055d1998-10-06 23:03:22 +000058
Barry Warsaw3dd1c391998-10-22 04:14:24 +000059 --help
60 -h
Barry Warsaweb6b9b71998-12-03 19:49:45 +000061 Print the help message.
Barry Warsawe55055d1998-10-06 23:03:22 +000062
Barry Warsaw3dd1c391998-10-22 04:14:24 +000063 initialcolor
Barry Warsaweb6b9b71998-12-03 19:49:45 +000064 a Tk color name or #rrggbb color spec to be used as the
65 initially selected color. This overrides any color saved in
66 the persistent init file. Since `#' needs to be escaped in
67 many shells, it is optional in the spec (e.g. #45dd1f is the
68 same as 45dd1f).
Barry Warsawe55055d1998-10-06 23:03:22 +000069
Barry Warsaw3e481de2001-07-10 21:37:04 +000070
Barry Warsaw3dd1c391998-10-22 04:14:24 +000071Running as a Modal Dialog
Barry Warsawe55055d1998-10-06 23:03:22 +000072
Barry Warsaw821d8b71999-04-26 23:46:25 +000073 Pynche can be run as a modal dialog, inside another application,
Barry Warsaw3e481de2001-07-10 21:37:04 +000074 say as a general color chooser. In fact, Grail 0.6 uses Pynche
75 and a future version of IDLE may as well. Pynche supports the API
76 implemented by the Tkinter standard tkColorChooser module, with a
77 few changes as described below. By importing pyColorChooser from
78 the Pynche package, you can run
Barry Warsawe55055d1998-10-06 23:03:22 +000079
Barry Warsawcf1daad1998-10-22 19:00:38 +000080 pyColorChooser.askcolor()
Barry Warsawe55055d1998-10-06 23:03:22 +000081
Barry Warsawcf1daad1998-10-22 19:00:38 +000082 which will popup Pynche as a modal dialog, and return the selected
83 color.
Barry Warsawe55055d1998-10-06 23:03:22 +000084
Barry Warsaw3dd1c391998-10-22 04:14:24 +000085 There are some UI differences when running as a modal
Barry Warsaw821d8b71999-04-26 23:46:25 +000086 vs. standalone. When running as a modal, there is no "Quit" menu
87 item under the "File" menu. Instead there are "Okay" and "Cancel"
88 buttons.
Barry Warsawe55055d1998-10-06 23:03:22 +000089
Barry Warsaw3dd1c391998-10-22 04:14:24 +000090 When "Okay" is hit, askcolor() returns the tuple
Barry Warsawe55055d1998-10-06 23:03:22 +000091
Barry Warsaweb6b9b71998-12-03 19:49:45 +000092 ((r, g, b), "name")
Barry Warsawe55055d1998-10-06 23:03:22 +000093
Barry Warsaw3dd1c391998-10-22 04:14:24 +000094 where r, g, and b are red, green, and blue color values
95 respectively (in the range 0 to 255). "name" will be a color name
96 from the color database if there is an exact match, otherwise it
97 will be an X11 color spec of the form "#rrggbb". Note that this
98 is different than tkColorChooser, which doesn't know anything
99 about color names.
100
Barry Warsawcf1daad1998-10-22 19:00:38 +0000101 askcolor() supports the following optional keyword arguments:
Barry Warsaw3dd1c391998-10-22 04:14:24 +0000102
Barry Warsaweb6b9b71998-12-03 19:49:45 +0000103 color
104 the color to set as the initial selected color
Barry Warsaw3dd1c391998-10-22 04:14:24 +0000105
Barry Warsaweb6b9b71998-12-03 19:49:45 +0000106 master[*]
107 the master window to use as the parent of the modal
108 dialog. Without this argument, pyColorChooser will create
109 it's own Tkinter.Tk instance as the master. This may not
110 be what you want.
Barry Warsaw3dd1c391998-10-22 04:14:24 +0000111
Barry Warsawa853adc1999-04-27 18:57:00 +0000112 databasefile
Barry Warsaweb6b9b71998-12-03 19:49:45 +0000113 similar to the --database option, the value must be a
114 file name
Barry Warsaw3dd1c391998-10-22 04:14:24 +0000115
Barry Warsaweb6b9b71998-12-03 19:49:45 +0000116 initfile[*]
117 similar to the --initfile option, the value must be a
118 file name
Barry Warsaw3dd1c391998-10-22 04:14:24 +0000119
Barry Warsaweb6b9b71998-12-03 19:49:45 +0000120 ignore[*]
121 similar to the --ignore flag, the value is a boolean
Barry Warsaw3dd1c391998-10-22 04:14:24 +0000122
Barry Warsawa853adc1999-04-27 18:57:00 +0000123 wantspec
Barry Warsaweb6b9b71998-12-03 19:49:45 +0000124 When this is true, the "name" field in the return tuple
125 will always be a color spec of the form "#rrggbb". It
126 will not return a color name even if there is a match;
127 this is so pyColorChooser can exactly match the API of
128 tkColorChooser.
Barry Warsawcf1daad1998-10-22 19:00:38 +0000129
Barry Warsaweb6b9b71998-12-03 19:49:45 +0000130 [*] these arguments must be specified the first time
131 askcolor() is used and cannot be changed on subsequent calls.
Barry Warsawcf1daad1998-10-22 19:00:38 +0000132
Barry Warsaw3e481de2001-07-10 21:37:04 +0000133
Barry Warsaw3dd1c391998-10-22 04:14:24 +0000134The Colorstrip Window
135
136 The top part of the main Pynche window contains the "variation
137 strips". Each strip contains a number of "color chips". The
138 strips always indicate the currently selected color by a highlight
139 rectangle around the selected color chip, with an arrow pointing
140 to the chip. Each arrow has an associated number giving you the
141 color value along the variation's axis. Each variation strip
142 shows you the colors that are reachable from the selected color by
143 varying just one axis of the color solid.
144
145 For example, when the selected color is (in Red/Green/Blue
146 notation) 127/127/127, the Red Variations strip shows you every
147 color in the range 0/127/127 to 255/127/127. Similarly for the
148 green and blue axes. You can select any color by clicking on its
149 chip. This will update the highlight rectangle and the arrow, as
150 well as other displays in Pynche.
151
152 Click on "Update while dragging" if you want Pynche to update the
153 selected color while you drag along any variation strip (this will
Barry Warsaw3e481de2001-07-10 21:37:04 +0000154 be a bit slower). Click on "Hexadecimal" to display the arrow
155 numbers in hex.
Barry Warsaw3dd1c391998-10-22 04:14:24 +0000156
Barry Warsaw821d8b71999-04-26 23:46:25 +0000157 There are also two shortcut buttons in this window, which
158 auto-select Black (0/0/0) and White (255/255/255).
159
Barry Warsaw3e481de2001-07-10 21:37:04 +0000160
Barry Warsaw3dd1c391998-10-22 04:14:24 +0000161The Proof Window
162
163 In the lower left corner of the main window you see two larger
164 color chips. The Selected chip shows you a larger version of the
165 color selected in the variation strips, along with its X11 color
166 specification. The Nearest chip shows you the closest color in
167 the X11 database to the selected color, giving its X11 color name.
168 Clicking on the Nearest color chip selects that color. Color
169 distance is calculated in the 3D space of the RGB color solid and
170 if more than one color name is the same distance from the selected
171 color, the first one found will be chosen.
172
173 Note that there may be more than one X11 color name for the same
174 RGB value. In that case, the first one found in the text database
175 is designated the "primary" name, and this is shown under the
176 Nearest chip. The other names are "aliases" and they are visible
Barry Warsaw821d8b71999-04-26 23:46:25 +0000177 in the Color List Window (see below).
Barry Warsaw3dd1c391998-10-22 04:14:24 +0000178
Barry Warsaw3e481de2001-07-10 21:37:04 +0000179
Barry Warsaw3dd1c391998-10-22 04:14:24 +0000180The Type-in Window
181
182 At the lower right of the main window are three entry fields.
183 Here you can type numeric values for any of the three color axes.
184 Legal values are between 0 and 255, and these fields do not allow
185 you to enter illegal values. You must hit Enter or Tab to select
186 the new color.
187
188 Click on "Update while typing" if you want Pynche to select the
189 color on every keystroke (well, every one that produces a legal
190 value!) Click on "Hexadecimal" to display and enter color values
191 in hex.
192
Barry Warsaw3e481de2001-07-10 21:37:04 +0000193
Barry Warsaw3dd1c391998-10-22 04:14:24 +0000194Other Views
195
196 There are three secondary windows which are not displayed by
197 default. You can bring these up via the "View" menu on the main
198 Pynche window.
199
Barry Warsaw3e481de2001-07-10 21:37:04 +0000200
Barry Warsaw3dd1c391998-10-22 04:14:24 +0000201The Text Window
202
203 The "Text Window" allows you to see what effects various colors
204 have on the standard Tk text widget elements. In the upper part
205 of the window is a plain Tk text widget and here you can edit the
206 text, select a region of text, etc. Below this is a button "Track
207 color changes". When this is turned on, any colors selected in
208 the other windows will change the text widget element specified in
209 the radio buttons below. When this is turned off, text widget
210 elements are not affected by color selection.
211
212 You can choose which element gets changed by color selection by
213 clicking on one of the radio buttons in the bottom part of this
214 window. Text foreground and background affect the text in the
215 upper part of the window. Selection foreground and background
216 affect the colors of the primary selection which is what you see
217 when you click the middle button (depending on window system) and
218 drag it through some text.
219
220 The Insertion is the insertion cursor in the text window, where
221 new text will be inserted as you type. The insertion cursor only
222 has a background.
223
Barry Warsaw3e481de2001-07-10 21:37:04 +0000224
Barry Warsaw3dd1c391998-10-22 04:14:24 +0000225The Color List Window
226
Barry Warsaw821d8b71999-04-26 23:46:25 +0000227 The "Color List" window shows every named color in the color name
228 database (this window may take a while to come up). In the upper
229 part of the window you see a scrolling list of all the color names
230 in the database, in alphabetical order. Click on any color to
231 select it. In the bottom part of the window is displayed any
232 aliases for the selected color (those color names that have the
233 same RGB value, but were found later in the text database). For
234 example, find the color "Black" and you'll see that its aliases
235 are "gray0" and "grey0".
Barry Warsaw3dd1c391998-10-22 04:14:24 +0000236
237 If the color has no aliases you'll see "<no aliases>" here. If you
238 just want to see if a color has an alias, and do not want to select a
239 color when you click on it, turn off "Update on Click".
240
241 Note that the color list is always updated when a color is selected
242 from the main window. There's no way to turn this feature off. If
243 the selected color has no matching color name you'll see
244 "<no matching color>" in the Aliases window.
245
Barry Warsaw3e481de2001-07-10 21:37:04 +0000246
Barry Warsaw3dd1c391998-10-22 04:14:24 +0000247The Details Window
248
249 The "Details" window gives you more control over color selection
250 than just clicking on a color chip in the main window. The row of
251 buttons along the top apply the specified increment and decrement
252 amounts to the selected color. These delta amounts are applied to
253 the variation strips specified by the check boxes labeled "Move
254 Sliders". Thus if just Red and Green are selected, hitting -10
255 will subtract 10 from the color value along the red and green
256 variation only. Note the message under the checkboxes; this
257 indicates the primary color level being changed when more than one
258 slider is tied together. For example, if Red and Green are
259 selected, you will be changing the Yellow level of the selected
260 color.
261
262 The "At Boundary" behavior determines what happens when any color
263 variation hits either the lower or upper boundaries (0 or 255) as
264 a result of clicking on the top row buttons:
Barry Warsawe55055d1998-10-06 23:03:22 +0000265
266 Stop
267 When the increment or decrement would send any of the tied
268 variations out of bounds, the entire delta is discarded.
269
270 Wrap Around
271 When the increment or decrement would send any of the tied
272 variations out of bounds, the out of bounds value is wrapped
273 around to the other side. Thus if red were at 238 and +25
274 were clicked, red would have the value 7.
275
Barry Warsaw821d8b71999-04-26 23:46:25 +0000276 Preserve Distance
Barry Warsawe55055d1998-10-06 23:03:22 +0000277 When the increment or decrement would send any of the tied
278 variations out of bounds, all tied variations are wrapped as
279 one, so as to preserve the distance between them. Thus if
280 green and blue were tied, and green was at 238 while blue was
281 at 223, and +25 were clicked, green would be at 15 and blue
282 would be at 0.
283
284 Squash
285 When the increment or decrement would send any of the tied
286 variations out of bounds, the out of bounds variation is set
287 to the ceiling of 255 or floor of 0, as appropriate. In this
288 way, all tied variations are squashed to one edge or the
289 other.
290
Barry Warsaw3dd1c391998-10-22 04:14:24 +0000291 The top row buttons have the following keyboard accelerators:
Barry Warsawe55055d1998-10-06 23:03:22 +0000292
293 -25 == Shift Left Arrow
294 -10 == Control Left Arrow
295 -1 == Left Arrow
296 +1 == Right Arrow
297 +10 == Control Right Arrow
298 +25 == Shift Right Arrow
299
Barry Warsaw3e481de2001-07-10 21:37:04 +0000300
Barry Warsaw3dd1c391998-10-22 04:14:24 +0000301Keyboard Accelerators
Barry Warsawe55055d1998-10-06 23:03:22 +0000302
303 Alt-w in any secondary window dismisses the window. In the main
Barry Warsaw3dd1c391998-10-22 04:14:24 +0000304 window it exits Pynche (except when running as a modal).
Barry Warsawe55055d1998-10-06 23:03:22 +0000305
Barry Warsaw3dd1c391998-10-22 04:14:24 +0000306 Alt-q in any window exits Pynche (except when running as a modal).
307
Barry Warsaw3e481de2001-07-10 21:37:04 +0000308
Barry Warsaw3dd1c391998-10-22 04:14:24 +0000309Persistency
310
311 Pynche remembers various settings of options and colors between
312 invocations, storing these values in a `persistent initialization
313 file'. The actual location of this file is specified by the
314 --initfile option (see above), and defaults to ~/.pynche.
315
316 When Pynche exits, it saves these values in the init file, and
317 re-reads them when it starts up. There is no locking on this
318 file, so if you run multiple instances of Pynche at a time, you
Barry Warsaw821d8b71999-04-26 23:46:25 +0000319 may clobber the init file.
Barry Warsaw3dd1c391998-10-22 04:14:24 +0000320
321 The actual options stored include
322
323 - the currently selected color
324
325 - all settings of checkbox and radio button options in all windows
326
327 - the contents of the text window, the current text selection and
328 insertion point, and all current text widget element color
329 settings.
330
Barry Warsaw821d8b71999-04-26 23:46:25 +0000331 - the name of the color database file (but not its contents)
332
Barry Warsaw3dd1c391998-10-22 04:14:24 +0000333 You can inhibit Pynche from reading the init file by supplying the
334 --ignore option on the command line. However, you cannot suppress
335 the storing of the settings in the init file on Pynche exit. If
336 you really want to do this, use /dev/null as the init file, using
337 --initfile.
Barry Warsawcf1daad1998-10-22 19:00:38 +0000338
Barry Warsaw3e481de2001-07-10 21:37:04 +0000339
Barry Warsaw821d8b71999-04-26 23:46:25 +0000340Color Name Database Files
341
342 Pynche uses a color name database file to calculate the nearest
343 color to the selected color, and to display in the Color List
344 view. Several files are distributed with Pynche, described
345 below. By default, the X11 color name database file is selected.
346 Other files:
347
348 html40colors.txt -- the HTML 4.0 guaranteed color names
349
350 websafe.txt -- the 216 "Web-safe" colors that Netscape and MSIE
351 guarantee will not be dithered. These are specified in #rrggbb
352 format for both values and names
353
354 webcolors.txt -- The 140 color names that Tim Peters and his
355 sister say NS and MSIE both understand (with some controversy over
356 AliceBlue).
357
Barry Warsaw74109a11999-04-26 23:50:04 +0000358 namedcolors.txt -- an alternative set of Netscape colors.
359
Barry Warsawa25223f1999-04-26 23:48:17 +0000360 You can switch between files by choosing "Load palette..." from
361 the "File" menu. This brings up a standard Tk file dialog.
362 Choose the file you want and then click "Ok". If Pynche
363 understands the format in this file, it will load the database and
364 update the appropriate windows. If not, it will bring up an error
365 dialog.
366
Barry Warsaw3e481de2001-07-10 21:37:04 +0000367
Barry Warsawcf1daad1998-10-22 19:00:38 +0000368To Do
369
Barry Warsaw3e481de2001-07-10 21:37:04 +0000370 Here's a brief list of things I want to do (some mythical day):
Barry Warsawcf1daad1998-10-22 19:00:38 +0000371
372 - Better support for resizing the top level windows
373
Barry Warsawcf1daad1998-10-22 19:00:38 +0000374 - More output views, e.g. color solids
375
376 - Have the notion of a `last color selected'; this may require a
377 new output view
378
379 - Support setting the font in the text view
380
Barry Warsaw3e481de2001-07-10 21:37:04 +0000381 - Support distutils setup.py for installation
382
Barry Warsawcf1daad1998-10-22 19:00:38 +0000383 I'm open to suggestions!
Barry Warsaweb6b9b71998-12-03 19:49:45 +0000384
385
386
387Local Variables:
388indent-tabs-mode: nil
389End: