Rocksolid Light

News from da outaworlds

mail  files  register  groups  login

Message-ID:  

BOFH excuse #112: The monitor is plugged into the serial port


comp / comp.lang.tcl / Re: change background of tkk::button on Windows?

SubjectAuthor
* change background of tkk::button on Windows?Ralf Fassel
+* Re: change background of tkk::button on Windows?greg
|`- Re: change background of tkk::button on Windows?Ralf Fassel
`* Re: change background of tkk::button on Windows?greg
 `- Re: change background of tkk::button on Windows?greg

1
Subject: change background of tkk::button on Windows?
From: Ralf Fassel
Newsgroups: comp.lang.tcl
Date: Tue, 28 May 2024 10:52 UTC
Path: eternal-september.org!news.eternal-september.org!feeder3.eternal-september.org!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: ralfixx@gmx.de (Ralf Fassel)
Newsgroups: comp.lang.tcl
Subject: change background of tkk::button on Windows?
Date: Tue, 28 May 2024 12:52:24 +0200
Lines: 32
Message-ID: <ygacyp6ryxj.fsf@akutech.de>
Mime-Version: 1.0
Content-Type: text/plain
X-Trace: individual.net WAcot5AWxx3zHRv81cGXAQCXichl5R2znIbnTCGCkZLWQfTx4=
Cancel-Lock: sha1:FTIOgLIUgVpy92IpEkSdo1NBIQ0= sha1:s6qZ/X3yP6HdZbe1y5K97qjloCE= sha256:3xa6tkKQ5r1atMwcLoq1fr+vlwfxfI47k+azzJwX5ww=
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
View all headers

tcl + tk 8.6.14
Windows 10

On *Windows*, how can I change the background of a ttk::button to some
color?

On Linux, this works:

ttk::style configure TButton -background red
pack [ttk::button .b -text Button]

=> black text on red background.
On Windows, however, there is only a tiny red ring around the button
with the above code, and the button background itself is the usual grey.

I tried also:

ttk::style map TButton -background [list !disabled red]
(same effect as above, red ring)

I see
ttk::style element options TButton.label
-compound -space -text -font -foreground -underline -width -anchor -justify -wraplength -embossed -image -stipple -background

But how do I get at the -background of the TButton.label?
ttK::style 'configure' or 'map' on TButton.Label or TButton.label does
not change anything in the ttk::button (though
https://tkdocs.com/tutorial/styles.html
somehow indicates it could ... maybe).

TNX
R' (ttk::styles look good, but they are driving me mad)

Subject: Re: change background of tkk::button on Windows?
From: greg
Newsgroups: comp.lang.tcl
Organization: A noiseless patient Spider
Date: Wed, 29 May 2024 17:49 UTC
References: 1
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: gregor.ebbing@gmx.de (greg)
Newsgroups: comp.lang.tcl
Subject: Re: change background of tkk::button on Windows?
Date: Wed, 29 May 2024 19:49:53 +0200
Organization: A noiseless patient Spider
Lines: 46
Message-ID: <v37ps1$188nu$1@dont-email.me>
References: <ygacyp6ryxj.fsf@akutech.de>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 29 May 2024 19:49:54 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="804c1984132dc5ab4f3147f9b0edd12e";
logging-data="1319678"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+kxPuZwpbPmlRUO1xX8aWTqIv3+IYtyvI="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:Z2I7VyQoHLMckveWBdmoEkJupBc=
In-Reply-To: <ygacyp6ryxj.fsf@akutech.de>
Content-Language: de-DE
View all headers

Am 28.05.24 um 12:52 schrieb Ralf Fassel:
> tcl + tk 8.6.14
> Windows 10
>
> On *Windows*, how can I change the background of a ttk::button to some
> color?
>
> On Linux, this works:
>
> ttk::style configure TButton -background red
> pack [ttk::button .b -text Button]
>
> => black text on red background.
> On Windows, however, there is only a tiny red ring around the button
> with the above code, and the button background itself is the usual grey.
>
> I tried also:
>
> ttk::style map TButton -background [list !disabled red]
> (same effect as above, red ring)
>
> I see
> ttk::style element options TButton.label
> -compound -space -text -font -foreground -underline -width -anchor -justify -wraplength -embossed -image -stipple -background
>
> But how do I get at the -background of the TButton.label?
> ttK::style 'configure' or 'map' on TButton.Label or TButton.label does
> not change anything in the ttk::button (though
> https://tkdocs.com/tutorial/styles.html
> somehow indicates it could ... maybe).
>
> TNX
> R' (ttk::styles look good, but they are driving me mad)
Hello,
As far as I understand, the winnative, xpnative and vista themes are
limited in what you can change.

https://wiki.tcl-lang.org/page/Ttk#67395ef1c74680130d5bdb83dbfe0426dc5c1a6a3a7ecdf4f591c0476fe58df6

One option is to use a different theme.
ttk::style theme names
ttk::style theme use clam

mfg
Gregor

Subject: Re: change background of tkk::button on Windows?
From: greg
Newsgroups: comp.lang.tcl
Organization: A noiseless patient Spider
Date: Thu, 30 May 2024 11:29 UTC
References: 1
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: gregor.ebbing@gmx.de (greg)
Newsgroups: comp.lang.tcl
Subject: Re: change background of tkk::button on Windows?
Date: Thu, 30 May 2024 13:29:37 +0200
Organization: A noiseless patient Spider
Lines: 67
Message-ID: <v39nv1$1lsev$1@dont-email.me>
References: <ygacyp6ryxj.fsf@akutech.de>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 30 May 2024 13:29:38 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="2c9686fa7b21c4d0e8a53cff7b5f1703";
logging-data="1765855"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/uyxsPSpF3K+axr6DcDEoo6mfH2hFIMjE="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:T6t8TIbQs9UgqyMRllEsIOZysOA=
Content-Language: de-DE
In-Reply-To: <ygacyp6ryxj.fsf@akutech.de>
View all headers

Am 28.05.24 um 12:52 schrieb Ralf Fassel:
> tcl + tk 8.6.14
> Windows 10
>
> On *Windows*, how can I change the background of a ttk::button to some
> color?
>
> On Linux, this works:
>
> ttk::style configure TButton -background red
> pack [ttk::button .b -text Button]
>
> => black text on red background.
> On Windows, however, there is only a tiny red ring around the button
> with the above code, and the button background itself is the usual grey.
>
> I tried also:
>
> ttk::style map TButton -background [list !disabled red]
> (same effect as above, red ring)
>
> I see
> ttk::style element options TButton.label
> -compound -space -text -font -foreground -underline -width -anchor -justify -wraplength -embossed -image -stipple -background
>
> But how do I get at the -background of the TButton.label?
> ttK::style 'configure' or 'map' on TButton.Label or TButton.label does
> not change anything in the ttk::button (though
> https://tkdocs.com/tutorial/styles.html
> somehow indicates it could ... maybe).
>
> TNX
> R' (ttk::styles look good, but they are driving me mad)

from the excellent https://tkdocs.com/tutorial/styles.html
"You'll sometimes try to change an option that is supposed to exist
according to element options, but it will have no effect..."

a colored button, but without text:

package require Tk

set iw 76
set ih 25
set img1 [image create photo -width $iw -height $ih]
$img1 put {#ff0000} -to 0 0 $iw $ih

set img2 [image create photo -width $iw -height $ih]
$img2 put {#00ff00} -to 0 0 $iw $ih

set img3 [image create photo -width $iw -height $ih]
$img3 put {#0000ff} -to 0 0 $iw $ih

ttk::style configure Bone.TButton
ttk::style element create Bone.image image [list $img1 pressed $img2
active $img3] -border {2 4} -sticky we
#ttk::style element create Bone.image image [list $img1 pressed $img2
active $img3] -border {2 4} -sticky snwe
ttk::style layout Bone.TButton [list Bone.image -sticky nswe]

set b1 [ttk::button .b1 -text "Button1" -style Bone.TButton]
set b2 [ttk::button .b2 -text "Button2"]

# Packe die Buttons
pack $b1 $b2

Subject: Re: change background of tkk::button on Windows?
From: greg
Newsgroups: comp.lang.tcl
Organization: A noiseless patient Spider
Date: Thu, 30 May 2024 11:46 UTC
References: 1 2
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: gregor.ebbing@gmx.de (greg)
Newsgroups: comp.lang.tcl
Subject: Re: change background of tkk::button on Windows?
Date: Thu, 30 May 2024 13:46:48 +0200
Organization: A noiseless patient Spider
Lines: 102
Message-ID: <v39ov8$1m3nu$1@dont-email.me>
References: <ygacyp6ryxj.fsf@akutech.de> <v39nv1$1lsev$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Thu, 30 May 2024 13:46:48 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="2c9686fa7b21c4d0e8a53cff7b5f1703";
logging-data="1773310"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/8S1lwqWfhRqqGkMTQrCScNtYUQi0C9hU="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:3psiqeSsCSbBw4SUJ1qnG9D+8gg=
Content-Language: de-DE
In-Reply-To: <v39nv1$1lsev$1@dont-email.me>
View all headers

Am 30.05.24 um 13:29 schrieb greg:
> Am 28.05.24 um 12:52 schrieb Ralf Fassel:
>> tcl + tk 8.6.14
>> Windows 10
>>
>> On *Windows*, how can I change the background of a ttk::button to some
>> color?
>>
>> On Linux, this works:
>>
>>    ttk::style configure TButton -background red
>>    pack [ttk::button .b -text Button]
>>
>> => black text on red background.
>> On Windows, however, there is only a tiny red ring around the button
>> with the above code, and the button background itself is the usual grey.
>>
>> I tried also:
>>
>>    ttk::style map TButton -background [list !disabled red]
>>    (same effect as above, red ring)
>>
>> I see
>>    ttk::style element options TButton.label
>>    -compound -space -text -font -foreground -underline -width -anchor
>> -justify -wraplength -embossed -image -stipple -background
>>
>> But how do I get at the -background of the TButton.label?
>> ttK::style 'configure' or 'map' on TButton.Label or TButton.label does
>> not change anything in the ttk::button (though
>>    https://tkdocs.com/tutorial/styles.html
>> somehow indicates it could ... maybe).
>>
>> TNX
>> R' (ttk::styles look good, but they are driving me mad)
>
>
> from the excellent https://tkdocs.com/tutorial/styles.html
> "You'll sometimes try to change an option that is supposed to exist
> according to element options, but it will have no effect..."
>
> a colored button, but without text:
>
> package require Tk
>
> set iw 76
> set ih 25
> set img1 [image create photo -width $iw -height $ih]
> $img1 put {#ff0000} -to 0 0 $iw $ih
>
> set img2 [image create photo -width $iw -height $ih]
> $img2 put {#00ff00} -to 0 0 $iw $ih
>
> set img3 [image create photo -width $iw -height $ih]
> $img3 put {#0000ff} -to 0 0 $iw $ih
>
> ttk::style configure Bone.TButton
> ttk::style element create Bone.image image [list $img1  pressed $img2
> active $img3] -border {2 4} -sticky we
> #ttk::style element create Bone.image image [list $img1  pressed $img2
> active $img3] -border {2 4} -sticky snwe
> ttk::style layout Bone.TButton [list Bone.image -sticky nswe]
>
>
> set b1 [ttk::button .b1 -text "Button1" -style Bone.TButton]
> set b2 [ttk::button .b2 -text "Button2"]
>
> # Packe die Buttons
> pack $b1 $b2
with text

package require Tk

puts [ttk::style theme use]

set iw 76
set ih 25
set img1 [image create photo -width $iw -height $ih]
$img1 put {#ff0000} -to 0 0 $iw $ih

set img2 [image create photo -width $iw -height $ih]
$img2 put {#00ff00} -to 0 0 $iw $ih

set img3 [image create photo -width $iw -height $ih]
$img3 put {#0000ff} -to 0 0 $iw $ih

ttk::style configure Bone.TButton
ttk::style element create Bone.image image [list $img1 pressed $img2
active $img3] -border {2 4} -sticky we
#ttk::style element create Bone.image image [list $img1 pressed $img2
active $img3] -border {2 4} -sticky snwe
ttk::style layout Bone.TButton [list Bone.image -sticky nswe
Button.text -sticky nswe]

set b1 [ttk::button .b1 -text "Button1" -style Bone.TButton]
set b2 [ttk::button .b2 -text "Button2"]

# Packe die Buttons
pack $b1 $b2
puts [ttk::style layout Bone.TButton ]
puts [ttk::style layout TButton ]

Subject: Re: change background of tkk::button on Windows?
From: Ralf Fassel
Newsgroups: comp.lang.tcl
Date: Thu, 30 May 2024 12:59 UTC
References: 1 2
Path: eternal-september.org!news.eternal-september.org!feeder3.eternal-september.org!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: ralfixx@gmx.de (Ralf Fassel)
Newsgroups: comp.lang.tcl
Subject: Re: change background of tkk::button on Windows?
Date: Thu, 30 May 2024 14:59:30 +0200
Lines: 29
Message-ID: <ygav82vqwul.fsf@akutech.de>
References: <ygacyp6ryxj.fsf@akutech.de> <v37ps1$188nu$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain
X-Trace: individual.net gnl+3yNB0XLc/6ABUjxvqA3Zv2yJ0RIrdzb2IfseacG4nLbww=
Cancel-Lock: sha1:8viNQFyiKatxnB2cltPnToTXw64= sha1:WO5VRCXhDd0lEBiLy2DiH5Bmr5M= sha256:VTv9nh3fqZ2KeigjjTYJb3jQWYt0fprQTwdXmun4MGE=
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
View all headers

* greg <gregor.ebbing@gmx.de>
| Am 28.05.24 um 12:52 schrieb Ralf Fassel:
| > tcl + tk 8.6.14
| > Windows 10
| > On *Windows*, how can I change the background of a ttk::button to
| > some color?
--<snip-snip>--
| Hello,
| As far as I understand, the winnative, xpnative and vista themes are
| limited in what you can change.
>
| https://wiki.tcl-lang.org/page/Ttk#67395ef1c74680130d5bdb83dbfe0426dc5c1a6a3a7ecdf4f591c0476fe58df6

Thanks greg, seems I'm not the only one going mad (but cleary this is
Microsofts fault this time :-) The documentation on Windows themes
seems limited to the MSDN manpages for the function calls.

| One option is to use a different theme.
| ttk::style theme names
| ttk::style theme use clam

Not an option here, L&F needs to be close to "modern" Windows native.
Eg using clam, many backgrounds are a darker grey than the rest of the
UI, so I get a checkerboard of light and dark backgrounds :-/

I fell back to using a regular Tk button with [-relief ridge] and the
font from the ttk-button, which is not optimal, but "close enough".

R'

1

rocksolid light 0.9.8
clearnet tor