| 1 | Pynche - The PYthonically Natural Color and Hue Editor
|
|---|
| 2 |
|
|---|
| 3 | Contact: Barry A. Warsaw
|
|---|
| 4 | Email: [email protected]
|
|---|
| 5 | Version: 1.3
|
|---|
| 6 |
|
|---|
| 7 | Introduction
|
|---|
| 8 |
|
|---|
| 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'.
|
|---|
| 18 |
|
|---|
| 19 | Pynche should work with any variant of Python after 1.5.2
|
|---|
| 20 | (e.g. 2.0.1 and 2.1.1), using Tk 8.0.x. It's been tested on
|
|---|
| 21 | Solaris 2.6, Windows NT 4, and various Linux distros. You'll want
|
|---|
| 22 | to be sure to have at least Tk 8.0.3 for Windows. Also, Pynche is
|
|---|
| 23 | very colormap intensive, so it doesn't work very well on 8-bit
|
|---|
| 24 | graphics cards; 24bit+ graphics cards are so cheap these days,
|
|---|
| 25 | I'll probably never "fix" that.
|
|---|
| 26 |
|
|---|
| 27 | 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.
|
|---|
| 34 |
|
|---|
| 35 | Pynche is pronounced: Pin'-chee
|
|---|
| 36 |
|
|---|
| 37 |
|
|---|
| 38 | Running Standalone
|
|---|
| 39 |
|
|---|
| 40 | On Unix, start it by running the `pynche' script. On Windows, run
|
|---|
| 41 | pynche.pyw to inhibit the console window. When run from the
|
|---|
| 42 | command line, the following options are recognized:
|
|---|
| 43 |
|
|---|
| 44 | --database file
|
|---|
| 45 | -d file
|
|---|
| 46 | Alternate location of the color database file. Without this
|
|---|
| 47 | option, the first valid file found will be used (see below).
|
|---|
| 48 |
|
|---|
| 49 | --initfile file
|
|---|
| 50 | -i file
|
|---|
| 51 | Alternate location of the persistent initialization file. See
|
|---|
| 52 | the section on Persistency below.
|
|---|
| 53 |
|
|---|
| 54 | --ignore
|
|---|
| 55 | -X
|
|---|
| 56 | Ignore the persistent initialization file when starting up.
|
|---|
| 57 | Pynche will still write the current option settings to the
|
|---|
| 58 | persistent init file when it quits.
|
|---|
| 59 |
|
|---|
| 60 | --help
|
|---|
| 61 | -h
|
|---|
| 62 | Print the help message.
|
|---|
| 63 |
|
|---|
| 64 | initialcolor
|
|---|
| 65 | a Tk color name or #rrggbb color spec to be used as the
|
|---|
| 66 | initially selected color. This overrides any color saved in
|
|---|
| 67 | the persistent init file. Since `#' needs to be escaped in
|
|---|
| 68 | many shells, it is optional in the spec (e.g. #45dd1f is the
|
|---|
| 69 | same as 45dd1f).
|
|---|
| 70 |
|
|---|
| 71 |
|
|---|
| 72 | Running as a Modal Dialog
|
|---|
| 73 |
|
|---|
| 74 | Pynche can be run as a modal dialog, inside another application,
|
|---|
| 75 | say as a general color chooser. In fact, Grail 0.6 uses Pynche
|
|---|
| 76 | and a future version of IDLE may as well. Pynche supports the API
|
|---|
| 77 | implemented by the Tkinter standard tkColorChooser module, with a
|
|---|
| 78 | few changes as described below. By importing pyColorChooser from
|
|---|
| 79 | the Pynche package, you can run
|
|---|
| 80 |
|
|---|
| 81 | pyColorChooser.askcolor()
|
|---|
| 82 |
|
|---|
| 83 | which will popup Pynche as a modal dialog, and return the selected
|
|---|
| 84 | color.
|
|---|
| 85 |
|
|---|
| 86 | There are some UI differences when running as a modal
|
|---|
| 87 | vs. standalone. When running as a modal, there is no "Quit" menu
|
|---|
| 88 | item under the "File" menu. Instead there are "Okay" and "Cancel"
|
|---|
| 89 | buttons.
|
|---|
| 90 |
|
|---|
| 91 | When "Okay" is hit, askcolor() returns the tuple
|
|---|
| 92 |
|
|---|
| 93 | ((r, g, b), "name")
|
|---|
| 94 |
|
|---|
| 95 | where r, g, and b are red, green, and blue color values
|
|---|
| 96 | respectively (in the range 0 to 255). "name" will be a color name
|
|---|
| 97 | from the color database if there is an exact match, otherwise it
|
|---|
| 98 | will be an X11 color spec of the form "#rrggbb". Note that this
|
|---|
| 99 | is different than tkColorChooser, which doesn't know anything
|
|---|
| 100 | about color names.
|
|---|
| 101 |
|
|---|
| 102 | askcolor() supports the following optional keyword arguments:
|
|---|
| 103 |
|
|---|
| 104 | color
|
|---|
| 105 | the color to set as the initial selected color
|
|---|
| 106 |
|
|---|
| 107 | master[*]
|
|---|
| 108 | the master window to use as the parent of the modal
|
|---|
| 109 | dialog. Without this argument, pyColorChooser will create
|
|---|
| 110 | its own Tkinter.Tk instance as the master. This may not
|
|---|
| 111 | be what you want.
|
|---|
| 112 |
|
|---|
| 113 | databasefile
|
|---|
| 114 | similar to the --database option, the value must be a
|
|---|
| 115 | file name
|
|---|
| 116 |
|
|---|
| 117 | initfile[*]
|
|---|
| 118 | similar to the --initfile option, the value must be a
|
|---|
| 119 | file name
|
|---|
| 120 |
|
|---|
| 121 | ignore[*]
|
|---|
| 122 | similar to the --ignore flag, the value is a boolean
|
|---|
| 123 |
|
|---|
| 124 | wantspec
|
|---|
| 125 | When this is true, the "name" field in the return tuple
|
|---|
| 126 | will always be a color spec of the form "#rrggbb". It
|
|---|
| 127 | will not return a color name even if there is a match;
|
|---|
| 128 | this is so pyColorChooser can exactly match the API of
|
|---|
| 129 | tkColorChooser.
|
|---|
| 130 |
|
|---|
| 131 | [*] these arguments must be specified the first time
|
|---|
| 132 | askcolor() is used and cannot be changed on subsequent calls.
|
|---|
| 133 |
|
|---|
| 134 |
|
|---|
| 135 | The Colorstrip Window
|
|---|
| 136 |
|
|---|
| 137 | The top part of the main Pynche window contains the "variation
|
|---|
| 138 | strips". Each strip contains a number of "color chips". The
|
|---|
| 139 | strips always indicate the currently selected color by a highlight
|
|---|
| 140 | rectangle around the selected color chip, with an arrow pointing
|
|---|
| 141 | to the chip. Each arrow has an associated number giving you the
|
|---|
| 142 | color value along the variation's axis. Each variation strip
|
|---|
| 143 | shows you the colors that are reachable from the selected color by
|
|---|
| 144 | varying just one axis of the color solid.
|
|---|
| 145 |
|
|---|
| 146 | For example, when the selected color is (in Red/Green/Blue
|
|---|
| 147 | notation) 127/127/127, the Red Variations strip shows you every
|
|---|
| 148 | color in the range 0/127/127 to 255/127/127. Similarly for the
|
|---|
| 149 | green and blue axes. You can select any color by clicking on its
|
|---|
| 150 | chip. This will update the highlight rectangle and the arrow, as
|
|---|
| 151 | well as other displays in Pynche.
|
|---|
| 152 |
|
|---|
| 153 | Click on "Update while dragging" if you want Pynche to update the
|
|---|
| 154 | selected color while you drag along any variation strip (this will
|
|---|
| 155 | be a bit slower). Click on "Hexadecimal" to display the arrow
|
|---|
| 156 | numbers in hex.
|
|---|
| 157 |
|
|---|
| 158 | There are also two shortcut buttons in this window, which
|
|---|
| 159 | auto-select Black (0/0/0) and White (255/255/255).
|
|---|
| 160 |
|
|---|
| 161 |
|
|---|
| 162 | The Proof Window
|
|---|
| 163 |
|
|---|
| 164 | In the lower left corner of the main window you see two larger
|
|---|
| 165 | color chips. The Selected chip shows you a larger version of the
|
|---|
| 166 | color selected in the variation strips, along with its X11 color
|
|---|
| 167 | specification. The Nearest chip shows you the closest color in
|
|---|
| 168 | the X11 database to the selected color, giving its X11 color
|
|---|
| 169 | specification, and below that, its X11 color name. When the
|
|---|
| 170 | Selected chip color exactly matches the Nearest chip color, you
|
|---|
| 171 | will see the color name appear below the color specification for
|
|---|
| 172 | the Selected chip.
|
|---|
| 173 |
|
|---|
| 174 | Clicking on the Nearest color chip selects that color. Color
|
|---|
| 175 | distance is calculated in the 3D space of the RGB color solid and
|
|---|
| 176 | if more than one color name is the same distance from the selected
|
|---|
| 177 | color, the first one found will be chosen.
|
|---|
| 178 |
|
|---|
| 179 | Note that there may be more than one X11 color name for the same
|
|---|
| 180 | RGB value. In that case, the first one found in the text database
|
|---|
| 181 | is designated the "primary" name, and this is shown under the
|
|---|
| 182 | Nearest chip. The other names are "aliases" and they are visible
|
|---|
| 183 | in the Color List Window (see below).
|
|---|
| 184 |
|
|---|
| 185 | Both the color specifications and color names are selectable for
|
|---|
| 186 | copying and pasting into another window.
|
|---|
|
|---|