Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Active{fore,back}ground options ignored for label widget?

49 views
Skip to first unread message

Dave

unread,
Mar 23, 2017, 7:02:09 PM3/23/17
to
Win7x64 Tcl 8.6.6 compiled w/ msys2 64-bit gcc

Why are the active{fore,back}ground options ignored while the other
options are not?

option add *Table.Label.width 20
option add *Table.Label.activebackground lightblue
option add *Table.Label.activeforeground pink
option add *Table.Label.background blue
option add *Table.Label.foreground red

frame .f -class Table -width 200 -height 500 -bg cyan
label .f.c1 -text One
label .f.c2 -text Two -state active

pack .f
pack .f.c1 -side top -padx 25
pack .f.c2 -side top -padx 25

--
computerjock AT mail DOT com

Arjen Markus

unread,
Mar 24, 2017, 3:51:11 AM3/24/17
to
From the man page:

Specifies background color to use when drawing active elements. An element (a widget or portion of a widget) is active if the mouse cursor is positioned over the element and pressing a mouse button will cause some action to occur. If strict Motif compliance has been requested by setting the tk_strictMotif variable, this option will normally be ignored; the normal background color will be used instead. For some elements on Windows and Macintosh systems, the active color will only be used while mouse button 1 is pressed over the element.

How did you make the label "active"?

(I am a bit surprised that label widgets have "active" options at all - by default they do not offer any interactivity. Of course you could expliclty add bindings ...)

Regards,

Arjen

Dave

unread,
Mar 24, 2017, 1:03:41 PM3/24/17
to
On 3/24/2017 2:51 AM, Arjen Markus wrote:
> On Friday, March 24, 2017 at 12:02:09 AM UTC+1, Dave wrote:
>> Win7x64 Tcl 8.6.6 compiled w/ msys2 64-bit gcc
>>
>> Why are the active{fore,back}ground options ignored while the other
>> options are not?
>>
>> option add *Table.Label.width 20
>> option add *Table.Label.activebackground lightblue
>> option add *Table.Label.activeforeground pink
>> option add *Table.Label.background blue
>> option add *Table.Label.foreground red
>>
>> frame .f -class Table -width 200 -height 500 -bg cyan
>> label .f.c1 -text One
>> label .f.c2 -text Two -state active
>>
>> pack .f
>> pack .f.c1 -side top -padx 25
>> pack .f.c2 -side top -padx 25
>>
>> --
>> computerjock AT mail DOT com
>
> From the man page:
>
> Specifies background color to use when drawing active elements. An element (a widget or portion of a widget) is active if the mouse cursor is positioned over the element and pressing a mouse button will cause some action to occur. If strict Motif compliance has been requested by setting the tk_strictMotif variable, this option will normally be ignored; the normal background color will be used instead. For some elements on Windows and Macintosh systems, the active color will only be used while mouse button 1 is pressed over the element.
>
> How did you make the label "active"?
>

I had assumed that the .f.c2 "-state active" would have done it. I had
hoped that -state would have allowed me to easily switch between two
color schemes. I got that impression from the "-state" docs for label:

Command-Line Name: -state
Database Name: state
Database Class: State
Specifies one of three states for the label: normal, active, or
disabled. In normal state the button is displayed using the -foreground
and -background options. In active state the label is displayed using
the -activeforeground and -activebackground options. In the disabled
state the -disabledforeground and -background options determine how the
button is displayed.

Thank you for the explanation. IMO the docs can lead to confusion.

nemethi

unread,
Mar 24, 2017, 1:51:04 PM3/24/17
to
If you read the "options" manual page, you will see that the correct
database names are "activeBackground" and "activeForeground" (with
capital 'B' and 'F'). Correct your script accordingly, and it will work
as expected.

--
Csaba Nemethi http://www.nemethi.de mailto:csaba....@t-online.de

Dave

unread,
Mar 26, 2017, 4:45:55 PM3/26/17
to
On 3/24/2017 12:51 PM, nemethi wrote:
>
> If you read the "options" manual page, you will see that the correct
> database names are "activeBackground" and "activeForeground" (with
> capital 'B' and 'F'). Correct your script accordingly, and it will work
> as expected.
>

I should have caught that... I feel silly now. Thanks for catching my error.
0 new messages