tgai
tgai

Reputation: 1115

Cleaner looking TCL GUI TK Button

I have a Tk::Button that has a folder image on it. On some occasions we disable this button and the button image is kind of grayed out.

Example: enter image description here enter image description here

Is there anyway to clean up the disabled look? Possible bind a separate image to use when disabled?

set ::FileSelect::folder_image [image create photo -file "$::env(Path)/include/images/folder.gif"]
set ::FileSelect::folder_image_disabled [image create photo -file "$::env(Path)/include/images/folder_disabled.gif"]
ttk::button $widget_name.browse -image { $::FileSelect::folder_image disabled $::FileSelect::folder_image_disabled }

Upvotes: 1

Views: 1238

Answers (1)

Bryan Oakley
Bryan Oakley

Reputation: 385910

You can change the bitmap in whatever code sets the state to the disabled state.

For example:

if [should_be_disabled] {
    button configure -state disabled -image $disabled_image
} else {
    button configure -state normal -image $normal_image

If you are using themed widgets you can specify different images for each state. For example, to use the image disabled_image for the disabled state and default_image for the normal state you would do something like this:

ttk::button .b1 -image {default_image disabled disabled_image}

For more information on the themed button see the man page for ttk::button.

Upvotes: 2

Related Questions