Version 6 of WISH Color Picker Plus

Updated 2007-07-16 21:25:34 by pa_mcclamrock

WISH Color Picker Plus megawidget

        http://www.geocities.com/pa_mcclamrock/

http://www.geocities.com/pa_mcclamrock/wishcolorplus.gif

WISH Color Picker Plus is a fairly versatile megawidget for applying user-selected color schemes to Tk applications. After downloading and unwrapping the "wishcolorplus.tcl.tar.gz" archive, just put some code like this in your application:

 # Use WISH Color Picker Plus for color configuration
 # (It sets color variables with default values;
 # values may then be changed by configuration files):

 source [file join $libdir wishcolorplus.tcl]

 # Use some of the specified color variables:

 tk_setPalette background $winback foreground $winfore selectBackground \
        $selback selectForeground $selfore

After all your Tk widgets have been created, insert some code like this, obviously substituting your widget names for mine. (I haven't figured out how to automate the creation of the widget lists yet, but give me time.)

 # Lists of widgets (to add to lists originally set
 # by WISH Color Picker Plus):

 # Regular buttons:
 foreach butt [list .special .clear .pick .top .up .home .colo .view .edit] {
        lappend buttlist $butt
        $butt configure -bg $buttback -fg $buttfore
 }

 # Listboxes:
 foreach lub [list .sublist .filnamo .contexto] {
        lappend lublist $lub
        $lub configure -bg $listback -fg $listfore
 }

 # Entry widgets and spinboxes:
 foreach row [range 2 to 7] {
        foreach ent [list .ent($row,0) .ent($row,1) .ent($row,2)] {
                lappend entlist $ent
                $ent configure -bg $entback -fg $entfore
        }
 }

 foreach row [range 1 to 6] {
        foreach ent [list .tib($row,0) .tib($row,1) .tib($row,2)] {
                lappend entlist $ent
                $ent configure -bg $entback -fg $entfore
        }
 }

 foreach ent [list .wordcount .fracker .topent] {
        lappend entlist $spin
        $ent configure -bg $entback -fg $entfore
 }

 # Emphasized labels:
 foreach head [list .what .where .searchline .searchnum .ofnum \
        .foundnum .fileo .conto] {
        lappend headlist $head
        $head configure -bg $headback -fg $headfore
 }

 # Light labels (I don't have any of these in the app I took this code from):
 foreach light [list] {
        lappend lightlist $light
        $light configure -bg $lightback -fg $lightfore
 }

This will apply the colors from a color configuration file in the user's ~/.wishes directory (or else the bland default colors), and it will line up all the widgets to have the user's color modifications applied to them. WISH Color Picker Plus comes with several color schemes, which the user can apply, modify, or delete. (The color scheme above is called "Mama Rose"--my wife's favorite.)


GWM This is how I apply a skin to a complete window - note that you dont need to maintain a list of all your widgets. You can extend this to set font size, name etc. Use a switchbased on "winfo class $w" to set different colours for each type (button, listbox, menubutton...) of widget.

  proc setAllSkin {w} { ;# traverse all child windows to set colours
    global basecolour
    global textcolour
    if [winfo exists $w] {
      catch {$w configure  -background $basecolour }
      catch {$w configure  -fg $textcolour }
      catch {$w configure  -foreground $textcolour }
      foreach child [winfo children $w] {
        setAllSkin $child
      }
    }
  }
  setAllSkin . ;# changes the base and text colour for all widgets in '.'.

The 'catch {}' allows widgets that don't support background, fg or foreground keywords to continue.


Category GUI Category Widget