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 ]
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)