Re: Images on disabled buttons look bad

Liste des GroupesRevenir à cl tcl 
Sujet : Re: Images on disabled buttons look bad
De : saitology9 (at) *nospam* gmail.com (saito)
Groupes : comp.lang.tcl
Date : 28. Feb 2025, 19:09:05
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <vpsu42$3osva$1@dont-email.me>
References : 1 2 3
User-Agent : Mozilla Thunderbird
On 2/28/2025 10:13 AM, Martin (m0h) wrote:
 It is definetly good to know this feature exists, although I will have to see if it is worth the effort to implement this into my application as I rely on Tk buttons currently.
 
I think you could still achieve the effect you want with a little extra effort.  Essentially you create a clone of your current button as a label, with the same image and text (perhaps, the text in a "inactive" font/color).  Then whenever you change the state to inactive/disabled, you unpack the original button and pack this clone instead, and do the reverse when you restore the state.
It just occurred to me while writing this that you could simply use a label instead of a button!  A label doesn't normally respond to clicks and events so it is easier to work with in this case. You just add bindings for clicks and track its state and you are done.
Here is a quick implementation:
package req Tk
label .l -text Hello -compound left -image [image create photo -file ..]
bind .l <Button-1> respond_to_clicks
pack .l
proc respond_to_clicks {} {
  global my_state
if {$my_state} {
     puts [clock seconds]
}
}
# make it active
# now the button reacts to mouse clicks
set my_state 1
# make it inactive
set my_state 0

Date Sujet#  Auteur
26 Feb 25 * Images on disabled buttons look bad6Martin (m0h)
27 Feb 25 `* Re: Images on disabled buttons look bad5Christian Gollwitzer
27 Feb 25  +* Re: Images on disabled buttons look bad2Harald Oehlmann
28 Feb 25  i`- Re: Images on disabled buttons look bad1Martin (m0h)
28 Feb 25  `* Re: Images on disabled buttons look bad2Martin (m0h)
28 Feb 25   `- Re: Images on disabled buttons look bad1saito

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal