Check the -indicatoron option for TCL *radiobuttons*.
Command-Line Name:-indicatoron
Database Name: indicatorOn
Database Class: IndicatorOn
Specifies whether or not the indicator should be drawn. Must be
a proper boolean value. If false, the -relief option is ignored
and the widget's relief is always sunken if the widget is se-
lected and raised otherwise.
Hello out there,
for a kinf´d of technical app I need a 'switch type' button - that is
a button stays pressed when pressed once and only gets released when
pressed again. (Whereas the normal GUI behaviour of buttons is more
the 'door bell' type).
I did come as far as keeping it pressed using the code below:
---
package require Tk
foreach ch [winfo children "."] {destroy $ch}
proc btnPress {w var} {
if {[set $var]} {
puts "calling 'tk::ButtonUp $w'"
tk::ButtonUp $w
set $var 0
} else {
puts "calling 'tk::ButtonDown $w'"
tk::ButtonDown $w
set $var 1
}
}
proc tst {} {
set btn [button .btn -width 3 -text ""]
pack $btn
set ::${btn}State 0
bind $btn <Button-1> [list btnPress %W ::${btn}State]
bind $btn <Enter> {break}
bind $btn <Leave> {break}
bind $btn <<Invoke>> {break}
bind $btn <Key-space> {break}
bind $btn <ButtonRelease-1> {break}
return $btn
}
set b [tst]
---
All the 'break' statements are for disabling the class bindings for
'Button'.
What I see is
- on the first press the ButtonDown message appears and the button
gets pressed
- on following presses I see the Up/Down messages appear as they
should - but my button never gets released again.
This is on Windows 10 and Tcl 8.6.10.
Any help will be greatly appreciated
Helmut
Hello out there,
for a kinf´d of technical app I need a 'switch type' button - that is
a button stays pressed when pressed once and only gets released when
pressed again. (Whereas the normal GUI behaviour of buttons is more
the 'door bell' type).
I did come as far as keeping it pressed using the code below:
---
package require Tk
foreach ch [winfo children "."] {destroy $ch}
proc btnPress {w var} {
if {[set $var]} {
puts "calling 'tk::ButtonUp $w'"
tk::ButtonUp $w
set $var 0
} else {
puts "calling 'tk::ButtonDown $w'"
tk::ButtonDown $w
set $var 1
}
}
proc tst {} {
set btn [button .btn -width 3 -text ""]
pack $btn
set ::${btn}State 0
bind $btn <Button-1> [list btnPress %W ::${btn}State]
bind $btn <Enter> {break}
bind $btn <Leave> {break}
bind $btn <<Invoke>> {break}
bind $btn <Key-space> {break}
bind $btn <ButtonRelease-1> {break}
return $btn
}
set b [tst]
---
All the 'break' statements are for disabling the class bindings for
'Button'.
What I see is
- on the first press the ButtonDown message appears and the button
gets pressed
- on following presses I see the Up/Down messages appear as they
should - but my button never gets released again.
This is on Windows 10 and Tcl 8.6.10.
Any help will be greatly appreciated
Helmut
On 4/17/2024 7:21 AM, Helmut Giese wrote:
Hello out there,
for a kinf´d of technical app I need a 'switch type' button - that is
a button stays pressed when pressed once and only gets released when
pressed again. (Whereas the normal GUI behaviour of buttons is more
the 'door bell' type).
Hello out there,Are you looking for a checkbutton instead? In this case is simply
for a kinf´d of technical app I need a 'switch type' button - that is
a button stays pressed when pressed once and only gets released when
pressed again. (Whereas the normal GUI behaviour of buttons is more
the 'door bell' type).
I did come as far as keeping it pressed using the code below:
---
package require Tk
foreach ch [winfo children "."] {destroy $ch}
proc btnPress {w var} {
if {[set $var]} {
puts "calling 'tk::ButtonUp $w'"
tk::ButtonUp $w
set $var 0
} else {
puts "calling 'tk::ButtonDown $w'"
tk::ButtonDown $w
set $var 1
}
}
proc tst {} {
set btn [button .btn -width 3 -text ""]
pack $btn
set ::${btn}State 0
bind $btn <Button-1> [list btnPress %W ::${btn}State]
bind $btn <Enter> {break}
bind $btn <Leave> {break}
bind $btn <<Invoke>> {break}
bind $btn <Key-space> {break}
bind $btn <ButtonRelease-1> {break}
return $btn
}
set b [tst]
---
All the 'break' statements are for disabling the class bindings for
'Button'.
What I see is
- on the first press the ButtonDown message appears and the button
gets pressed
- on following presses I see the Up/Down messages appear as they
should - but my button never gets released again.
This is on Windows 10 and Tcl 8.6.10.
Any help will be greatly appreciated
Helmut
Sysop: | DaiTengu |
---|---|
Location: | Appleton, WI |
Users: | 916 |
Nodes: | 10 (0 / 10) |
Uptime: | 00:34:32 |
Calls: | 12,172 |
Calls today: | 2 |
Files: | 186,522 |
Messages: | 2,234,814 |