Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

The unrecognized minister of propaganda, E -- seen in an email from Ean Schuessler


devel / comp.lang.tcl / Still the return problem

SubjectAuthor
* Still the return problemLuc
+* Still the return problemfr
|+- Still the return problemRobert Heller
|`- Still the return problemLuc
`- Still the return problemRobert Heller

1
Still the return problem

<20221106030341.3c50b9eb@lud1.home>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=10058&group=comp.lang.tcl#10058

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!aioe.org!lW5nFmRGy3LxgktjtQ+19A.user.46.165.242.75.POSTED!not-for-mail
From: no...@no.no (Luc)
Newsgroups: comp.lang.tcl
Subject: Still the return problem
Date: Sun, 6 Nov 2022 03:03:41 -0300
Organization: Aioe.org NNTP Server
Message-ID: <20221106030341.3c50b9eb@lud1.home>
Mime-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="4400"; posting-host="lW5nFmRGy3LxgktjtQ+19A.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
X-Notice: Filtered by postfilter v. 0.9.2
X-Newsreader: Claws Mail 3.14.1 (GTK+ 2.24.31; x86_64-pc-linux-gnu)
 by: Luc - Sun, 6 Nov 2022 06:03 UTC

I am back to the old problem.

Even if I make a "plain" page instead of a proc, I'd still need to be
able to output something and exit - exit the proc/function, not the
entire application. So the [exit] command is verboten.

Now, either way, there is a part of the proc/application where a new
widget pops up. That widget has to receive input, return it to the
parent application (the one I'm working on) so the parent can proceed.

I wrote this small prototype. Can you make the button return its
output and destroy this entire window?

Please remember this is supposed to be a child window. The parent
window must be kept alive.

namespace eval ::ops {}

proc ::ops::run {} {
# ----------------- MAKE WINDOW -----------------------
package require Tk
wm withdraw .
eval destroy [winfo children .]
catch {destroy .ops}
set ::ops::w [toplevel .ops]
wm resizable $::ops::w 1 1
# -------------- TEXT BOX --------------
text $::ops::w.textbox
set ::ops::TextBox $::ops::w.textbox
pack $::ops::TextBox -fill both -expand 1 -side left

$::ops::TextBox configure -background #ffffff -foreground #000000
$::ops::TextBox configure -width 30 -height 20
$::ops::TextBox configure -wrap none -font "Freesans 16" -padx 10 -pady 10
$::ops::TextBox configure -cursor arrow
$::ops::TextBox insert end "Some text that is invisible because the box is so small.\n"
$::ops::TextBox insert end "I don't know why the text box is so small."
focus $::ops::TextBox

button $::ops::w.textbox.button
$::ops::w.textbox.button configure -width 5 -height 2
$::ops::w.textbox.button configure -font "Freesans 16" -padx 4 -pady 4
$::ops::w.textbox.button configure -text "Push"
$::ops::w.textbox.button configure -command {return "Boom!"}
pack $::ops::w.textbox.button

bind $::ops::w <Escape> {exit 0}
wm protocol $::ops::w WM_DELETE_WINDOW {exit 0}
}

puts [::ops::run]

--
Luc
>>

Re: Still the return problem

<70c12da6-2e21-4ab2-9605-e813af771fc4n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=10060&group=comp.lang.tcl#10060

  copy link   Newsgroups: comp.lang.tcl
X-Received: by 2002:a0c:f5ca:0:b0:4bb:6f16:c0ca with SMTP id q10-20020a0cf5ca000000b004bb6f16c0camr39031295qvm.111.1667738108227;
Sun, 06 Nov 2022 04:35:08 -0800 (PST)
X-Received: by 2002:a05:620a:28cd:b0:6cf:93b3:a78 with SMTP id
l13-20020a05620a28cd00b006cf93b30a78mr32120628qkp.11.1667738108033; Sun, 06
Nov 2022 04:35:08 -0800 (PST)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.tcl
Date: Sun, 6 Nov 2022 04:35:07 -0800 (PST)
In-Reply-To: <20221106030341.3c50b9eb@lud1.home>
Injection-Info: google-groups.googlegroups.com; posting-host=80.187.96.154; posting-account=aaGzBAoAAADO0Qsz99jkqns7nnqZHQxI
NNTP-Posting-Host: 80.187.96.154
References: <20221106030341.3c50b9eb@lud1.home>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <70c12da6-2e21-4ab2-9605-e813af771fc4n@googlegroups.com>
Subject: Re: Still the return problem
From: zaw...@gmail.com (fr)
Injection-Date: Sun, 06 Nov 2022 12:35:08 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 3570
 by: fr - Sun, 6 Nov 2022 12:35 UTC

On Sunday, November 6, 2022 at 7:03:49 AM UTC+1, Luc wrote:
> I am back to the old problem.
>
> Even if I make a "plain" page instead of a proc, I'd still need to be
> able to output something and exit - exit the proc/function, not the
> entire application. So the [exit] command is verboten.
>
> Now, either way, there is a part of the proc/application where a new
> widget pops up. That widget has to receive input, return it to the
> parent application (the one I'm working on) so the parent can proceed.
>
> I wrote this small prototype. Can you make the button return its
> output and destroy this entire window?
>
> Please remember this is supposed to be a child window. The parent
> window must be kept alive.
>
>
> namespace eval ::ops {}
>
> proc ::ops::run {} {
> # ----------------- MAKE WINDOW -----------------------
> package require Tk
> wm withdraw .
> eval destroy [winfo children .]
> catch {destroy .ops}
> set ::ops::w [toplevel .ops]
> wm resizable $::ops::w 1 1
> # -------------- TEXT BOX --------------
> text $::ops::w.textbox
> set ::ops::TextBox $::ops::w.textbox
> pack $::ops::TextBox -fill both -expand 1 -side left
>
> $::ops::TextBox configure -background #ffffff -foreground #000000
> $::ops::TextBox configure -width 30 -height 20
> $::ops::TextBox configure -wrap none -font "Freesans 16" -padx 10 -pady 10
> $::ops::TextBox configure -cursor arrow
> $::ops::TextBox insert end "Some text that is invisible because the box is so small.\n"
> $::ops::TextBox insert end "I don't know why the text box is so small."
> focus $::ops::TextBox
>
> button $::ops::w.textbox.button
> $::ops::w.textbox.button configure -width 5 -height 2
> $::ops::w.textbox.button configure -font "Freesans 16" -padx 4 -pady 4
> $::ops::w.textbox.button configure -text "Push"
> $::ops::w.textbox.button configure -command {return "Boom!"}
> pack $::ops::w.textbox.button
>
> bind $::ops::w <Escape> {exit 0}
> wm protocol $::ops::w WM_DELETE_WINDOW {exit 0}
> }
>
> puts [::ops::run]
>
> --
> Luc
> >>
Hi Luc,
my untested suggestion:
catch {unset ::ops::result}
.... -command {set ::ops::result Boom}
and at end of proc instead of the 2 last lines - that end the process -
vwait ::ops::result
destroy $::ops::w
return $::ops::result

there is tk_dialog too, a modal dialog, that blocks interaction with other gui elements, so you won't need to hide the main window.
Roland

Re: Still the return problem

<95ucnV53dtsqMvr-nZ2dnZfqn_SdnZ2d@giganews.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=10061&group=comp.lang.tcl#10061

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border-2.nntp.ord.giganews.com!nntp.giganews.com!Xl.tags.giganews.com!local-1.nntp.ord.giganews.com!news.giganews.com.POSTED!not-for-mail
NNTP-Posting-Date: Sun, 06 Nov 2022 12:59:35 +0000
MIME-Version: 1.0
From: hel...@deepsoft.com (Robert Heller)
Organization: Deepwoods Software
X-Newsreader: TkNews 3.0 (1.2.15)
Subject: Re: Still the return problem
In-Reply-To: <20221106030341.3c50b9eb@lud1.home>
References: <20221106030341.3c50b9eb@lud1.home>
Newsgroups: comp.lang.tcl
Content-Type: text/plain;
charset="us-ascii"
Originator: heller@sharky4.deepsoft.com
Message-ID: <95ucnV53dtsqMvr-nZ2dnZfqn_SdnZ2d@giganews.com>
Date: Sun, 06 Nov 2022 12:59:35 +0000
Lines: 118
X-Usenet-Provider: http://www.giganews.com
X-Trace: sv3-iTxb/GDnkFdh1tCEwI62yqPJcIlhKYFSDLbfgCaRuYVr/qIk9L6RmWyGtRjjbXt0Dokiu7wTP2sX7Nw!Ma/OwBVenFgTeHBjy4VF50ci77vWARD7VrlYX+RinY3fbyOIwCn48KX4SrGBIbswpMJFyU+tnedq!Iec=
X-Complaints-To: abuse@giganews.com
X-DMCA-Notifications: http://www.giganews.com/info/dmca.html
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
 by: Robert Heller - Sun, 6 Nov 2022 12:59 UTC

At Sun, 6 Nov 2022 03:03:41 -0300 Luc <no@no.no> wrote:

>
> I am back to the old problem.
>
> Even if I make a "plain" page instead of a proc, I'd still need to be
> able to output something and exit - exit the proc/function, not the
> entire application. So the [exit] command is verboten.
>
> Now, either way, there is a part of the proc/application where a new
> widget pops up. That widget has to receive input, return it to the
> parent application (the one I'm working on) so the parent can proceed.
>
> I wrote this small prototype. Can you make the button return its
> output and destroy this entire window?
>
> Please remember this is supposed to be a child window. The parent
> window must be kept alive.
>
>
> namespace eval ::ops {}
>
> proc ::ops::run {} {
> # ----------------- MAKE WINDOW -----------------------
> package require Tk
> wm withdraw .
> eval destroy [winfo children .]
> catch {destroy .ops}
> set ::ops::w [toplevel .ops]
> wm resizable $::ops::w 1 1
> # -------------- TEXT BOX --------------
> text $::ops::w.textbox
> set ::ops::TextBox $::ops::w.textbox
> pack $::ops::TextBox -fill both -expand 1 -side left
>
> $::ops::TextBox configure -background #ffffff -foreground #000000
> $::ops::TextBox configure -width 30 -height 20
> $::ops::TextBox configure -wrap none -font "Freesans 16" -padx 10 -pady 10
> $::ops::TextBox configure -cursor arrow
> $::ops::TextBox insert end "Some text that is invisible because the box is so small.\n"
> $::ops::TextBox insert end "I don't know why the text box is so small."
> focus $::ops::TextBox
>
> button $::ops::w.textbox.button
> $::ops::w.textbox.button configure -width 5 -height 2
> $::ops::w.textbox.button configure -font "Freesans 16" -padx 4 -pady 4
> $::ops::w.textbox.button configure -text "Push"
> $::ops::w.textbox.button configure -command {return "Boom!"}
> pack $::ops::w.textbox.button
>
> bind $::ops::w <Escape> {exit 0}
> wm protocol $::ops::w WM_DELETE_WINDOW {exit 0}
> }
>
> puts [::ops::run]
>

OK, what you are creating is a clasic [modal] dialog box -- a popup toplevel
that "waits" for user input (and may process that input) and then when the
dialog box is done it is withdraw (to be re-used) or destroyed (if it is not
going to be reused) and finally returns some result to the calling program.

include this:

namespace eval ops {
variable w
variable result
}

include at the beginning of the proc:

variable w
variable result

Change the -command bound to the button to:

$::ops::w.textbox.button configure \
-command {set ::ops::result "Boom!"; destroy $::ops::w}

and replace the last two lines of the proc with:

bind $::ops:w <Escape> [list destroy $::ops::w]
set ::ops::result ""
tkwait window $::ops::w
return $::ops::result

Optional: look at the documentation for focus and grab -- the grab command
can be used to make your dialog box have exclusive control.

What happens is:

the proc ::ops::run *waits* for the toplevel to be destroyed (closing it by
default destroys it, as does <Escape> and your button). then returns whatever
is stored in the ::ops::result variable -- this would be the result you want
to return.

You can't randomly "return" a value directly from a button press inside a
dialog box (or really any sort of GUI effect -- keypress, mouse click, etc,.).
The way a "dialog box" type of thing works (has to work), the GUI action sets
a "global" variable (generally protected in a namespace or something), and
then the dialog box is destroyed. The invoking code *waits* for the dialog box
to finish either using "tkwait window ..." to wait for the dialog box to be
destroyed or "tkwait variable ..." to wait for the result variable (or a flag
variable) to be set or changed. The processing continues from the tkwait
command -- the proc encompansing the dialog box can then return a result to
the parent code.

--
Robert Heller -- Cell: 413-658-7953 GV: 978-633-5364
Deepwoods Software -- Custom Software Services
http://www.deepsoft.com/ -- Linux Administration Services
heller@deepsoft.com -- Webhosting Services

Re: Still the return problem

<T_qcnRh3cp-pL_r-nZ2dnZfqnPednZ2d@giganews.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=10062&group=comp.lang.tcl#10062

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!feeder.usenetexpress.com!tr1.iad1.usenetexpress.com!69.80.99.22.MISMATCH!Xl.tags.giganews.com!local-2.nntp.ord.giganews.com!news.giganews.com.POSTED!not-for-mail
NNTP-Posting-Date: Sun, 06 Nov 2022 13:10:12 +0000
MIME-Version: 1.0
From: hel...@deepsoft.com (Robert Heller)
Organization: Deepwoods Software
X-Newsreader: TkNews 3.0 (1.2.15)
Subject: Re: Still the return problem
In-Reply-To: <70c12da6-2e21-4ab2-9605-e813af771fc4n@googlegroups.com>
References: <20221106030341.3c50b9eb@lud1.home> <70c12da6-2e21-4ab2-9605-e813af771fc4n@googlegroups.com>
Newsgroups: comp.lang.tcl
Content-Type: text/plain; charset="us-ascii"
Originator: heller@sharky4.deepsoft.com
Message-ID: <T_qcnRh3cp-pL_r-nZ2dnZfqnPednZ2d@giganews.com>
Date: Sun, 06 Nov 2022 13:10:12 +0000
Lines: 50
X-Usenet-Provider: http://www.giganews.com
X-Trace: sv3-gE4oTNsymrGQtzenlTjvXAmSYWRIi6pkoihj137CZRiXoCLPhT/rxUwVNxUtf0ppAd1Yd+5QfbH+GO4!bT8FOZkIPbUXZxHkrIYTYfTUSLSJTV8mphR5+caeyYoJEt+hohOVmAJcbgfhOJAh2Clf83XdwdUO!L7Q=
X-Complaints-To: abuse@giganews.com
X-DMCA-Notifications: http://www.giganews.com/info/dmca.html
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
X-Received-Bytes: 2979
 by: Robert Heller - Sun, 6 Nov 2022 13:10 UTC

At Sun, 6 Nov 2022 04:35:07 -0800 (PST) fr <zawuni@gmail.com> wrote:

>
> On Sunday, November 6, 2022 at 7:03:49 AM UTC+1, Luc wrote:
> > I am back to the old problem.
> >
> > Even if I make a "plain" page instead of a proc, I'd still need to be
> > able to output something and exit - exit the proc/function, not the
> > entire application. So the [exit] command is verboten.
> >
> > Now, either way, there is a part of the proc/application where a new
> > widget pops up. That widget has to receive input, return it to the
> > parent application (the one I'm working on) so the parent can proceed.

> Hi Luc,
> my untested suggestion:
> catch {unset ::ops::result}
> ... -command {set ::ops::result Boom}
> and at end of proc instead of the 2 last lines - that end the process -
> vwait ::ops::result
> destroy $::ops::w
> return $::ops::result
>
> there is tk_dialog too, a modal dialog, that blocks interaction with other gui elements, so you won't need to hide the main window.
> Roland

The source code for tk_dialog should be located someplace like:

/usr/share/tcltk/tk8.6/dialog.tcl

on a typical Linux installation.

To vaugely misquote Obi Wan Knobie:

"Use the Source Luc"

The source code for tk_dialog is very verbosely documented and is very
instructive about how to do exactly what Luc wants to do.

>
>

--
Robert Heller -- Cell: 413-658-7953 GV: 978-633-5364
Deepwoods Software -- Custom Software Services
http://www.deepsoft.com/ -- Linux Administration Services
heller@deepsoft.com -- Webhosting Services

Re: Still the return problem

<20221108090857.052c063e@lud1.home>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=10091&group=comp.lang.tcl#10091

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!aioe.org!ybkfwvcKExdJLDzZTMMtag.user.46.165.242.75.POSTED!not-for-mail
From: no...@no.no (Luc)
Newsgroups: comp.lang.tcl
Subject: Re: Still the return problem
Date: Tue, 8 Nov 2022 09:08:57 -0300
Organization: Aioe.org NNTP Server
Message-ID: <20221108090857.052c063e@lud1.home>
References: <20221106030341.3c50b9eb@lud1.home>
<70c12da6-2e21-4ab2-9605-e813af771fc4n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="41191"; posting-host="ybkfwvcKExdJLDzZTMMtag.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
X-Newsreader: Claws Mail 3.14.1 (GTK+ 2.24.31; x86_64-pc-linux-gnu)
X-Notice: Filtered by postfilter v. 0.9.2
 by: Luc - Tue, 8 Nov 2022 12:08 UTC

Hello guys. I've been busy with work and had to put the Tcl/Tk project
in the back burner for a few days, but I'd like to thank you for the
generous assistance. The solutions did help, that old problem is solved,
the project made more progress and I will be back to it as soon as I can.

Thank you again.

--
Luc
>>
**************************
On Sun, 6 Nov 2022 04:35:07 -0800 (PST), fr wrote:

> On Sunday, November 6, 2022 at 7:03:49 AM UTC+1, Luc wrote:
> > I am back to the old problem.
> >
> > Even if I make a "plain" page instead of a proc, I'd still need to be
> > able to output something and exit - exit the proc/function, not the
> > entire application. So the [exit] command is verboten.
> >
> > Now, either way, there is a part of the proc/application where a new
> > widget pops up. That widget has to receive input, return it to the
> > parent application (the one I'm working on) so the parent can proceed.
> >
> > I wrote this small prototype. Can you make the button return its
> > output and destroy this entire window?
> >
> > Please remember this is supposed to be a child window. The parent
> > window must be kept alive.
> >
> >
> > namespace eval ::ops {}
> >
> > proc ::ops::run {} {
> > # ----------------- MAKE WINDOW -----------------------
> > package require Tk
> > wm withdraw .
> > eval destroy [winfo children .]
> > catch {destroy .ops}
> > set ::ops::w [toplevel .ops]
> > wm resizable $::ops::w 1 1
> > # -------------- TEXT BOX --------------
> > text $::ops::w.textbox
> > set ::ops::TextBox $::ops::w.textbox
> > pack $::ops::TextBox -fill both -expand 1 -side left
> >
> > $::ops::TextBox configure -background #ffffff -foreground #000000
> > $::ops::TextBox configure -width 30 -height 20
> > $::ops::TextBox configure -wrap none -font "Freesans 16" -padx 10 -pady
> > 10 $::ops::TextBox configure -cursor arrow
> > $::ops::TextBox insert end "Some text that is invisible because the box
> > is so small.\n" $::ops::TextBox insert end "I don't know why the text
> > box is so small." focus $::ops::TextBox
> >
> > button $::ops::w.textbox.button
> > $::ops::w.textbox.button configure -width 5 -height 2
> > $::ops::w.textbox.button configure -font "Freesans 16" -padx 4 -pady 4
> > $::ops::w.textbox.button configure -text "Push"
> > $::ops::w.textbox.button configure -command {return "Boom!"}
> > pack $::ops::w.textbox.button
> >
> > bind $::ops::w <Escape> {exit 0}
> > wm protocol $::ops::w WM_DELETE_WINDOW {exit 0}
> > }
> >
> > puts [::ops::run]
> >
> > --
> > Luc
> > >>
> Hi Luc,
> my untested suggestion:
> catch {unset ::ops::result}
> ... -command {set ::ops::result Boom}
> and at end of proc instead of the 2 last lines - that end the process -
> vwait ::ops::result
> destroy $::ops::w
> return $::ops::result
>
> there is tk_dialog too, a modal dialog, that blocks interaction with
> other gui elements, so you won't need to hide the main window. Roland
************************

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor