blob: 1042934a86bdd4569d9a5b83b5067db6a6785bc5 [file] [log] [blame]
Barry Warsawe55055d1998-10-06 23:03:22 +00001Pynche - The PYthonically Natural Color and Hue Editor
Barry Warsaweb6b9b7e1998-12-03 19:49:45 +00002
Barry Warsaw64039911998-12-15 01:02:51 +00003Contact: Barry A. Warsaw
Barry Warsaweb6b9b7e1998-12-03 19:49:45 +00004Email: bwarsaw@python.org
Barry Warsaw821d8b71999-04-26 23:46:25 +00005Version: 1.0
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 Warsaw821d8b71999-04-26 23:46:25 +000019 Pynche has been tested with Python 1.5.x using Tk 8.0.x. It
Barry Warsaw3dd1c391998-10-22 04:14:24 +000020 probably works with Python 1.5. I've tested it on both Solaris
21 2.6 and Windows NT. There are some funky things that happen on
22 Windows but I think they are primarily Tk problems. You'll want
Barry Warsaw821d8b71999-04-26 23:46:25 +000023 to be sure to have at least Tk 8.0.3 for Windows. Also, Pynche is
24 very colormap intensive, so it doesn't work very well on 8-bit
25 graphics cards. I'll probably fix that in the future.
Barry Warsawe55055d1998-10-06 23:03:22 +000026
Barry Warsaw821d8b71999-04-26 23:46:25 +000027 Pynche must find a text database of colors names in order to
28 provide `nearest' color matching. Pynche is distributed with an
29 rgb.txt file from the X11R6.4 distribution for this reason, along
30 with other "Web related" database (see below). You can use a
31 different file with the -d option. The file xlicense.txt contains
32 the license only for rgb.txt and both files are in the X/
33 subdirectory.
Barry Warsawe55055d1998-10-06 23:03:22 +000034
Barry Warsaw3dd1c391998-10-22 04:14:24 +000035 Pynche is pronounced `Pinch-ee'.
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 Warsaweb6b9b7e1998-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 Warsaweb6b9b7e1998-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 Warsaw3dd1c391998-10-22 04:14:24 +000070Running as a Modal Dialog
Barry Warsawe55055d1998-10-06 23:03:22 +000071
Barry Warsaw821d8b71999-04-26 23:46:25 +000072 Pynche can be run as a modal dialog, inside another application,
73 say as a general color chooser. In fact, Grail 0.6 already uses
74 Pynche and a future version of IDLE may as well. Pynche supports
75 the API implemented by the Tkinter standard tkColorChooser module,
76 with a few changes as described below. By importing pyColorChooser
77 from the Pynche package, you can run
Barry Warsawe55055d1998-10-06 23:03:22 +000078
Barry Warsawcf1daad1998-10-22 19:00:38 +000079 pyColorChooser.askcolor()
Barry Warsawe55055d1998-10-06 23:03:22 +000080
Barry Warsawcf1daad1998-10-22 19:00:38 +000081 which will popup Pynche as a modal dialog, and return the selected
82 color.
Barry Warsawe55055d1998-10-06 23:03:22 +000083
Barry Warsaw3dd1c391998-10-22 04:14:24 +000084 There are some UI differences when running as a modal
Barry Warsaw821d8b71999-04-26 23:46:25 +000085 vs. standalone. When running as a modal, there is no "Quit" menu
86 item under the "File" menu. Instead there are "Okay" and "Cancel"
87 buttons.
Barry Warsawe55055d1998-10-06 23:03:22 +000088
Barry Warsaw3dd1c391998-10-22 04:14:24 +000089 When "Okay" is hit, askcolor() returns the tuple
Barry Warsawe55055d1998-10-06 23:03:22 +000090
Barry Warsaweb6b9b7e1998-12-03 19:49:45 +000091 ((r, g, b), "name")
Barry Warsawe55055d1998-10-06 23:03:22 +000092
Barry Warsaw3dd1c391998-10-22 04:14:24 +000093 where r, g, and b are red, green, and blue color values
94 respectively (in the range 0 to 255). "name" will be a color name
95 from the color database if there is an exact match, otherwise it
96 will be an X11 color spec of the form "#rrggbb". Note that this
97 is different than tkColorChooser, which doesn't know anything
98 about color names.
99
Barry Warsawcf1daad1998-10-22 19:00:38 +0000100 askcolor() supports the following optional keyword arguments:
Barry Warsaw3dd1c391998-10-22 04:14:24 +0000101
Barry Warsaweb6b9b7e1998-12-03 19:49:45 +0000102 color
103 the color to set as the initial selected color
Barry Warsaw3dd1c391998-10-22 04:14:24 +0000104
Barry Warsaweb6b9b7e1998-12-03 19:49:45 +0000105 master[*]
106 the master window to use as the parent of the modal
107 dialog. Without this argument, pyColorChooser will create
108 it's own Tkinter.Tk instance as the master. This may not
109 be what you want.
Barry Warsaw3dd1c391998-10-22 04:14:24 +0000110
Barry Warsawa853adc1999-04-27 18:57:00 +0000111 databasefile
Barry Warsaweb6b9b7e1998-12-03 19:49:45 +0000112 similar to the --database option, the value must be a
113 file name
Barry Warsaw3dd1c391998-10-22 04:14:24 +0000114
Barry Warsaweb6b9b7e1998-12-03 19:49:45 +0000115 initfile[*]
116 similar to the --initfile option, the value must be a
117 file name
Barry Warsaw3dd1c391998-10-22 04:14:24 +0000118
Barry Warsaweb6b9b7e1998-12-03 19:49:45 +0000119 ignore[*]
120 similar to the --ignore flag, the value is a boolean
Barry Warsaw3dd1c391998-10-22 04:14:24 +0000121
Barry Warsawa853adc1999-04-27 18:57:00 +0000122 wantspec
Barry Warsaweb6b9b7e1998-12-03 19:49:45 +0000123 When this is true, the "name" field in the return tuple
124 will always be a color spec of the form "#rrggbb". It
125 will not return a color name even if there is a match;
126 this is so pyColorChooser can exactly match the API of
127 tkColorChooser.
Barry Warsawcf1daad1998-10-22 19:00:38 +0000128
Barry Warsaweb6b9b7e1998-12-03 19:49:45 +0000129 [*] these arguments must be specified the first time
130 askcolor() is used and cannot be changed on subsequent calls.
Barry Warsawcf1daad1998-10-22 19:00:38 +0000131
Barry Warsaw3dd1c391998-10-22 04:14:24 +0000132The Colorstrip Window
133
134 The top part of the main Pynche window contains the "variation
135 strips". Each strip contains a number of "color chips". The
136 strips always indicate the currently selected color by a highlight
137 rectangle around the selected color chip, with an arrow pointing
138 to the chip. Each arrow has an associated number giving you the
139 color value along the variation's axis. Each variation strip
140 shows you the colors that are reachable from the selected color by
141 varying just one axis of the color solid.
142
143 For example, when the selected color is (in Red/Green/Blue
144 notation) 127/127/127, the Red Variations strip shows you every
145 color in the range 0/127/127 to 255/127/127. Similarly for the
146 green and blue axes. You can select any color by clicking on its
147 chip. This will update the highlight rectangle and the arrow, as
148 well as other displays in Pynche.
149
150 Click on "Update while dragging" if you want Pynche to update the
151 selected color while you drag along any variation strip (this will
152 be slower). Click on "Hexadecimal" to display the arrow numbers
153 in hex.
154
Barry Warsaw821d8b71999-04-26 23:46:25 +0000155 There are also two shortcut buttons in this window, which
156 auto-select Black (0/0/0) and White (255/255/255).
157
Barry Warsaw3dd1c391998-10-22 04:14:24 +0000158The Proof Window
159
160 In the lower left corner of the main window you see two larger
161 color chips. The Selected chip shows you a larger version of the
162 color selected in the variation strips, along with its X11 color
163 specification. The Nearest chip shows you the closest color in
164 the X11 database to the selected color, giving its X11 color name.
165 Clicking on the Nearest color chip selects that color. Color
166 distance is calculated in the 3D space of the RGB color solid and
167 if more than one color name is the same distance from the selected
168 color, the first one found will be chosen.
169
170 Note that there may be more than one X11 color name for the same
171 RGB value. In that case, the first one found in the text database
172 is designated the "primary" name, and this is shown under the
173 Nearest chip. The other names are "aliases" and they are visible
Barry Warsaw821d8b71999-04-26 23:46:25 +0000174 in the Color List Window (see below).
Barry Warsaw3dd1c391998-10-22 04:14:24 +0000175
176The Type-in Window
177
178 At the lower right of the main window are three entry fields.
179 Here you can type numeric values for any of the three color axes.
180 Legal values are between 0 and 255, and these fields do not allow
181 you to enter illegal values. You must hit Enter or Tab to select
182 the new color.
183
184 Click on "Update while typing" if you want Pynche to select the
185 color on every keystroke (well, every one that produces a legal
186 value!) Click on "Hexadecimal" to display and enter color values
187 in hex.
188
189Other Views
190
191 There are three secondary windows which are not displayed by
192 default. You can bring these up via the "View" menu on the main
193 Pynche window.
194
195The Text Window
196
197 The "Text Window" allows you to see what effects various colors
198 have on the standard Tk text widget elements. In the upper part
199 of the window is a plain Tk text widget and here you can edit the
200 text, select a region of text, etc. Below this is a button "Track
201 color changes". When this is turned on, any colors selected in
202 the other windows will change the text widget element specified in
203 the radio buttons below. When this is turned off, text widget
204 elements are not affected by color selection.
205
206 You can choose which element gets changed by color selection by
207 clicking on one of the radio buttons in the bottom part of this
208 window. Text foreground and background affect the text in the
209 upper part of the window. Selection foreground and background
210 affect the colors of the primary selection which is what you see
211 when you click the middle button (depending on window system) and
212 drag it through some text.
213
214 The Insertion is the insertion cursor in the text window, where
215 new text will be inserted as you type. The insertion cursor only
216 has a background.
217
218The Color List Window
219
Barry Warsaw821d8b71999-04-26 23:46:25 +0000220 The "Color List" window shows every named color in the color name
221 database (this window may take a while to come up). In the upper
222 part of the window you see a scrolling list of all the color names
223 in the database, in alphabetical order. Click on any color to
224 select it. In the bottom part of the window is displayed any
225 aliases for the selected color (those color names that have the
226 same RGB value, but were found later in the text database). For
227 example, find the color "Black" and you'll see that its aliases
228 are "gray0" and "grey0".
Barry Warsaw3dd1c391998-10-22 04:14:24 +0000229
230 If the color has no aliases you'll see "<no aliases>" here. If you
231 just want to see if a color has an alias, and do not want to select a
232 color when you click on it, turn off "Update on Click".
233
234 Note that the color list is always updated when a color is selected
235 from the main window. There's no way to turn this feature off. If
236 the selected color has no matching color name you'll see
237 "<no matching color>" in the Aliases window.
238
239The Details Window
240
241 The "Details" window gives you more control over color selection
242 than just clicking on a color chip in the main window. The row of
243 buttons along the top apply the specified increment and decrement
244 amounts to the selected color. These delta amounts are applied to
245 the variation strips specified by the check boxes labeled "Move
246 Sliders". Thus if just Red and Green are selected, hitting -10
247 will subtract 10 from the color value along the red and green
248 variation only. Note the message under the checkboxes; this
249 indicates the primary color level being changed when more than one
250 slider is tied together. For example, if Red and Green are
251 selected, you will be changing the Yellow level of the selected
252 color.
253
254 The "At Boundary" behavior determines what happens when any color
255 variation hits either the lower or upper boundaries (0 or 255) as
256 a result of clicking on the top row buttons:
Barry Warsawe55055d1998-10-06 23:03:22 +0000257
258 Stop
259 When the increment or decrement would send any of the tied
260 variations out of bounds, the entire delta is discarded.
261
262 Wrap Around
263 When the increment or decrement would send any of the tied
264 variations out of bounds, the out of bounds value is wrapped
265 around to the other side. Thus if red were at 238 and +25
266 were clicked, red would have the value 7.
267
Barry Warsaw821d8b71999-04-26 23:46:25 +0000268 Preserve Distance
Barry Warsawe55055d1998-10-06 23:03:22 +0000269 When the increment or decrement would send any of the tied
270 variations out of bounds, all tied variations are wrapped as
271 one, so as to preserve the distance between them. Thus if
272 green and blue were tied, and green was at 238 while blue was
273 at 223, and +25 were clicked, green would be at 15 and blue
274 would be at 0.
275
276 Squash
277 When the increment or decrement would send any of the tied
278 variations out of bounds, the out of bounds variation is set
279 to the ceiling of 255 or floor of 0, as appropriate. In this
280 way, all tied variations are squashed to one edge or the
281 other.
282
Barry Warsaw3dd1c391998-10-22 04:14:24 +0000283 The top row buttons have the following keyboard accelerators:
Barry Warsawe55055d1998-10-06 23:03:22 +0000284
285 -25 == Shift Left Arrow
286 -10 == Control Left Arrow
287 -1 == Left Arrow
288 +1 == Right Arrow
289 +10 == Control Right Arrow
290 +25 == Shift Right Arrow
291
Barry Warsaw3dd1c391998-10-22 04:14:24 +0000292Keyboard Accelerators
Barry Warsawe55055d1998-10-06 23:03:22 +0000293
294 Alt-w in any secondary window dismisses the window. In the main
Barry Warsaw3dd1c391998-10-22 04:14:24 +0000295 window it exits Pynche (except when running as a modal).
Barry Warsawe55055d1998-10-06 23:03:22 +0000296
Barry Warsaw3dd1c391998-10-22 04:14:24 +0000297 Alt-q in any window exits Pynche (except when running as a modal).
298
299Persistency
300
301 Pynche remembers various settings of options and colors between
302 invocations, storing these values in a `persistent initialization
303 file'. The actual location of this file is specified by the
304 --initfile option (see above), and defaults to ~/.pynche.
305
306 When Pynche exits, it saves these values in the init file, and
307 re-reads them when it starts up. There is no locking on this
308 file, so if you run multiple instances of Pynche at a time, you
Barry Warsaw821d8b71999-04-26 23:46:25 +0000309 may clobber the init file.
Barry Warsaw3dd1c391998-10-22 04:14:24 +0000310
311 The actual options stored include
312
313 - the currently selected color
314
315 - all settings of checkbox and radio button options in all windows
316
317 - the contents of the text window, the current text selection and
318 insertion point, and all current text widget element color
319 settings.
320
Barry Warsaw821d8b71999-04-26 23:46:25 +0000321 - the name of the color database file (but not its contents)
322
Barry Warsaw3dd1c391998-10-22 04:14:24 +0000323 You can inhibit Pynche from reading the init file by supplying the
324 --ignore option on the command line. However, you cannot suppress
325 the storing of the settings in the init file on Pynche exit. If
326 you really want to do this, use /dev/null as the init file, using
327 --initfile.
Barry Warsawcf1daad1998-10-22 19:00:38 +0000328
Barry Warsaw821d8b71999-04-26 23:46:25 +0000329Color Name Database Files
330
331 Pynche uses a color name database file to calculate the nearest
332 color to the selected color, and to display in the Color List
333 view. Several files are distributed with Pynche, described
334 below. By default, the X11 color name database file is selected.
335 Other files:
336
337 html40colors.txt -- the HTML 4.0 guaranteed color names
338
339 websafe.txt -- the 216 "Web-safe" colors that Netscape and MSIE
340 guarantee will not be dithered. These are specified in #rrggbb
341 format for both values and names
342
343 webcolors.txt -- The 140 color names that Tim Peters and his
344 sister say NS and MSIE both understand (with some controversy over
345 AliceBlue).
346
Barry Warsaw74109a11999-04-26 23:50:04 +0000347 namedcolors.txt -- an alternative set of Netscape colors.
348
Barry Warsawa25223f1999-04-26 23:48:17 +0000349 You can switch between files by choosing "Load palette..." from
350 the "File" menu. This brings up a standard Tk file dialog.
351 Choose the file you want and then click "Ok". If Pynche
352 understands the format in this file, it will load the database and
353 update the appropriate windows. If not, it will bring up an error
354 dialog.
355
Barry Warsawcf1daad1998-10-22 19:00:38 +0000356To Do
357
358 Here's a brief list of things I want to do:
359
360 - Better support for resizing the top level windows
361
362 - Better support on 8-bit screens
363
364 - More output views, e.g. color solids
365
366 - Have the notion of a `last color selected'; this may require a
367 new output view
368
369 - Support setting the font in the text view
370
371 I'm open to suggestions!
Barry Warsaweb6b9b7e1998-12-03 19:49:45 +0000372
373
374
375Local Variables:
376indent-tabs-mode: nil
377End: