Rocksolid Light

News from da outaworlds

mail  files  register  groups  login

Message-ID:  

Q: What is purple and conquered the world? A: Alexander the Grape.


comp / comp.lang.tcl / Re: How to do callbacks to methods

SubjectAuthor
* How to do callbacks to methodsMark Summerfield
+- Re: How to do callbacks to methodsMark Summerfield
`* Re: How to do callbacks to methodsgreg
 `- Re: How to do callbacks to methodsMark Summerfield

1
Subject: How to do callbacks to methods
From: Mark Summerfield
Newsgroups: comp.lang.tcl
Date: Thu, 11 Jul 2024 07:44 UTC
Path: eternal-september.org!news.eternal-september.org!feeder3.eternal-september.org!border-1.nntp.ord.giganews.com!border-4.nntp.ord.giganews.com!nntp.giganews.com!Xl.tags.giganews.com!local-2.nntp.ord.giganews.com!nntp.brightview.co.uk!news.brightview.co.uk.POSTED!not-for-mail
NNTP-Posting-Date: Thu, 11 Jul 2024 07:44:29 +0000
From: mark@qtrac.eu (Mark Summerfield)
Subject: How to do callbacks to methods
Newsgroups: comp.lang.tcl
MIME-Version: 1.0
User-Agent: Pan/0.154 (Izium; 517acf4)
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Message-ID: <CF2dndaVPsTAEBL7nZ2dnZfqn_YAAAAA@brightview.co.uk>
Date: Thu, 11 Jul 2024 07:44:29 +0000
Lines: 25
X-Usenet-Provider: http://www.giganews.com
X-Trace: sv3-nN6o1YjoS80nEzDnL4K4XRdk5jOr7MYVRzMC4eEnm28X9v/SRtCbclcDviGNe6z5BDO2gXh/Ro4EIaS!RHlQnIZZ5KnV2h9QMqp/wRE+Goxzi8yUcJ57i1CgJStu1xNG54tY92daCMgB1eI6yXZ0S4+3egKS!aJHMwz6ztna0JEYyHXMu+6q+8w==
X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly
X-Postfilter: 1.3.40
View all headers

In the app below none of the callbacks works, neither in the bind calls
nor the -command. I am using Tcl/Tk 9.0b2 on Linux. How can I make these
callbacks work?

#!/usr/bin/env wish9
tk appname "Test App"
oo::class create App {
constructor {} {
wm withdraw .
wm title . [tk appname]
grid [ttk::button .quitButton -text Quit -underline 0 \
-command {my on_quit}]
bind <Escape> {my on_quit}
bind <Alt-q> {my on_quit}
}
method on_quit {} {
destroy .
}
method show {} {
wm deiconify .
raise .
}
} set application [App new]
$application show

Subject: Re: How to do callbacks to methods
From: Mark Summerfield
Newsgroups: comp.lang.tcl
Date: Thu, 11 Jul 2024 08:04 UTC
References: 1
Path: eternal-september.org!news.eternal-september.org!feeder3.eternal-september.org!border-3.nntp.ord.giganews.com!nntp.giganews.com!Xl.tags.giganews.com!local-2.nntp.ord.giganews.com!nntp.brightview.co.uk!news.brightview.co.uk.POSTED!not-for-mail
NNTP-Posting-Date: Thu, 11 Jul 2024 08:04:56 +0000
From: mark@qtrac.eu (Mark Summerfield)
Subject: Re: How to do callbacks to methods
Newsgroups: comp.lang.tcl
References: <CF2dndaVPsTAEBL7nZ2dnZfqn_YAAAAA@brightview.co.uk>
MIME-Version: 1.0
User-Agent: Pan/0.154 (Izium; 517acf4)
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Message-ID: <CF2dndGVPsS1DxL7nZ2dnZfqn_adnZ2d@brightview.co.uk>
Date: Thu, 11 Jul 2024 08:04:56 +0000
Lines: 26
X-Usenet-Provider: http://www.giganews.com
X-Trace: sv3-ZbXoaSkq708u9H4/5sxrCqdJiWYs/VUSLLemxJIoKj1I2zPPoR+otlQrUXNS8yvLYMIlUDBu2jauA5d!s0fVGI17NIsFyW+fq+cezQ6vj5CQHonzJfFqhArB14UmfKZxo8yCC6jZfQ4lYeFnhu7tj1OcZxX0!ObFE+jB0134bCe2qcZsErEnjVA==
X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly
X-Postfilter: 1.3.40
View all headers

Sorry for the noise, I found the solution on the wiki:

#!/usr/bin/env wish9
proc ::oo::Helpers::callback {method args} {
list [uplevel 1 {namespace which my}] $method {*}$args
} tk appname "Test App"
oo::class create App {
constructor {} {
wm withdraw .
wm title . [tk appname]
grid [ttk::button .quitButton -text Quit -underline 0 \
-command [callback on_quit]]
bind . <Escape> [callback on_quit]
bind . <Alt-q> [callback on_quit]
}
method on_quit {} {
destroy .
}
method show {} {
wm deiconify .
raise .
}
} set application [App new]
$application show

Subject: Re: How to do callbacks to methods
From: greg
Newsgroups: comp.lang.tcl
Organization: A noiseless patient Spider
Date: Thu, 11 Jul 2024 10:17 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: How to do callbacks to methods
Date: Thu, 11 Jul 2024 12:17:08 +0200
Organization: A noiseless patient Spider
Lines: 62
Message-ID: <v6obf4$2dlc7$1@dont-email.me>
References: <CF2dndaVPsTAEBL7nZ2dnZfqn_YAAAAA@brightview.co.uk>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 11 Jul 2024 12:17:09 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="9be51c00966dfec898df4c40cc697fc1";
logging-data="2545031"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18Ac+ALPEnFbhiyArQ8EyGnzpW9xdGLggE="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:a5fWIwN7ozKr5jyzuanbQkz9FKc=
Content-Language: de-DE
In-Reply-To: <CF2dndaVPsTAEBL7nZ2dnZfqn_YAAAAA@brightview.co.uk>
View all headers

Am 11.07.24 um 09:44 schrieb Mark Summerfield:
> In the app below none of the callbacks works, neither in the bind calls
> nor the -command. I am using Tcl/Tk 9.0b2 on Linux. How can I make these
> callbacks work?
>
> #!/usr/bin/env wish9
> tk appname "Test App"
> oo::class create App {
> constructor {} {
> wm withdraw .
> wm title . [tk appname]
> grid [ttk::button .quitButton -text Quit -underline 0 \
> -command {my on_quit}]
> bind <Escape> {my on_quit}
> bind <Alt-q> {my on_quit}
> }
> method on_quit {} {
> destroy .
> }
> method show {} {
> wm deiconify .
> raise .
> }
> }
> set application [App new]
> $application show

Hello,
solution: callback
https://www.tcl.tk/man/tcl9.0/TclCmd/callback.html

package require Tk

# helpers proc for 8.6
#proc ::oo::Helpers::callback {method args} {
# list [uplevel 1 {namespace which my}] $method {*}$args
#}

#https://www.tcl.tk/man/tcl9.0/TclCmd/callback.html

tk appname "Test App"
oo::class create App {
constructor {} {
wm withdraw .
wm title . [tk appname]
grid [ttk::button .quitButton -text Quit -underline 0 \
-command [callback on_quit]]
bind <Escape> [callback on_quit]
bind <Alt-q> [callback on_quit]
}
method on_quit {} {
destroy .
}
method show {} {
wm deiconify .
raise .
}
} set application [App new]
$application show

Subject: Re: How to do callbacks to methods
From: Mark Summerfield
Newsgroups: comp.lang.tcl
Date: Fri, 12 Jul 2024 07:14 UTC
References: 1 2
Path: eternal-september.org!news.eternal-september.org!feeder3.eternal-september.org!border-1.nntp.ord.giganews.com!nntp.giganews.com!Xl.tags.giganews.com!local-1.nntp.ord.giganews.com!nntp.brightview.co.uk!news.brightview.co.uk.POSTED!not-for-mail
NNTP-Posting-Date: Fri, 12 Jul 2024 07:14:25 +0000
From: mark@qtrac.eu (Mark Summerfield)
Subject: Re: How to do callbacks to methods
Newsgroups: comp.lang.tcl
References: <CF2dndaVPsTAEBL7nZ2dnZfqn_YAAAAA@brightview.co.uk>
<v6obf4$2dlc7$1@dont-email.me>
MIME-Version: 1.0
User-Agent: Pan/0.154 (Izium; 517acf4)
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Message-ID: <Kf-dnTasu69MSg37nZ2dnZfqn_sAAAAA@brightview.co.uk>
Date: Fri, 12 Jul 2024 07:14:25 +0000
Lines: 1
X-Usenet-Provider: http://www.giganews.com
X-Trace: sv3-XprCOyLRVKoRjU2i0rfMBtf1xMi4esiGkIJxVueMPVgqS6zLoEColrrfE9z5YTr52o7YBRQeFLtGgkI!VOAMMmmAZBoGiOHRl05x7RmBlvLqwZHSpp5AUvfNPV//K0XAHiCBpekS+xFZsKxn9ckDdOfNd5S+!4eb6pH8YEbYT+7XIJ3ZlDPALvA==
X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly
X-Postfilter: 1.3.40
View all headers

Thank you!

1

rocksolid light 0.9.8
clearnet tor