blob: c74332afce34af20153a81c054daf60bcea51dd5 [file] [log] [blame]
Barry Warsawe55055d1998-10-06 23:03:22 +00001Pynche - The PYthonically Natural Color and Hue Editor
Barry Warsawe55055d1998-10-06 23:03:22 +00002Author: Barry A. Warsaw <bwarsaw@python.org>
3
Barry Warsaw3dd1c391998-10-22 04:14:24 +00004Introduction
Barry Warsawe55055d1998-10-06 23:03:22 +00005
Barry Warsaw3dd1c391998-10-22 04:14:24 +00006 Pynche is a color editor based largely on a similar program that I
7 originally wrote back in 1987 for the Sunview window system. That
8 editor was called ICE, the Interactive Color Editor. I'd always
9 wanted to port this program to X but didn't feel like hacking X
10 and C code to do it. Fast forward many years, to where Python +
11 Tkinter provides such a nice programming environment, with enough
12 power, that I finally buckled down and re-implemented it. I
13 changed the name because these days, too many other systems have
14 the acronym `ICE'.
Barry Warsawe55055d1998-10-06 23:03:22 +000015
Barry Warsaw3dd1c391998-10-22 04:14:24 +000016 Pynche has been tested with Python 1.5.1 using Tk 8.0. It
17 probably works with Python 1.5. I've tested it on both Solaris
18 2.6 and Windows NT. There are some funky things that happen on
19 Windows but I think they are primarily Tk problems. You'll want
20 to be sure to have Tk 8.0.3 for Windows. Also, Pynche is very
21 colormap intensive, so it doesn't work very well on 8-bit graphics
22 cards. I'll probably fix that in the future.
Barry Warsawe55055d1998-10-06 23:03:22 +000023
Barry Warsaw3dd1c391998-10-22 04:14:24 +000024 Pynche must find a text database of colors, in the X11 format.
25 Pynche is distributed with an rgb.txt file from the X11R6.4
26 distribution for this reason, but you can use a different file
27 with the -d option. The file xlicense.txt contains the license
28 only for rgb.txt and both files are in the X/ subdirectory.
Barry Warsawe55055d1998-10-06 23:03:22 +000029
Barry Warsaw3dd1c391998-10-22 04:14:24 +000030 Pynche is pronounced `Pinch-ee'.
Barry Warsawe55055d1998-10-06 23:03:22 +000031
Barry Warsaw3dd1c391998-10-22 04:14:24 +000032Running Standalone
Barry Warsawe55055d1998-10-06 23:03:22 +000033
Barry Warsaw3dd1c391998-10-22 04:14:24 +000034 On Unix, start it by running the `pynche' script. On Windows, run
35 pynche.pyw to inhibit the console window. When run from the
36 command line, the following options are recognized:
Barry Warsawe55055d1998-10-06 23:03:22 +000037
Barry Warsaw3dd1c391998-10-22 04:14:24 +000038 --database file
39 -d file
40 Alternate location of the color database file. Without this
41 option, the first of /usr/openwin/lib/rgb.txt or X/rgb.txt
42 will be used.
Barry Warsawe55055d1998-10-06 23:03:22 +000043
Barry Warsaw3dd1c391998-10-22 04:14:24 +000044 --initfile file
45 -i file
46 Alternate location of the persistent initialization file. See
47 the section on Persistency below.
Barry Warsawe55055d1998-10-06 23:03:22 +000048
Barry Warsaw3dd1c391998-10-22 04:14:24 +000049 --ignore
50 -X
51 Ignore the persistent initialization file when starting up.
52 Pynche will still write the current option settings to the
53 persistent init file when it quits.
Barry Warsawe55055d1998-10-06 23:03:22 +000054
Barry Warsaw3dd1c391998-10-22 04:14:24 +000055 --help
56 -h
57 Print the help message.
Barry Warsawe55055d1998-10-06 23:03:22 +000058
Barry Warsaw3dd1c391998-10-22 04:14:24 +000059 initialcolor
60 a Tk color name or #rrggbb color spec to be used as the
61 initially selected color. This overrides any color saved in
62 the persistent init file. Since `#' needs to be escaped in
63 many shells, it is optional in the spec (e.g. #45dd1f is the
64 same as 45dd1f).
Barry Warsawe55055d1998-10-06 23:03:22 +000065
Barry Warsaw3dd1c391998-10-22 04:14:24 +000066Running as a Modal Dialog
Barry Warsawe55055d1998-10-06 23:03:22 +000067
Barry Warsaw3dd1c391998-10-22 04:14:24 +000068 Pynche can be run as a modal dialog, inside another application.
69 It supports the API implemented by the Tkinter standard
70 tkColorChooser module, with a few changes. By importing
71 pyColorChooser from the Pynche package, you can run
Barry Warsawe55055d1998-10-06 23:03:22 +000072
Barry Warsawcf1daad1998-10-22 19:00:38 +000073 pyColorChooser.askcolor()
Barry Warsawe55055d1998-10-06 23:03:22 +000074
Barry Warsawcf1daad1998-10-22 19:00:38 +000075 which will popup Pynche as a modal dialog, and return the selected
76 color.
Barry Warsawe55055d1998-10-06 23:03:22 +000077
Barry Warsaw3dd1c391998-10-22 04:14:24 +000078 There are some UI differences when running as a modal
79 vs. standalone. When running as a modal, there is no "File" menu,
80 but instead there are "Okay" and "Cancel" buttons.
Barry Warsawe55055d1998-10-06 23:03:22 +000081
Barry Warsaw3dd1c391998-10-22 04:14:24 +000082 When "Okay" is hit, askcolor() returns the tuple
Barry Warsawe55055d1998-10-06 23:03:22 +000083
Barry Warsaw3dd1c391998-10-22 04:14:24 +000084 ((r, g, b), "name")
Barry Warsawe55055d1998-10-06 23:03:22 +000085
Barry Warsaw3dd1c391998-10-22 04:14:24 +000086 where r, g, and b are red, green, and blue color values
87 respectively (in the range 0 to 255). "name" will be a color name
88 from the color database if there is an exact match, otherwise it
89 will be an X11 color spec of the form "#rrggbb". Note that this
90 is different than tkColorChooser, which doesn't know anything
91 about color names.
92
Barry Warsawcf1daad1998-10-22 19:00:38 +000093 askcolor() supports the following optional keyword arguments:
Barry Warsaw3dd1c391998-10-22 04:14:24 +000094
Barry Warsawcf1daad1998-10-22 19:00:38 +000095 color
96 the color to set as the initial selected color
Barry Warsaw3dd1c391998-10-22 04:14:24 +000097
Barry Warsawcf1daad1998-10-22 19:00:38 +000098 master[*]
99 the master window to use as the parent of the modal
100 dialog. Without this argument, pyColorChooser will create
101 it's own Tkinter.Tk instance as the master. This may not
102 be what you want.
Barry Warsaw3dd1c391998-10-22 04:14:24 +0000103
Barry Warsawcf1daad1998-10-22 19:00:38 +0000104 databasefile[*]
Barry Warsaw3dd1c391998-10-22 04:14:24 +0000105 similar to the --database option, the value must be a
106 file name
107
Barry Warsawcf1daad1998-10-22 19:00:38 +0000108 initfile[*]
Barry Warsaw3dd1c391998-10-22 04:14:24 +0000109 similar to the --initfile option, the value must be a
110 file name
111
Barry Warsawcf1daad1998-10-22 19:00:38 +0000112 ignore[*]
Barry Warsaw3dd1c391998-10-22 04:14:24 +0000113 similar to the --ignore flag, the value is a boolean
114
Barry Warsawcf1daad1998-10-22 19:00:38 +0000115 wantspec[*]
116 When this is true, the "name" field in the return tuple
117 will always be a color spec of the form "#rrggbb". It
118 will not return a color name even if there is a match;
119 this is so pyColorChooser can exactly match the API of
120 tkColorChooser.
121
122 [*] these arguments must be specified the first time
123 askcolor() is used and cannot be changed on subsequent calls.
124
Barry Warsaw3dd1c391998-10-22 04:14:24 +0000125The Colorstrip Window
126
127 The top part of the main Pynche window contains the "variation
128 strips". Each strip contains a number of "color chips". The
129 strips always indicate the currently selected color by a highlight
130 rectangle around the selected color chip, with an arrow pointing
131 to the chip. Each arrow has an associated number giving you the
132 color value along the variation's axis. Each variation strip
133 shows you the colors that are reachable from the selected color by
134 varying just one axis of the color solid.
135
136 For example, when the selected color is (in Red/Green/Blue
137 notation) 127/127/127, the Red Variations strip shows you every
138 color in the range 0/127/127 to 255/127/127. Similarly for the
139 green and blue axes. You can select any color by clicking on its
140 chip. This will update the highlight rectangle and the arrow, as
141 well as other displays in Pynche.
142
143 Click on "Update while dragging" if you want Pynche to update the
144 selected color while you drag along any variation strip (this will
145 be slower). Click on "Hexadecimal" to display the arrow numbers
146 in hex.
147
148The Proof Window
149
150 In the lower left corner of the main window you see two larger
151 color chips. The Selected chip shows you a larger version of the
152 color selected in the variation strips, along with its X11 color
153 specification. The Nearest chip shows you the closest color in
154 the X11 database to the selected color, giving its X11 color name.
155 Clicking on the Nearest color chip selects that color. Color
156 distance is calculated in the 3D space of the RGB color solid and
157 if more than one color name is the same distance from the selected
158 color, the first one found will be chosen.
159
160 Note that there may be more than one X11 color name for the same
161 RGB value. In that case, the first one found in the text database
162 is designated the "primary" name, and this is shown under the
163 Nearest chip. The other names are "aliases" and they are visible
164 in other Pynche windows.
165
166The Type-in Window
167
168 At the lower right of the main window are three entry fields.
169 Here you can type numeric values for any of the three color axes.
170 Legal values are between 0 and 255, and these fields do not allow
171 you to enter illegal values. You must hit Enter or Tab to select
172 the new color.
173
174 Click on "Update while typing" if you want Pynche to select the
175 color on every keystroke (well, every one that produces a legal
176 value!) Click on "Hexadecimal" to display and enter color values
177 in hex.
178
179Other Views
180
181 There are three secondary windows which are not displayed by
182 default. You can bring these up via the "View" menu on the main
183 Pynche window.
184
185The Text Window
186
187 The "Text Window" allows you to see what effects various colors
188 have on the standard Tk text widget elements. In the upper part
189 of the window is a plain Tk text widget and here you can edit the
190 text, select a region of text, etc. Below this is a button "Track
191 color changes". When this is turned on, any colors selected in
192 the other windows will change the text widget element specified in
193 the radio buttons below. When this is turned off, text widget
194 elements are not affected by color selection.
195
196 You can choose which element gets changed by color selection by
197 clicking on one of the radio buttons in the bottom part of this
198 window. Text foreground and background affect the text in the
199 upper part of the window. Selection foreground and background
200 affect the colors of the primary selection which is what you see
201 when you click the middle button (depending on window system) and
202 drag it through some text.
203
204 The Insertion is the insertion cursor in the text window, where
205 new text will be inserted as you type. The insertion cursor only
206 has a background.
207
208The Color List Window
209
210 The "Color List" window shows every color in the text database
211 (this window may take a while to come up). In the upper part of
212 the window you see a scrolling list of all the color names in the
213 database, in alphabetical order. Click on any color to select it.
214 In the bottom part of the window is displayed any aliases for the
215 selected color (those color names that have the same RGB value,
216 but were found later in the text database). For example, find the
217 color "Black" and you'll see that its aliases are "gray0" and
218 "grey0".
219
220 If the color has no aliases you'll see "<no aliases>" here. If you
221 just want to see if a color has an alias, and do not want to select a
222 color when you click on it, turn off "Update on Click".
223
224 Note that the color list is always updated when a color is selected
225 from the main window. There's no way to turn this feature off. If
226 the selected color has no matching color name you'll see
227 "<no matching color>" in the Aliases window.
228
229The Details Window
230
231 The "Details" window gives you more control over color selection
232 than just clicking on a color chip in the main window. The row of
233 buttons along the top apply the specified increment and decrement
234 amounts to the selected color. These delta amounts are applied to
235 the variation strips specified by the check boxes labeled "Move
236 Sliders". Thus if just Red and Green are selected, hitting -10
237 will subtract 10 from the color value along the red and green
238 variation only. Note the message under the checkboxes; this
239 indicates the primary color level being changed when more than one
240 slider is tied together. For example, if Red and Green are
241 selected, you will be changing the Yellow level of the selected
242 color.
243
244 The "At Boundary" behavior determines what happens when any color
245 variation hits either the lower or upper boundaries (0 or 255) as
246 a result of clicking on the top row buttons:
Barry Warsawe55055d1998-10-06 23:03:22 +0000247
248 Stop
249 When the increment or decrement would send any of the tied
250 variations out of bounds, the entire delta is discarded.
251
252 Wrap Around
253 When the increment or decrement would send any of the tied
254 variations out of bounds, the out of bounds value is wrapped
255 around to the other side. Thus if red were at 238 and +25
256 were clicked, red would have the value 7.
257
258 Preseve Distance
259 When the increment or decrement would send any of the tied
260 variations out of bounds, all tied variations are wrapped as
261 one, so as to preserve the distance between them. Thus if
262 green and blue were tied, and green was at 238 while blue was
263 at 223, and +25 were clicked, green would be at 15 and blue
264 would be at 0.
265
266 Squash
267 When the increment or decrement would send any of the tied
268 variations out of bounds, the out of bounds variation is set
269 to the ceiling of 255 or floor of 0, as appropriate. In this
270 way, all tied variations are squashed to one edge or the
271 other.
272
Barry Warsaw3dd1c391998-10-22 04:14:24 +0000273 The top row buttons have the following keyboard accelerators:
Barry Warsawe55055d1998-10-06 23:03:22 +0000274
275 -25 == Shift Left Arrow
276 -10 == Control Left Arrow
277 -1 == Left Arrow
278 +1 == Right Arrow
279 +10 == Control Right Arrow
280 +25 == Shift Right Arrow
281
Barry Warsaw3dd1c391998-10-22 04:14:24 +0000282Keyboard Accelerators
Barry Warsawe55055d1998-10-06 23:03:22 +0000283
284 Alt-w in any secondary window dismisses the window. In the main
Barry Warsaw3dd1c391998-10-22 04:14:24 +0000285 window it exits Pynche (except when running as a modal).
Barry Warsawe55055d1998-10-06 23:03:22 +0000286
Barry Warsaw3dd1c391998-10-22 04:14:24 +0000287 Alt-q in any window exits Pynche (except when running as a modal).
288
289Persistency
290
291 Pynche remembers various settings of options and colors between
292 invocations, storing these values in a `persistent initialization
293 file'. The actual location of this file is specified by the
294 --initfile option (see above), and defaults to ~/.pynche.
295
296 When Pynche exits, it saves these values in the init file, and
297 re-reads them when it starts up. There is no locking on this
298 file, so if you run multiple instances of Pynche at a time, you
299 will override the init file.
300
301 The actual options stored include
302
303 - the currently selected color
304
305 - all settings of checkbox and radio button options in all windows
306
307 - the contents of the text window, the current text selection and
308 insertion point, and all current text widget element color
309 settings.
310
311 You can inhibit Pynche from reading the init file by supplying the
312 --ignore option on the command line. However, you cannot suppress
313 the storing of the settings in the init file on Pynche exit. If
314 you really want to do this, use /dev/null as the init file, using
315 --initfile.
Barry Warsawcf1daad1998-10-22 19:00:38 +0000316
317To Do
318
319 Here's a brief list of things I want to do:
320
321 - Better support for resizing the top level windows
322
323 - Better support on 8-bit screens
324
325 - More output views, e.g. color solids
326
327 - Have the notion of a `last color selected'; this may require a
328 new output view
329
330 - Support setting the font in the text view
331
332 I'm open to suggestions!