| 1 | n/a | """Strip viewer and related widgets. |
|---|
| 2 | n/a | |
|---|
| 3 | n/a | The classes in this file implement the StripViewer shown in the top two thirds |
|---|
| 4 | n/a | of the main Pynche window. It consists of three StripWidgets which display |
|---|
| 5 | n/a | the variations in red, green, and blue respectively of the currently selected |
|---|
| 6 | n/a | r/g/b color value. |
|---|
| 7 | n/a | |
|---|
| 8 | n/a | Each StripWidget shows the color variations that are reachable by varying an |
|---|
| 9 | n/a | axis of the currently selected color. So for example, if the color is |
|---|
| 10 | n/a | |
|---|
| 11 | n/a | (R,G,B)=(127,163,196) |
|---|
| 12 | n/a | |
|---|
| 13 | n/a | then the Red variations show colors from (0,163,196) to (255,163,196), the |
|---|
| 14 | n/a | Green variations show colors from (127,0,196) to (127,255,196), and the Blue |
|---|
| 15 | n/a | variations show colors from (127,163,0) to (127,163,255). |
|---|
| 16 | n/a | |
|---|
| 17 | n/a | The selected color is always visible in all three StripWidgets, and in fact |
|---|
| 18 | n/a | each StripWidget highlights the selected color, and has an arrow pointing to |
|---|
| 19 | n/a | the selected chip, which includes the value along that particular axis. |
|---|
| 20 | n/a | |
|---|
| 21 | n/a | Clicking on any chip in any StripWidget selects that color, and updates all |
|---|
| 22 | n/a | arrows and other windows. By toggling on Update while dragging, Pynche will |
|---|
| 23 | n/a | select the color under the cursor while you drag it, but be forewarned that |
|---|
| 24 | n/a | this can be slow. |
|---|
| 25 | n/a | """ |
|---|
| 26 | n/a | |
|---|
| 27 | n/a | from tkinter import * |
|---|
| 28 | n/a | import ColorDB |
|---|
| 29 | n/a | |
|---|
| 30 | n/a | # Load this script into the Tcl interpreter and call it in |
|---|
| 31 | n/a | # StripWidget.set_color(). This is about as fast as it can be with the |
|---|
| 32 | n/a | # current _tkinter.c interface, which doesn't support Tcl Objects. |
|---|
| 33 | n/a | TCLPROC = '''\ |
|---|
| 34 | n/a | proc setcolor {canv colors} { |
|---|
| 35 | n/a | set i 1 |
|---|
| 36 | n/a | foreach c $colors { |
|---|
| 37 | n/a | $canv itemconfigure $i -fill $c -outline $c |
|---|
| 38 | n/a | incr i |
|---|
| 39 | n/a | } |
|---|
| 40 | n/a | } |
|---|
| 41 | n/a | ''' |
|---|
| 42 | n/a | |
|---|
| 43 | n/a | # Tcl event types |
|---|
| 44 | n/a | BTNDOWN = 4 |
|---|
| 45 | n/a | BTNUP = 5 |
|---|
| 46 | n/a | BTNDRAG = 6 |
|---|
| 47 | n/a | |
|---|
| 48 | n/a | SPACE = ' ' |
|---|
| 49 | n/a | |
|---|
| 50 | n/a | |
|---|
| 51 | n/a | |
|---|
| 52 | n/a | def constant(numchips): |
|---|
| 53 | n/a | step = 255.0 / (numchips - 1) |
|---|
| 54 | n/a | start = 0.0 |
|---|
| 55 | n/a | seq = [] |
|---|
| 56 | n/a | while numchips > 0: |
|---|
| 57 | n/a | seq.append(int(start)) |
|---|
| 58 | n/a | start = start + step |
|---|
| 59 | n/a | numchips = numchips - 1 |
|---|
| 60 | n/a | return seq |
|---|
| 61 | n/a | |
|---|
| 62 | n/a | # red variations, green+blue = cyan constant |
|---|
| 63 | n/a | def constant_red_generator(numchips, red, green, blue): |
|---|
| 64 | n/a | seq = constant(numchips) |
|---|
| 65 | n/a | return list(zip([red] * numchips, seq, seq)) |
|---|
| 66 | n/a | |
|---|
| 67 | n/a | # green variations, red+blue = magenta constant |
|---|
| 68 | n/a | def constant_green_generator(numchips, red, green, blue): |
|---|
| 69 | n/a | seq = constant(numchips) |
|---|
| 70 | n/a | return list(zip(seq, [green] * numchips, seq)) |
|---|
| 71 | n/a | |
|---|
| 72 | n/a | # blue variations, red+green = yellow constant |
|---|
| 73 | n/a | def constant_blue_generator(numchips, red, green, blue): |
|---|
| 74 | n/a | seq = constant(numchips) |
|---|
| 75 | n/a | return list(zip(seq, seq, [blue] * numchips)) |
|---|
| 76 | n/a | |
|---|
| 77 | n/a | # red variations, green+blue = cyan constant |
|---|
| 78 | n/a | def constant_cyan_generator(numchips, red, green, blue): |
|---|
| 79 | n/a | seq = constant(numchips) |
|---|
| 80 | n/a | return list(zip(seq, [green] * numchips, [blue] * numchips)) |
|---|
| 81 | n/a | |
|---|
| 82 | n/a | # green variations, red+blue = magenta constant |
|---|
| 83 | n/a | def constant_magenta_generator(numchips, red, green, blue): |
|---|
| 84 | n/a | seq = constant(numchips) |
|---|
| 85 | n/a | return list(zip([red] * numchips, seq, [blue] * numchips)) |
|---|
| 86 | n/a | |
|---|
| 87 | n/a | # blue variations, red+green = yellow constant |
|---|
| 88 | n/a | def constant_yellow_generator(numchips, red, green, blue): |
|---|
| 89 | n/a | seq = constant(numchips) |
|---|
| 90 | n/a | return list(zip([red] * numchips, [green] * numchips, seq)) |
|---|
| 91 | n/a | |
|---|
| 92 | n/a | |
|---|
| 93 | n/a | |
|---|
| 94 | n/a | class LeftArrow: |
|---|
| 95 | n/a | _ARROWWIDTH = 30 |
|---|
| 96 | n/a | _ARROWHEIGHT = 15 |
|---|
| 97 | n/a | _YOFFSET = 13 |
|---|
| 98 | n/a | _TEXTYOFFSET = 1 |
|---|
| 99 | n/a | _TAG = ('leftarrow',) |
|---|
| 100 | n/a | |
|---|
| 101 | n/a | def __init__(self, canvas, x): |
|---|
| 102 | n/a | self._canvas = canvas |
|---|
| 103 | n/a | self.__arrow, self.__text = self._create(x) |
|---|
| 104 | n/a | self.move_to(x) |
|---|
| 105 | n/a | |
|---|
| 106 | n/a | def _create(self, x): |
|---|
| 107 | n/a | arrow = self._canvas.create_line( |
|---|
| 108 | n/a | x, self._ARROWHEIGHT + self._YOFFSET, |
|---|
| 109 | n/a | x, self._YOFFSET, |
|---|
| 110 | n/a | x + self._ARROWWIDTH, self._YOFFSET, |
|---|
| 111 | n/a | arrow='first', |
|---|
| 112 | n/a | width=3.0, |
|---|
| 113 | n/a | tags=self._TAG) |
|---|
| 114 | n/a | text = self._canvas.create_text( |
|---|
| 115 | n/a | x + self._ARROWWIDTH + 13, |
|---|
| 116 | n/a | self._ARROWHEIGHT - self._TEXTYOFFSET, |
|---|
| 117 | n/a | tags=self._TAG, |
|---|
| 118 | n/a | text='128') |
|---|
| 119 | n/a | return arrow, text |
|---|
| 120 | n/a | |
|---|
| 121 | n/a | def _x(self): |
|---|
| 122 | n/a | coords = list(self._canvas.coords(self._TAG)) |
|---|
| 123 | n/a | assert coords |
|---|
| 124 | n/a | return coords[0] |
|---|
| 125 | n/a | |
|---|
| 126 | n/a | def move_to(self, x): |
|---|
| 127 | n/a | deltax = x - self._x() |
|---|
| 128 | n/a | self._canvas.move(self._TAG, deltax, 0) |
|---|
| 129 | n/a | |
|---|
| 130 | n/a | def set_text(self, text): |
|---|
| 131 | n/a | self._canvas.itemconfigure(self.__text, text=text) |
|---|
| 132 | n/a | |
|---|
| 133 | n/a | |
|---|
| 134 | n/a | class RightArrow(LeftArrow): |
|---|
| 135 | n/a | _TAG = ('rightarrow',) |
|---|
| 136 | n/a | |
|---|
| 137 | n/a | def _create(self, x): |
|---|
| 138 | n/a | arrow = self._canvas.create_line( |
|---|
| 139 | n/a | x, self._YOFFSET, |
|---|
| 140 | n/a | x + self._ARROWWIDTH, self._YOFFSET, |
|---|
| 141 | n/a | x + self._ARROWWIDTH, self._ARROWHEIGHT + self._YOFFSET, |
|---|
| 142 | n/a | arrow='last', |
|---|
| 143 | n/a | width=3.0, |
|---|
| 144 | n/a | tags=self._TAG) |
|---|
| 145 | n/a | text = self._canvas.create_text( |
|---|
| 146 | n/a | x - self._ARROWWIDTH + 15, # BAW: kludge |
|---|
| 147 | n/a | self._ARROWHEIGHT - self._TEXTYOFFSET, |
|---|
| 148 | n/a | justify=RIGHT, |
|---|
| 149 | n/a | text='128', |
|---|
| 150 | n/a | tags=self._TAG) |
|---|
| 151 | n/a | return arrow, text |
|---|
| 152 | n/a | |
|---|
| 153 | n/a | def _x(self): |
|---|
| 154 | n/a | coords = list(self._canvas.coords(self._TAG)) |
|---|
| 155 | n/a | assert coords |
|---|
| 156 | n/a | return coords[0] + self._ARROWWIDTH |
|---|
| 157 | n/a | |
|---|
| 158 | n/a | |
|---|
| 159 | n/a | |
|---|
| 160 | n/a | class StripWidget: |
|---|
| 161 | n/a | _CHIPHEIGHT = 50 |
|---|
| 162 | n/a | _CHIPWIDTH = 10 |
|---|
| 163 | n/a | _NUMCHIPS = 40 |
|---|
| 164 | n/a | |
|---|
| 165 | n/a | def __init__(self, switchboard, |
|---|
| 166 | n/a | master = None, |
|---|
| 167 | n/a | chipwidth = _CHIPWIDTH, |
|---|
| 168 | n/a | chipheight = _CHIPHEIGHT, |
|---|
| 169 | n/a | numchips = _NUMCHIPS, |
|---|
| 170 | n/a | generator = None, |
|---|
| 171 | n/a | axis = None, |
|---|
| 172 | n/a | label = '', |
|---|
| 173 | n/a | uwdvar = None, |
|---|
| 174 | n/a | hexvar = None): |
|---|
| 175 | n/a | # instance variables |
|---|
| 176 | n/a | self.__generator = generator |
|---|
| 177 | n/a | self.__axis = axis |
|---|
| 178 | n/a | self.__numchips = numchips |
|---|
| 179 | n/a | assert self.__axis in (0, 1, 2) |
|---|
| 180 | n/a | self.__uwd = uwdvar |
|---|
| 181 | n/a | self.__hexp = hexvar |
|---|
| 182 | n/a | # the last chip selected |
|---|
| 183 | n/a | self.__lastchip = None |
|---|
| 184 | n/a | self.__sb = switchboard |
|---|
| 185 | n/a | |
|---|
| 186 | n/a | canvaswidth = numchips * (chipwidth + 1) |
|---|
| 187 | n/a | canvasheight = chipheight + 43 # BAW: Kludge |
|---|
| 188 | n/a | |
|---|
| 189 | n/a | # create the canvas and pack it |
|---|
| 190 | n/a | canvas = self.__canvas = Canvas(master, |
|---|
| 191 | n/a | width=canvaswidth, |
|---|
| 192 | n/a | height=canvasheight, |
|---|
| 193 | n/a | ## borderwidth=2, |
|---|
| 194 | n/a | ## relief=GROOVE |
|---|
| 195 | n/a | ) |
|---|
| 196 | n/a | |
|---|
| 197 | n/a | canvas.pack() |
|---|
| 198 | n/a | canvas.bind('<ButtonPress-1>', self.__select_chip) |
|---|
| 199 | n/a | canvas.bind('<ButtonRelease-1>', self.__select_chip) |
|---|
| 200 | n/a | canvas.bind('<B1-Motion>', self.__select_chip) |
|---|
| 201 | n/a | |
|---|
| 202 | n/a | # Load a proc into the Tcl interpreter. This is used in the |
|---|
| 203 | n/a | # set_color() method to speed up setting the chip colors. |
|---|
| 204 | n/a | canvas.tk.eval(TCLPROC) |
|---|
| 205 | n/a | |
|---|
| 206 | n/a | # create the color strip |
|---|
| 207 | n/a | chips = self.__chips = [] |
|---|
| 208 | n/a | x = 1 |
|---|
| 209 | n/a | y = 30 |
|---|
| 210 | n/a | tags = ('chip',) |
|---|
| 211 | n/a | for c in range(self.__numchips): |
|---|
| 212 | n/a | color = 'grey' |
|---|
| 213 | n/a | canvas.create_rectangle( |
|---|
| 214 | n/a | x, y, x+chipwidth, y+chipheight, |
|---|
| 215 | n/a | fill=color, outline=color, |
|---|
| 216 | n/a | tags=tags) |
|---|
| 217 | n/a | x = x + chipwidth + 1 # for outline |
|---|
| 218 | n/a | chips.append(color) |
|---|
| 219 | n/a | |
|---|
| 220 | n/a | # create the strip label |
|---|
| 221 | n/a | self.__label = canvas.create_text( |
|---|
| 222 | n/a | 3, y + chipheight + 8, |
|---|
| 223 | n/a | text=label, |
|---|
| 224 | n/a | anchor=W) |
|---|
| 225 | n/a | |
|---|
| 226 | n/a | # create the arrow and text item |
|---|
| 227 | n/a | chipx = self.__arrow_x(0) |
|---|
| 228 | n/a | self.__leftarrow = LeftArrow(canvas, chipx) |
|---|
| 229 | n/a | |
|---|
| 230 | n/a | chipx = self.__arrow_x(len(chips) - 1) |
|---|
| 231 | n/a | self.__rightarrow = RightArrow(canvas, chipx) |
|---|
| 232 | n/a | |
|---|
| 233 | n/a | def __arrow_x(self, chipnum): |
|---|
| 234 | n/a | coords = self.__canvas.coords(chipnum+1) |
|---|
| 235 | n/a | assert coords |
|---|
| 236 | n/a | x0, y0, x1, y1 = coords |
|---|
| 237 | n/a | return (x1 + x0) / 2.0 |
|---|
| 238 | n/a | |
|---|
| 239 | n/a | # Invoked when one of the chips is clicked. This should just tell the |
|---|
| 240 | n/a | # switchboard to set the color on all the output components |
|---|
| 241 | n/a | def __select_chip(self, event=None): |
|---|
| 242 | n/a | x = event.x |
|---|
| 243 | n/a | y = event.y |
|---|
| 244 | n/a | canvas = self.__canvas |
|---|
| 245 | n/a | chip = canvas.find_overlapping(x, y, x, y) |
|---|
| 246 | n/a | if chip and (1 <= chip[0] <= self.__numchips): |
|---|
| 247 | n/a | color = self.__chips[chip[0]-1] |
|---|
| 248 | n/a | red, green, blue = ColorDB.rrggbb_to_triplet(color) |
|---|
| 249 | n/a | etype = int(event.type) |
|---|
| 250 | n/a | if (etype == BTNUP or self.__uwd.get()): |
|---|
| 251 | n/a | # update everyone |
|---|
| 252 | n/a | self.__sb.update_views(red, green, blue) |
|---|
| 253 | n/a | else: |
|---|
| 254 | n/a | # just track the arrows |
|---|
| 255 | n/a | self.__trackarrow(chip[0], (red, green, blue)) |
|---|
| 256 | n/a | |
|---|
| 257 | n/a | def __trackarrow(self, chip, rgbtuple): |
|---|
| 258 | n/a | # invert the last chip |
|---|
| 259 | n/a | if self.__lastchip is not None: |
|---|
| 260 | n/a | color = self.__canvas.itemcget(self.__lastchip, 'fill') |
|---|
| 261 | n/a | self.__canvas.itemconfigure(self.__lastchip, outline=color) |
|---|
| 262 | n/a | self.__lastchip = chip |
|---|
| 263 | n/a | # get the arrow's text |
|---|
| 264 | n/a | coloraxis = rgbtuple[self.__axis] |
|---|
| 265 | n/a | if self.__hexp.get(): |
|---|
| 266 | n/a | # hex |
|---|
| 267 | n/a | text = hex(coloraxis) |
|---|
| 268 | n/a | else: |
|---|
| 269 | n/a | # decimal |
|---|
| 270 | n/a | text = repr(coloraxis) |
|---|
| 271 | n/a | # move the arrow, and set its text |
|---|
| 272 | n/a | if coloraxis <= 128: |
|---|
| 273 | n/a | # use the left arrow |
|---|
| 274 | n/a | self.__leftarrow.set_text(text) |
|---|
| 275 | n/a | self.__leftarrow.move_to(self.__arrow_x(chip-1)) |
|---|
| 276 | n/a | self.__rightarrow.move_to(-100) |
|---|
| 277 | n/a | else: |
|---|
| 278 | n/a | # use the right arrow |
|---|
| 279 | n/a | self.__rightarrow.set_text(text) |
|---|
| 280 | n/a | self.__rightarrow.move_to(self.__arrow_x(chip-1)) |
|---|
| 281 | n/a | self.__leftarrow.move_to(-100) |
|---|
| 282 | n/a | # and set the chip's outline |
|---|
| 283 | n/a | brightness = ColorDB.triplet_to_brightness(rgbtuple) |
|---|
| 284 | n/a | if brightness <= 128: |
|---|
| 285 | n/a | outline = 'white' |
|---|
| 286 | n/a | else: |
|---|
| 287 | n/a | outline = 'black' |
|---|
| 288 | n/a | self.__canvas.itemconfigure(chip, outline=outline) |
|---|
| 289 | n/a | |
|---|
| 290 | n/a | |
|---|
| 291 | n/a | def update_yourself(self, red, green, blue): |
|---|
| 292 | n/a | assert self.__generator |
|---|
| 293 | n/a | i = 1 |
|---|
| 294 | n/a | chip = 0 |
|---|
| 295 | n/a | chips = self.__chips = [] |
|---|
| 296 | n/a | tk = self.__canvas.tk |
|---|
| 297 | n/a | # get the red, green, and blue components for all chips |
|---|
| 298 | n/a | for t in self.__generator(self.__numchips, red, green, blue): |
|---|
| 299 | n/a | rrggbb = ColorDB.triplet_to_rrggbb(t) |
|---|
| 300 | n/a | chips.append(rrggbb) |
|---|
| 301 | n/a | tred, tgreen, tblue = t |
|---|
| 302 | n/a | if tred <= red and tgreen <= green and tblue <= blue: |
|---|
| 303 | n/a | chip = i |
|---|
| 304 | n/a | i = i + 1 |
|---|
| 305 | n/a | # call the raw tcl script |
|---|
| 306 | n/a | colors = SPACE.join(chips) |
|---|
| 307 | n/a | tk.eval('setcolor %s {%s}' % (self.__canvas._w, colors)) |
|---|
| 308 | n/a | # move the arrows around |
|---|
| 309 | n/a | self.__trackarrow(chip, (red, green, blue)) |
|---|
| 310 | n/a | |
|---|
| 311 | n/a | def set(self, label, generator): |
|---|
| 312 | n/a | self.__canvas.itemconfigure(self.__label, text=label) |
|---|
| 313 | n/a | self.__generator = generator |
|---|
| 314 | n/a | |
|---|
| 315 | n/a | |
|---|
| 316 | n/a | class StripViewer: |
|---|
| 317 | n/a | def __init__(self, switchboard, master=None): |
|---|
| 318 | n/a | self.__sb = switchboard |
|---|
| 319 | n/a | optiondb = switchboard.optiondb() |
|---|
| 320 | n/a | # create a frame inside the master. |
|---|
| 321 | n/a | frame = Frame(master, relief=RAISED, borderwidth=1) |
|---|
| 322 | n/a | frame.grid(row=1, column=0, columnspan=2, sticky='NSEW') |
|---|
| 323 | n/a | # create the options to be used later |
|---|
| 324 | n/a | uwd = self.__uwdvar = BooleanVar() |
|---|
| 325 | n/a | uwd.set(optiondb.get('UPWHILEDRAG', 0)) |
|---|
| 326 | n/a | hexp = self.__hexpvar = BooleanVar() |
|---|
| 327 | n/a | hexp.set(optiondb.get('HEXSTRIP', 0)) |
|---|
| 328 | n/a | # create the red, green, blue strips inside their own frame |
|---|
| 329 | n/a | frame1 = Frame(frame) |
|---|
| 330 | n/a | frame1.pack(expand=YES, fill=BOTH) |
|---|
| 331 | n/a | self.__reds = StripWidget(switchboard, frame1, |
|---|
| 332 | n/a | generator=constant_cyan_generator, |
|---|
| 333 | n/a | axis=0, |
|---|
| 334 | n/a | label='Red Variations', |
|---|
| 335 | n/a | uwdvar=uwd, hexvar=hexp) |
|---|
| 336 | n/a | |
|---|
| 337 | n/a | self.__greens = StripWidget(switchboard, frame1, |
|---|
| 338 | n/a | generator=constant_magenta_generator, |
|---|
| 339 | n/a | axis=1, |
|---|
| 340 | n/a | label='Green Variations', |
|---|
| 341 | n/a | uwdvar=uwd, hexvar=hexp) |
|---|
| 342 | n/a | |
|---|
| 343 | n/a | self.__blues = StripWidget(switchboard, frame1, |
|---|
| 344 | n/a | generator=constant_yellow_generator, |
|---|
| 345 | n/a | axis=2, |
|---|
| 346 | n/a | label='Blue Variations', |
|---|
| 347 | n/a | uwdvar=uwd, hexvar=hexp) |
|---|
| 348 | n/a | |
|---|
| 349 | n/a | # create a frame to contain the controls |
|---|
| 350 | n/a | frame2 = Frame(frame) |
|---|
| 351 | n/a | frame2.pack(expand=YES, fill=BOTH) |
|---|
| 352 | n/a | frame2.columnconfigure(0, weight=20) |
|---|
| 353 | n/a | frame2.columnconfigure(2, weight=20) |
|---|
| 354 | n/a | |
|---|
| 355 | n/a | padx = 8 |
|---|
| 356 | n/a | |
|---|
| 357 | n/a | # create the black button |
|---|
| 358 | n/a | blackbtn = Button(frame2, |
|---|
| 359 | n/a | text='Black', |
|---|
| 360 | n/a | command=self.__toblack) |
|---|
| 361 | n/a | blackbtn.grid(row=0, column=0, rowspan=2, sticky=W, padx=padx) |
|---|
| 362 | n/a | |
|---|
| 363 | n/a | # create the controls |
|---|
| 364 | n/a | uwdbtn = Checkbutton(frame2, |
|---|
| 365 | n/a | text='Update while dragging', |
|---|
| 366 | n/a | variable=uwd) |
|---|
| 367 | n/a | uwdbtn.grid(row=0, column=1, sticky=W) |
|---|
| 368 | n/a | hexbtn = Checkbutton(frame2, |
|---|
| 369 | n/a | text='Hexadecimal', |
|---|
| 370 | n/a | variable=hexp, |
|---|
| 371 | n/a | command=self.__togglehex) |
|---|
| 372 | n/a | hexbtn.grid(row=1, column=1, sticky=W) |
|---|
| 373 | n/a | |
|---|
| 374 | n/a | # XXX: ignore this feature for now; it doesn't work quite right yet |
|---|
| 375 | n/a | |
|---|
| 376 | n/a | ## gentypevar = self.__gentypevar = IntVar() |
|---|
| 377 | n/a | ## self.__variations = Radiobutton(frame, |
|---|
| 378 | n/a | ## text='Variations', |
|---|
| 379 | n/a | ## variable=gentypevar, |
|---|
| 380 | n/a | ## value=0, |
|---|
| 381 | n/a | ## command=self.__togglegentype) |
|---|
| 382 | n/a | ## self.__variations.grid(row=0, column=1, sticky=W) |
|---|
| 383 | n/a | ## self.__constants = Radiobutton(frame, |
|---|
| 384 | n/a | ## text='Constants', |
|---|
| 385 | n/a | ## variable=gentypevar, |
|---|
| 386 | n/a | ## value=1, |
|---|
| 387 | n/a | ## command=self.__togglegentype) |
|---|
| 388 | n/a | ## self.__constants.grid(row=1, column=1, sticky=W) |
|---|
| 389 | n/a | |
|---|
| 390 | n/a | # create the white button |
|---|
| 391 | n/a | whitebtn = Button(frame2, |
|---|
| 392 | n/a | text='White', |
|---|
| 393 | n/a | command=self.__towhite) |
|---|
| 394 | n/a | whitebtn.grid(row=0, column=2, rowspan=2, sticky=E, padx=padx) |
|---|
| 395 | n/a | |
|---|
| 396 | n/a | def update_yourself(self, red, green, blue): |
|---|
| 397 | n/a | self.__reds.update_yourself(red, green, blue) |
|---|
| 398 | n/a | self.__greens.update_yourself(red, green, blue) |
|---|
| 399 | n/a | self.__blues.update_yourself(red, green, blue) |
|---|
| 400 | n/a | |
|---|
| 401 | n/a | def __togglehex(self, event=None): |
|---|
| 402 | n/a | red, green, blue = self.__sb.current_rgb() |
|---|
| 403 | n/a | self.update_yourself(red, green, blue) |
|---|
| 404 | n/a | |
|---|
| 405 | n/a | ## def __togglegentype(self, event=None): |
|---|
| 406 | n/a | ## which = self.__gentypevar.get() |
|---|
| 407 | n/a | ## if which == 0: |
|---|
| 408 | n/a | ## self.__reds.set(label='Red Variations', |
|---|
| 409 | n/a | ## generator=constant_cyan_generator) |
|---|
| 410 | n/a | ## self.__greens.set(label='Green Variations', |
|---|
| 411 | n/a | ## generator=constant_magenta_generator) |
|---|
| 412 | n/a | ## self.__blues.set(label='Blue Variations', |
|---|
| 413 | n/a | ## generator=constant_yellow_generator) |
|---|
| 414 | n/a | ## elif which == 1: |
|---|
| 415 | n/a | ## self.__reds.set(label='Red Constant', |
|---|
| 416 | n/a | ## generator=constant_red_generator) |
|---|
| 417 | n/a | ## self.__greens.set(label='Green Constant', |
|---|
| 418 | n/a | ## generator=constant_green_generator) |
|---|
| 419 | n/a | ## self.__blues.set(label='Blue Constant', |
|---|
| 420 | n/a | ## generator=constant_blue_generator) |
|---|
| 421 | n/a | ## else: |
|---|
| 422 | n/a | ## assert 0 |
|---|
| 423 | n/a | ## self.__sb.update_views_current() |
|---|
| 424 | n/a | |
|---|
| 425 | n/a | def __toblack(self, event=None): |
|---|
| 426 | n/a | self.__sb.update_views(0, 0, 0) |
|---|
| 427 | n/a | |
|---|
| 428 | n/a | def __towhite(self, event=None): |
|---|
| 429 | n/a | self.__sb.update_views(255, 255, 255) |
|---|
| 430 | n/a | |
|---|
| 431 | n/a | def save_options(self, optiondb): |
|---|
| 432 | n/a | optiondb['UPWHILEDRAG'] = self.__uwdvar.get() |
|---|
| 433 | n/a | optiondb['HEXSTRIP'] = self.__hexpvar.get() |
|---|