in reply to Change button color with Tk
G'day PerlCowboy,
All (I can't think of any exceptions off the top of my head) Tk widget options start with a "-". See your first post here for a plethora of examples.
All widget documentation is laid out in much the same manner. Looking at Tk::Button, you'll see Standard Options followed by Widget-Specific Options.
The Standard Options are just a list. Their details can be found in Tk::options. At the start of that page, you'll find the cget() and configure() methods: these are what you use to query and change options (both Standard and Widget-Specific ones).
It's unclear precisely what you want to do. If you just want to change the default background colour for your GUI when it's first presented, then ++roboticus is quite correct, you don't include them in a sub; instead, you'll want code like this:
$parent->Button( -text => '...', -background => '...', -command => ... )
If, however, you want a colour to change in response to an event (e.g. a button press), then you will want code in a sub, but using the configure() method I indicated above.
— Ken
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Change button color with Tk
by PerlCowboy (Novice) on Nov 02, 2017 at 19:23 UTC | |
by Discipulus (Canon) on Nov 02, 2017 at 20:14 UTC |