Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  nodelist  faq  login

Avoid strange women and temporary variables.


programming / comp.lang.tcl / Re: Looking for non-modal alternatives to tk_messageBox

SubjectAuthor
* Looking for non-modal alternatives to tk_messageBoxMichael Soyka
`* Re: Looking for non-modal alternatives to tk_messageBoxsaitology9
 `* Re: Looking for non-modal alternatives to tk_messageBoxMichael Soyka
  +* Re: Looking for non-modal alternatives to tk_messageBoxAndreas Leitgeb
  |`* Re: Looking for non-modal alternatives to tk_messageBoxRobert Heller
  | +- Re: Looking for non-modal alternatives to tk_messageBoxMichael Soyka
  | `* Re: Looking for non-modal alternatives to tk_messageBoxMichael Soyka
  |  +- Re: Looking for non-modal alternatives to tk_messageBoxRobert Heller
  |  `* Re: Looking for non-modal alternatives to tk_messageBoxsaitology9
  |   +* Re: Looking for non-modal alternatives to tk_messageBoxRobert Heller
  |   |+* Re: Looking for non-modal alternatives to tk_messageBoxMichael Soyka
  |   ||`- Re: Looking for non-modal alternatives to tk_messageBoxRobert Heller
  |   |`- Re: Looking for non-modal alternatives to tk_messageBoxsaitology9
  |   `* Re: Looking for non-modal alternatives to tk_messageBoxSchelte
  |    +* Re: Looking for non-modal alternatives to tk_messageBoxsaitology9
  |    |`* Re: Looking for non-modal alternatives to tk_messageBoxAndreas Leitgeb
  |    | `- Re: Looking for non-modal alternatives to tk_messageBoxRich
  |    `- Re: Looking for non-modal alternatives to tk_messageBoxsaitology9
  +- Re: Looking for non-modal alternatives to tk_messageBoxjtyler
  `* Re: Looking for non-modal alternatives to tk_messageBoxsaitology9
   +- Re: Looking for non-modal alternatives to tk_messageBoxMichael Soyka
   `* Re: Looking for non-modal alternatives to tk_messageBoxAndreas Leitgeb
    `* Re: Looking for non-modal alternatives to tk_messageBoxMichael Soyka
     +- Re: Looking for non-modal alternatives to tk_messageBoxRobert Heller
     `* Re: Looking for non-modal alternatives to tk_messageBoxsaitology9
      `* Re: Looking for non-modal alternatives to tk_messageBoxjtyler
       `- Re: Looking for non-modal alternatives to tk_messageBoxSchelte

Pages:12
Subject: Looking for non-modal alternatives to tk_messageBox
From: Michael Soyka
Newsgroups: comp.lang.tcl
Date: Fri, 15 Apr 2022 01:54 UTC
X-Received: by 2002:ac8:7614:0:b0:2ed:c70:604c with SMTP id t20-20020ac87614000000b002ed0c70604cmr3988328qtq.391.1649987662836;
Thu, 14 Apr 2022 18:54:22 -0700 (PDT)
X-Received: by 2002:a05:6808:bd3:b0:2ec:f542:4a7c with SMTP id
o19-20020a0568080bd300b002ecf5424a7cmr695857oik.178.1649987662617; Thu, 14
Apr 2022 18:54:22 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.tcl
Date: Thu, 14 Apr 2022 18:54:22 -0700 (PDT)
Injection-Info: google-groups.googlegroups.com; posting-host=24.38.189.127; posting-account=BNremgoAAAA8qNSnkohRhaCVs-73LJUv
NNTP-Posting-Host: 24.38.189.127
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <10556088-a5a7-429c-80e7-81bf1ffaa3f6n@googlegroups.com>
Subject: Looking for non-modal alternatives to tk_messageBox
From: mssr...@gmail.com (Michael Soyka)
Injection-Date: Fri, 15 Apr 2022 01:54:22 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Lines: 14
View all headers
I have a Tk application that runs diagnostics on a remote system.  It displays the tests and test results in a text widget.  When a test fails, the operator is notified using tk_messageBox and given the option of rerunning or bypassing the test (retry/cancel).  To make a decision the operator reviews the information displayed in the text widget which could involve engaging the scrollbar.  However, the scrollbar is unresponsive, I assume because tk_messageBox is blocking the event loop.

I've addressed this problem by writing my own tk_messageBox that uses tkwait but, being intellectually curious, I'd like to know what alternatives might exist.  They could be existing packages or some design choice that permits the use of tk_messageBox but any other suggestions would be welcomed.

Thanks in advance,
-mike


Subject: Re: Looking for non-modal alternatives to tk_messageBox
From: saitolo...@gmail.com
Newsgroups: comp.lang.tcl
Organization: Aioe.org NNTP Server
Date: Fri, 15 Apr 2022 02:29 UTC
References: 1
Path: i2pn2.org!i2pn.org!aioe.org!a5rWVvs5S5ZXUwkNcVnRMw.user.46.165.242.91.POSTED!not-for-mail
From: saitolo...@gmail.com
Newsgroups: comp.lang.tcl
Subject: Re: Looking for non-modal alternatives to tk_messageBox
Date: Thu, 14 Apr 2022 22:29:40 -0400
Organization: Aioe.org NNTP Server
Message-ID: <t3alak$6o6$1@gioia.aioe.org>
References: <10556088-a5a7-429c-80e7-81bf1ffaa3f6n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="6918"; posting-host="a5rWVvs5S5ZXUwkNcVnRMw.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.6.1
X-Notice: Filtered by postfilter v. 0.9.2
Content-Language: en-US
View all headers
On 4/14/22 9:54 PM, Michael Soyka wrote:

I've addressed this problem by writing my own tk_messageBox that uses tkwait but, being intellectually curious, I'd like to know what alternatives might exist.  They could be existing packages or some design choice that permits the use of tk_messageBox but any other suggestions would be welcomed.


Hello,

I am sure most everybody has faced the same and come up with a similar solution. However, it is good to point out that you can achieve your goal with the built-in tk_messageBox.  Here is a quick example:

package req Tk

toplevel .hidden
wm withdraw .hidden

# rest of your script

tk_messageBox -message "Not blocking anything..." -parent .hidden




Subject: Re: Looking for non-modal alternatives to tk_messageBox
From: Michael Soyka
Newsgroups: comp.lang.tcl
Date: Fri, 15 Apr 2022 19:53 UTC
References: 1 2
X-Received: by 2002:a05:620a:2946:b0:67b:3047:6d9d with SMTP id n6-20020a05620a294600b0067b30476d9dmr332996qkp.691.1650052419577;
Fri, 15 Apr 2022 12:53:39 -0700 (PDT)
X-Received: by 2002:a05:6870:c084:b0:e2:c07d:7ee6 with SMTP id
c4-20020a056870c08400b000e2c07d7ee6mr2048982oad.234.1650052419354; Fri, 15
Apr 2022 12:53:39 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.tcl
Date: Fri, 15 Apr 2022 12:53:39 -0700 (PDT)
In-Reply-To: <t3alak$6o6$1@gioia.aioe.org>
Injection-Info: google-groups.googlegroups.com; posting-host=24.38.189.127; posting-account=BNremgoAAAA8qNSnkohRhaCVs-73LJUv
NNTP-Posting-Host: 24.38.189.127
References: <10556088-a5a7-429c-80e7-81bf1ffaa3f6n@googlegroups.com> <t3alak$6o6$1@gioia.aioe.org>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <b2e1d5fd-e709-4a2e-8330-417f5db860a2n@googlegroups.com>
Subject: Re: Looking for non-modal alternatives to tk_messageBox
From: mssr...@gmail.com (Michael Soyka)
Injection-Date: Fri, 15 Apr 2022 19:53:39 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Lines: 35
View all headers
On Thursday, April 14, 2022 at 10:29:45 PM UTC-4, saito...@gmail.com wrote:
On 4/14/22 9:54 PM, Michael Soyka wrote:

I've addressed this problem by writing my own tk_messageBox that uses tkwait but, being intellectually curious, I'd like to know what alternatives might exist. They could be existing packages or some design choice that permits the use of tk_messageBox but any other suggestions would be welcomed.

Hello,

I am sure most everybody has faced the same and come up with a similar
solution. However, it is good to point out that you can achieve your
goal with the built-in tk_messageBox. Here is a quick example:

package req Tk

toplevel .hidden
wm withdraw .hidden

# rest of your script

tk_messageBox -message "Not blocking anything..." -parent .hidden

I don't see how this makes tk_messageBox usable in my context. If the window is withdrawn while the message box exists, the operator can't review the text widget contents.
Please explain how this helps.

Also, I would guess that tk_messageBox blocks the event loop whether or not the -parent option is specified.  Perhaps its effect on the event loop should be mentioned in the documentation, unless I'm missing something (wouldn't be the first time!).

Nonetheless, thank you for responding,
-mike


Subject: Re: Looking for non-modal alternatives to tk_messageBox
From: Andreas Leitgeb
Newsgroups: comp.lang.tcl
Organization: A noiseless patient Spider
Date: Fri, 15 Apr 2022 20:37 UTC
References: 1 2 3
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: avl...@logic.at (Andreas Leitgeb)
Newsgroups: comp.lang.tcl
Subject: Re: Looking for non-modal alternatives to tk_messageBox
Date: Fri, 15 Apr 2022 20:37:26 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 40
Message-ID: <slrnt5jls6.10f1.avl@logic.at>
References: <10556088-a5a7-429c-80e7-81bf1ffaa3f6n@googlegroups.com>
<t3alak$6o6$1@gioia.aioe.org>
<b2e1d5fd-e709-4a2e-8330-417f5db860a2n@googlegroups.com>
Reply-To: avl@logic.at
Injection-Date: Fri, 15 Apr 2022 20:37:26 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="17b87b4e77ca008cfb7762ef7005ac6d";
logging-data="1456"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19ubMQRXWFkXOOUopZ/E3yy"
User-Agent: slrn/1.0.3 (Linux)
Cancel-Lock: sha1:RS0zJyq5OpkM0rvzpNFus6vm+5s=
View all headers
Michael Soyka <mssr953@gmail.com> wrote:
Also, I would guess that tk_messageBox blocks the event loop whether or
not the -parent option is specified.

You would guess effectively right, but in detail it runs it's
own message loop and specifically suppresses gui-events for
anything but itself.

Anyway, a messageBox without "modality" is just a toplevel with
a message widget and a couple of buttons arranged in frames...

I vaguely remember times when tk_messageBox was itself just a
procedure setting up the complete dialog.

It is still a procedure, but nowadays only a wrapper for
::tk::MessageBox, which itself cannot be inspected as a proc.

Using my standard debug-trick when running wish from a terminal
window (on linux. might not work on purely graphical OSes):
% fileevent stdin readable { puts stderr "[catch [gets stdin] r]: $r" }

now:
% ::tk::MessageBox -message message -detail detail -title title
   # dialog pops up - wish's own repl is busy, but filevent stdin still fires.
winfo children .
0: .__tk__messagebox
winfo children .__tk__messagebox
0: .__tk__messagebox.bot .__tk__messagebox.top .__tk__messagebox.msg
..__tk__messagebox.dtl .__tk__messagebox.bitmap .__tk__messagebox.ok
winfo class .__tk__messagebox.bot
0: TFrame
winfo class .__tk__messagebox.msg
0: TLabel
winfo class .__tk__messagebox.dtl
0: TLabel
..__tk__messagebox.dtl conf
0: {-background ...[too long]

and step by step one could examine the actual layout and recreate it.



Subject: Re: Looking for non-modal alternatives to tk_messageBox
From: jtyler
Newsgroups: comp.lang.tcl
Organization: Aioe.org NNTP Server
Date: Fri, 15 Apr 2022 21:39 UTC
References: 1 2 3
Path: i2pn2.org!i2pn.org!aioe.org!YN2ulY6LKp1eoOUw2OJ8ig.user.46.165.242.91.POSTED!not-for-mail
From: jtyler...@gmail.com (jtyler)
Newsgroups: comp.lang.tcl
Subject: Re: Looking for non-modal alternatives to tk_messageBox
Date: Fri, 15 Apr 2022 14:39:29 -0700
Organization: Aioe.org NNTP Server
Message-ID: <t3comh$vth$1@gioia.aioe.org>
References: <10556088-a5a7-429c-80e7-81bf1ffaa3f6n@googlegroups.com>
<t3alak$6o6$1@gioia.aioe.org>
<b2e1d5fd-e709-4a2e-8330-417f5db860a2n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="32689"; posting-host="YN2ulY6LKp1eoOUw2OJ8ig.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.7.0
Content-Language: en-US
X-Notice: Filtered by postfilter v. 0.9.2
View all headers
On 4/15/2022 12:53 PM, Michael Soyka wrote:
On Thursday, April 14, 2022 at 10:29:45 PM UTC-4, saito...@gmail.com wrote:
On 4/14/22 9:54 PM, Michael Soyka wrote:

I've addressed this problem by writing my own tk_messageBox that uses tkwait but, being intellectually curious, I'd like to know what alternatives might exist. They could be existing packages or some design choice that permits the use of tk_messageBox but any other suggestions would be welcomed.

Hello,

I am sure most everybody has faced the same and come up with a similar
solution. However, it is good to point out that you can achieve your
goal with the built-in tk_messageBox. Here is a quick example:

package req Tk

toplevel .hidden
wm withdraw .hidden

# rest of your script

tk_messageBox -message "Not blocking anything..." -parent .hidden

I don't see how this makes tk_messageBox usable in my context. If the window is withdrawn while the message box exists, the operator can't review the text widget contents.
Please explain how this helps.

Also, I would guess that tk_messageBox blocks the event loop whether or not the -parent option is specified.  Perhaps its effect on the event loop should be mentioned in the documentation, unless I'm missing something (wouldn't be the first time!).

Nonetheless, thank you for responding,
-mike

It is the new toplevel window .hidden which is withdrawn, not your text widget which would be in another window, most likely using the . window.

Notice the -parent .hidden, which makes the message box part of the new toplevel. I confess to not fully understanding why this works, I'm gonna guess that separate toplevels are the key.

Another way, but probably overkill, since the above seems to work just as well, would be to do the message box in a separate thread. Threads have their own event loop which is separate from the one in the main thread.


Subject: Re: Looking for non-modal alternatives to tk_messageBox
From: Robert Heller
Newsgroups: comp.lang.tcl
Organization: Deepwoods Software
Date: Fri, 15 Apr 2022 21:52 UTC
References: 1
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!buffer2.nntp.dca1.giganews.com!buffer1.nntp.dca1.giganews.com!news.giganews.com.POSTED!not-for-mail
NNTP-Posting-Date: Fri, 15 Apr 2022 16:52:05 -0500
MIME-Version: 1.0
From: hel...@deepsoft.com (Robert Heller)
Organization: Deepwoods Software
X-Newsreader: TkNews 3.0 (1.2.12)
Subject: Re: Looking for non-modal alternatives to tk_messageBox
In-Reply-To: <slrnt5jls6.10f1.avl@logic.at>
References: <10556088-a5a7-429c-80e7-81bf1ffaa3f6n@googlegroups.com>?
<t3alak$6o6$1@gioia.aioe.org>?
<b2e1d5fd-e709-4a2e-8330-417f5db860a2n@googlegroups.com>
<slrnt5jls6.10f1.avl@logic.at>
Newsgroups: comp.lang.tcl
Content-Type: text/plain;
charset="us-ascii"
Originator: heller@sharky4.deepsoft.com
Message-ID: <YZydnRDrw9GYdMT_nZ2dnUU7-fPNnZ2d@giganews.com>
Date: Fri, 15 Apr 2022 16:52:05 -0500
Lines: 104
X-Usenet-Provider: http://www.giganews.com
X-Trace: sv3-MUpgCU3rzZJD8MIuh45XA3BECP2rUZLmAtkKs4LfiJPViKb7JMb1YDWKjSY/8gr7STmf6qZ/eNPX7Ii!IkjLz1HIPx+e5kBjUQcoTvM74033hFUJkkssKt8MCxeEKz6MdBxQ9w3V6mhRzBevmU4MizM7im1t!ZWQ=
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-Original-Bytes: 5506
View all headers
At Fri, 15 Apr 2022 20:37:26 -0000 (UTC) Andreas Leitgeb <avl@logic.at> wrote:


Michael Soyka <mssr953@gmail.com> wrote:
Also, I would guess that tk_messageBox blocks the event loop whether or
not the -parent option is specified.

You would guess effectively right, but in detail it runs it's
own message loop and specifically suppresses gui-events for
anything but itself.

No, it just does a "grab":

grab(3tk)                    Tk Built-In Commands                    grab(3tk)

______________________________________________________________________________

NAME
       grab - Confine pointer and keyboard events to a window sub-tree

SYNOPSIS
       grab ?-global? window

       grab option ?arg arg ...?
______________________________________________________________________________

DESCRIPTION
       This command implements simple pointer and keyboard grabs for Tk.  Tk's
       grabs are different than the grabs described in the Xlib documentation.
       When  a  grab  is set for a particular window, Tk restricts all pointer
       events to the grab window and its descendants in Tk's window hierarchy.
       Whenever  the  pointer is within the grab window's subtree, the pointer
       will behave exactly the same as if there had been no grab  at  all  and
       all events will be reported in the normal fashion.  When the pointer is
       outside window's tree, button presses and  releases  and  mouse  motion
       events  are reported to window, and window entry and window exit events
       are ignored. The grab subtree "owns" the pointer: windows  outside  the
       grab subtree will be visible on the screen but they will be insensitive
       until the grab is released.  The tree of windows  underneath  the  grab
       window  can  include top-level windows, in which case all of those top-
       level windows and their descendants  will  continue  to  receive  mouse
       events during the grab.
                                  
Basically, a modal toplevel does this:

    toplevel .foo
    (build the rest of .foo)
    set oldgrab [grab current .foo]
    grab .foo
    set oldfocus [focus]
    focus .foo
    tkwait window .foo;# could wait on a global set by a close/cancel button.
    if {$oldgrab ne {}} {
        grab $oldgrab
    }
    if {$oldfocus ne {}} {
        focus $oldfocus
    }

Removing all of the grab infrastructure and tossing the tkwait, yields a
non-modal toplevel.


Anyway, a messageBox without "modality" is just a toplevel with
a message widget and a couple of buttons arranged in frames...

I vaguely remember times when tk_messageBox was itself just a
procedure setting up the complete dialog.

It is still a procedure, but nowadays only a wrapper for
::tk::MessageBox, which itself cannot be inspected as a proc.

Using my standard debug-trick when running wish from a terminal
window (on linux. might not work on purely graphical OSes):
% fileevent stdin readable { puts stderr "[catch [gets stdin] r]: $r" }

now:
% ::tk::MessageBox -message message -detail detail -title title
   # dialog pops up - wish's own repl is busy, but filevent stdin still fires.
winfo children .
0: .__tk__messagebox
winfo children .__tk__messagebox
0: .__tk__messagebox.bot .__tk__messagebox.top .__tk__messagebox.msg
.__tk__messagebox.dtl .__tk__messagebox.bitmap .__tk__messagebox.ok
winfo class .__tk__messagebox.bot
0: TFrame
winfo class .__tk__messagebox.msg
0: TLabel
winfo class .__tk__messagebox.dtl
0: TLabel
.__tk__messagebox.dtl conf
0: {-background ...[too long]

and step by step one could examine the actual layout and recreate it.

                                                                                                                  


--
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
                                 


Subject: Re: Looking for non-modal alternatives to tk_messageBox
From: saitolo...@gmail.com
Newsgroups: comp.lang.tcl
Organization: Aioe.org NNTP Server
Date: Sat, 16 Apr 2022 00:07 UTC
References: 1 2 3
Path: i2pn2.org!i2pn.org!aioe.org!a5rWVvs5S5ZXUwkNcVnRMw.user.46.165.242.91.POSTED!not-for-mail
From: saitolo...@gmail.com
Newsgroups: comp.lang.tcl
Subject: Re: Looking for non-modal alternatives to tk_messageBox
Date: Fri, 15 Apr 2022 20:07:04 -0400
Organization: Aioe.org NNTP Server
Message-ID: <t3d1bc$1o1h$1@gioia.aioe.org>
References: <10556088-a5a7-429c-80e7-81bf1ffaa3f6n@googlegroups.com>
<t3alak$6o6$1@gioia.aioe.org>
<b2e1d5fd-e709-4a2e-8330-417f5db860a2n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="57393"; posting-host="a5rWVvs5S5ZXUwkNcVnRMw.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.6.1
X-Notice: Filtered by postfilter v. 0.9.2
Content-Language: en-US
View all headers
On 4/15/22 3:53 PM, Michael Soyka wrote:

package req Tk

toplevel .hidden
wm withdraw .hidden

# rest of your script

tk_messageBox -message "Not blocking anything..." -parent .hidden


Hello,

Did you try it?  It should have worked.

As jtyler explained in his reply, there are a couple of more lines to add to your code.  They create a new toplevel, and immediately hide it.   Then when you call tk_messageBox, you use that toplevel as the parent.

As to why it works, message and dialog boxes are assumed to be "modal"; i.e., the rough idea is that they are meant to interrupt the current flow of program/user actions and wait for a "decision" to be made before proceeding.  They achieve this by blocking interactivity on the toplevel window identified as parent (either implicitly or explicitly).  This is done via a grab as explained by Robert Heller in another reply. However, that block is local to that single toplevel window only.  That is why your code would not allow the user to scroll up/down or do anything else in the main window while the message box was displayed.

However, you can create a new toplevel and set it as the parent of the tk_messageBox.  Since the new toplevel is not displayed at all, the message box will just sit there all by its lonely self without blocking anything that belongs in your actual script.




Subject: Re: Looking for non-modal alternatives to tk_messageBox
From: Michael Soyka
Newsgroups: comp.lang.tcl
Date: Sat, 16 Apr 2022 00:48 UTC
References: 1 2 3 4
X-Received: by 2002:a05:620a:2683:b0:69c:8c9c:5f80 with SMTP id c3-20020a05620a268300b0069c8c9c5f80mr897404qkp.367.1650070106615;
Fri, 15 Apr 2022 17:48:26 -0700 (PDT)
X-Received: by 2002:a05:6870:d294:b0:e1:936a:7145 with SMTP id
d20-20020a056870d29400b000e1936a7145mr2357867oae.220.1650070106400; Fri, 15
Apr 2022 17:48:26 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!1.us.feeder.erje.net!3.us.feeder.erje.net!feeder.erje.net!border1.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.tcl
Date: Fri, 15 Apr 2022 17:48:26 -0700 (PDT)
In-Reply-To: <t3d1bc$1o1h$1@gioia.aioe.org>
Injection-Info: google-groups.googlegroups.com; posting-host=24.38.189.127; posting-account=BNremgoAAAA8qNSnkohRhaCVs-73LJUv
NNTP-Posting-Host: 24.38.189.127
References: <10556088-a5a7-429c-80e7-81bf1ffaa3f6n@googlegroups.com>
<t3alak$6o6$1@gioia.aioe.org> <b2e1d5fd-e709-4a2e-8330-417f5db860a2n@googlegroups.com>
<t3d1bc$1o1h$1@gioia.aioe.org>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <7b09e697-e952-44ca-8938-a5dc16b5b587n@googlegroups.com>
Subject: Re: Looking for non-modal alternatives to tk_messageBox
From: mssr...@gmail.com (Michael Soyka)
Injection-Date: Sat, 16 Apr 2022 00:48:26 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 39
View all headers
On Friday, April 15, 2022 at 8:07:16 PM UTC-4, saito...@gmail.com wrote:
On 4/15/22 3:53 PM, Michael Soyka wrote:

package req Tk

toplevel .hidden
wm withdraw .hidden

# rest of your script

tk_messageBox -message "Not blocking anything..." -parent .hidden

Hello,

Did you try it? It should have worked.

My apologies, it does work as you've described. 
When I tried your suggestion I was under the misconception that my text widget would be part of .hidden.


As jtyler explained in his reply, there are a couple of more lines to
add to your code. They create a new toplevel, and immediately hide it.
Then when you call tk_messageBox, you use that toplevel as the parent.

As to why it works, message and dialog boxes are assumed to be "modal";
i.e., the rough idea is that they are meant to interrupt the current
flow of program/user actions and wait for a "decision" to be made before
proceeding. They achieve this by blocking interactivity on the toplevel
window identified as parent (either implicitly or explicitly). This is
done via a grab as explained by Robert Heller in another reply.
However, that block is local to that single toplevel window only. That
is why your code would not allow the user to scroll up/down or do
anything else in the main window while the message box was displayed.

However, you can create a new toplevel and set it as the parent of the
tk_messageBox. Since the new toplevel is not displayed at all, the
message box will just sit there all by its lonely self without blocking
anything that belongs in your actual script.

Again, thanks for taking the time to explain.


Subject: Re: Looking for non-modal alternatives to tk_messageBox
From: Michael Soyka
Newsgroups: comp.lang.tcl
Date: Sat, 16 Apr 2022 00:55 UTC
References: 1 2 3 4 5
X-Received: by 2002:a05:6214:d42:b0:441:831b:fa1b with SMTP id 2-20020a0562140d4200b00441831bfa1bmr943962qvr.130.1650070530580;
Fri, 15 Apr 2022 17:55:30 -0700 (PDT)
X-Received: by 2002:a05:6808:1719:b0:2f9:ac49:842d with SMTP id
bc25-20020a056808171900b002f9ac49842dmr2711537oib.234.1650070530315; Fri, 15
Apr 2022 17:55:30 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!1.us.feeder.erje.net!feeder.erje.net!border1.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.tcl
Date: Fri, 15 Apr 2022 17:55:30 -0700 (PDT)
In-Reply-To: <YZydnRDrw9GYdMT_nZ2dnUU7-fPNnZ2d@giganews.com>
Injection-Info: google-groups.googlegroups.com; posting-host=24.38.189.127; posting-account=BNremgoAAAA8qNSnkohRhaCVs-73LJUv
NNTP-Posting-Host: 24.38.189.127
References: <10556088-a5a7-429c-80e7-81bf1ffaa3f6n@googlegroups.com>
<t3alak$6o6$1@gioia.aioe.org> <b2e1d5fd-e709-4a2e-8330-417f5db860a2n@googlegroups.com>
<slrnt5jls6.10f1.avl@logic.at> <YZydnRDrw9GYdMT_nZ2dnUU7-fPNnZ2d@giganews.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <f17555cb-807d-4838-bb01-dff47e9ea980n@googlegroups.com>
Subject: Re: Looking for non-modal alternatives to tk_messageBox
From: mssr...@gmail.com (Michael Soyka)
Injection-Date: Sat, 16 Apr 2022 00:55:30 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 70
View all headers
On Friday, April 15, 2022 at 5:52:14 PM UTC-4, Robert Heller wrote:
At Fri, 15 Apr 2022 20:37:26 -0000 (UTC) Andreas Leitgeb <a...@logic.at> wrote:


Michael Soyka <mss...@gmail.com> wrote:
Also, I would guess that tk_messageBox blocks the event loop whether or
not the -parent option is specified.

You would guess effectively right, but in detail it runs it's
own message loop and specifically suppresses gui-events for
anything but itself.
No, it just does a "grab":

grab(3tk) Tk Built-In Commands grab(3tk)

______________________________________________________________________________

NAME
grab - Confine pointer and keyboard events to a window sub-tree

SYNOPSIS
grab ?-global? window

grab option ?arg arg ...?
______________________________________________________________________________

DESCRIPTION
This command implements simple pointer and keyboard grabs for Tk. Tk's
grabs are different than the grabs described in the Xlib documentation.
When a grab is set for a particular window, Tk restricts all pointer
events to the grab window and its descendants in Tk's window hierarchy.
Whenever the pointer is within the grab window's subtree, the pointer
will behave exactly the same as if there had been no grab at all and
all events will be reported in the normal fashion. When the pointer is
outside window's tree, button presses and releases and mouse motion
events are reported to window, and window entry and window exit events
are ignored. The grab subtree "owns" the pointer: windows outside the
grab subtree will be visible on the screen but they will be insensitive
until the grab is released. The tree of windows underneath the grab
window can include top-level windows, in which case all of those top-
level windows and their descendants will continue to receive mouse
events during the grab.

Basically, a modal toplevel does this:

toplevel .foo
(build the rest of .foo)
set oldgrab [grab current .foo]
grab .foo
set oldfocus [focus]
focus .foo
tkwait window .foo;# could wait on a global set by a close/cancel button.
if {$oldgrab ne {}} {
grab $oldgrab
}
if {$oldfocus ne {}} {
focus $oldfocus
}

Removing all of the grab infrastructure and tossing the tkwait, yields a
non-modal toplevel.

Thank you for your explanation, this clarifies both the behavior and solution.
And I've learned something new- who could ask for more?

Much obliged.

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


Subject: Re: Looking for non-modal alternatives to tk_messageBox
From: Andreas Leitgeb
Newsgroups: comp.lang.tcl
Organization: A noiseless patient Spider
Date: Sat, 16 Apr 2022 14:47 UTC
References: 1 2 3 4
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: avl...@logic.at (Andreas Leitgeb)
Newsgroups: comp.lang.tcl
Subject: Re: Looking for non-modal alternatives to tk_messageBox
Date: Sat, 16 Apr 2022 14:47:38 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 27
Message-ID: <slrnt5lloa.10f1.avl@logic.at>
References: <10556088-a5a7-429c-80e7-81bf1ffaa3f6n@googlegroups.com>
<t3alak$6o6$1@gioia.aioe.org>
<b2e1d5fd-e709-4a2e-8330-417f5db860a2n@googlegroups.com>
<t3d1bc$1o1h$1@gioia.aioe.org>
Reply-To: avl@logic.at
Injection-Date: Sat, 16 Apr 2022 14:47:38 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="6ec62a1bd7452741737cb4d0a85d2b80";
logging-data="26589"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19mp1IbYYS+PQHf4Z9g55tU"
User-Agent: slrn/1.0.3 (Linux)
Cancel-Lock: sha1:l+pfrPo8RFpTIPKTzflKO5GLjpg=
View all headers
saitology9@gmail.com <saitology9@gmail.com> wrote:
On 4/15/22 3:53 PM, Michael Soyka wrote:
package req Tk
toplevel .hidden
wm withdraw .hidden
# rest of your script
tk_messageBox -message "Not blocking anything..." -parent .hidden
Did you try it?  It should have worked.

The strange thing is, I did try it from an interactive "wish", and I did:

  toplevel .hidden; wm withdraw .hidden

in a single line, to avoid the toplevel to pop up first (to mimic
its behaviour in a script)

Then I created (and packed) a text widget ".t" in ".", then I started
the message box with the removed toplevel .hidden as its parent.

And...

while the messagebox was open, the text was deaf to all my actions,
until I closed the popup.

Conclusion: Maybe, the behaviour for invisible parent toplevels is OS-dependent.
(in my case that was on Linux)



Subject: Re: Looking for non-modal alternatives to tk_messageBox
From: Michael Soyka
Newsgroups: comp.lang.tcl
Date: Sat, 16 Apr 2022 15:23 UTC
References: 1 2 3 4 5
X-Received: by 2002:a05:620a:470d:b0:67d:d8a8:68c6 with SMTP id bs13-20020a05620a470d00b0067dd8a868c6mr2352583qkb.717.1650122607478;
Sat, 16 Apr 2022 08:23:27 -0700 (PDT)
X-Received: by 2002:a05:6870:796:b0:da:3d6a:101d with SMTP id
en22-20020a056870079600b000da3d6a101dmr1398985oab.20.1650122607220; Sat, 16
Apr 2022 08:23:27 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.tcl
Date: Sat, 16 Apr 2022 08:23:26 -0700 (PDT)
In-Reply-To: <slrnt5lloa.10f1.avl@logic.at>
Injection-Info: google-groups.googlegroups.com; posting-host=24.38.189.127; posting-account=BNremgoAAAA8qNSnkohRhaCVs-73LJUv
NNTP-Posting-Host: 24.38.189.127
References: <10556088-a5a7-429c-80e7-81bf1ffaa3f6n@googlegroups.com>
<t3alak$6o6$1@gioia.aioe.org> <b2e1d5fd-e709-4a2e-8330-417f5db860a2n@googlegroups.com>
<t3d1bc$1o1h$1@gioia.aioe.org> <slrnt5lloa.10f1.avl@logic.at>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <cafb07f9-6299-4d09-8d83-1468eaa11087n@googlegroups.com>
Subject: Re: Looking for non-modal alternatives to tk_messageBox
From: mssr...@gmail.com (Michael Soyka)
Injection-Date: Sat, 16 Apr 2022 15:23:27 +0000
Content-Type: text/plain; charset="UTF-8"
View all headers
On Saturday, April 16, 2022 at 10:47:42 AM UTC-4, Andreas Leitgeb wrote:
saito...@gmail.com <saito...@gmail.com> wrote:
On 4/15/22 3:53 PM, Michael Soyka wrote:
package req Tk
toplevel .hidden
wm withdraw .hidden
# rest of your script
tk_messageBox -message "Not blocking anything..." -parent .hidden
Did you try it? It should have worked.
The strange thing is, I did try it from an interactive "wish", and I did:
toplevel .hidden; wm withdraw .hidden
in a single line, to avoid the toplevel to pop up first (to mimic
its behaviour in a script)

Then I created (and packed) a text widget ".t" in ".", then I started
the message box with the removed toplevel .hidden as its parent.

And...

while the messagebox was open, the text was deaf to all my actions,
until I closed the popup.

Conclusion: Maybe, the behaviour for invisible parent toplevels is OS-dependent.
(in my case that was on Linux)

I'm running ActiveState 8.6.6 on Windows 10 and, if I use your create sequence, my text widget is alive and kicking; likewise if created in the other order.
However, on my linux box running Tk 8.6.9 neither order works, i.e., the text widget is unresponsive.


Subject: Re: Looking for non-modal alternatives to tk_messageBox
From: Robert Heller
Newsgroups: comp.lang.tcl
Organization: Deepwoods Software
Date: Sat, 16 Apr 2022 16:15 UTC
References: 1 2
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!buffer2.nntp.dca1.giganews.com!buffer1.nntp.dca1.giganews.com!news.giganews.com.POSTED!not-for-mail
NNTP-Posting-Date: Sat, 16 Apr 2022 11:15:18 -0500
MIME-Version: 1.0
From: hel...@deepsoft.com (Robert Heller)
Organization: Deepwoods Software
X-Newsreader: TkNews 3.0 (1.2.12)
Subject: Re: Looking for non-modal alternatives to tk_messageBox
In-Reply-To: <cafb07f9-6299-4d09-8d83-1468eaa11087n@googlegroups.com>
References: <10556088-a5a7-429c-80e7-81bf1ffaa3f6n@googlegroups.com>?
<t3alak$6o6$1@gioia.aioe.org>
<b2e1d5fd-e709-4a2e-8330-417f5db860a2n@googlegroups.com>?
<t3d1bc$1o1h$1@gioia.aioe.org> <slrnt5lloa.10f1.avl@logic.at>
<cafb07f9-6299-4d09-8d83-1468eaa11087n@googlegroups.com>
Newsgroups: comp.lang.tcl
Content-Type: text/plain;
charset="us-ascii"
Originator: heller@sharky4.deepsoft.com
Message-ID: <b4WdnXY79YgLdsf_nZ2dnUU7-VfNnZ2d@giganews.com>
Date: Sat, 16 Apr 2022 11:15:18 -0500
Lines: 60
X-Usenet-Provider: http://www.giganews.com
X-Trace: sv3-OENM2jgsPS5B2ruvgw7oYkLbC1/wvntY3eDKxafVu18ynn8ZxIy00whdpmJrJURMay24E7JklCIpCgB!W8isyZ4mIVxRw3F4WxGA9dCYLzVcG/WQ9qH00ua0Ls8PNjRj2mLplASrx22Rf1u32RDSPwPYBnh2!Rt8=
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-Original-Bytes: 3926
View all headers
At Sat, 16 Apr 2022 08:23:26 -0700 (PDT) Michael Soyka <mssr953@gmail.com> wrote:


On Saturday, April 16, 2022 at 10:47:42 AM UTC-4, Andreas Leitgeb wrote:
saito...@gmail.com <saito...@gmail.com> wrote:
On 4/15/22 3:53 PM, Michael Soyka wrote:
package req Tk
toplevel .hidden
wm withdraw .hidden
# rest of your script
tk_messageBox -message "Not blocking anything..." -parent .hidden
Did you try it? It should have worked.
The strange thing is, I did try it from an interactive "wish", and I did:
toplevel .hidden; wm withdraw .hidden
in a single line, to avoid the toplevel to pop up first (to mimic
its behaviour in a script)

Then I created (and packed) a text widget ".t" in ".", then I started
the message box with the removed toplevel .hidden as its parent.

And...

while the messagebox was open, the text was deaf to all my actions,
until I closed the popup.

Conclusion: Maybe, the behaviour for invisible parent toplevels is OS-dependent.
(in my case that was on Linux)

I'm running ActiveState 8.6.6 on Windows 10 and, if I use your create sequence, my text widget is alive and kicking; likewise if created in the other order.
However, on my linux box running Tk 8.6.9 neither order works, i.e., the text widget is unresponsive.
                                           


This suggests that the .hidden "trick" is not a reliable cross-platform
option.

Note: a non-modal version of Tk_messageBox is easy enough to just write using
something like this sequence:

toplevel .messageBox
wm title .messageBox "Some Title"
wm transient .messageBox $parent
wm protocol .messageBox  WM_DELETE_WINDOW <some script...>
message  .messageBox.message
pack .messageBox.message -expand yes -fill both
button .messageBox.dismis -text {Dismis} -command {destory .messageBox}
pack .messageBox.dismis -expand yes -fill x

This could be easily wrapped in a proc that uses some options and/or
parameters to fill things in parametricly.




--
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
                                                                                                                


Subject: Re: Looking for non-modal alternatives to tk_messageBox
From: saitolo...@gmail.com
Newsgroups: comp.lang.tcl
Organization: Aioe.org NNTP Server
Date: Sat, 16 Apr 2022 16:20 UTC
References: 1 2 3 4 5 6
Path: i2pn2.org!i2pn.org!aioe.org!a5rWVvs5S5ZXUwkNcVnRMw.user.46.165.242.91.POSTED!not-for-mail
From: saitolo...@gmail.com
Newsgroups: comp.lang.tcl
Subject: Re: Looking for non-modal alternatives to tk_messageBox
Date: Sat, 16 Apr 2022 12:20:10 -0400
Organization: Aioe.org NNTP Server
Message-ID: <t3eqbu$oi8$1@gioia.aioe.org>
References: <10556088-a5a7-429c-80e7-81bf1ffaa3f6n@googlegroups.com>
<t3alak$6o6$1@gioia.aioe.org>
<b2e1d5fd-e709-4a2e-8330-417f5db860a2n@googlegroups.com>
<t3d1bc$1o1h$1@gioia.aioe.org> <slrnt5lloa.10f1.avl@logic.at>
<cafb07f9-6299-4d09-8d83-1468eaa11087n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="25160"; posting-host="a5rWVvs5S5ZXUwkNcVnRMw.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.6.1
X-Notice: Filtered by postfilter v. 0.9.2
Content-Language: en-US
View all headers
On 4/16/22 11:23 AM, Michael Soyka wrote:

However, on my linux box running Tk 8.6.9 neither order works, i.e., the text widget is unresponsive.


Hello,

That is interesting.  It looks like Linux side only has global grab vs. local.  Also consider that Linux has several window managers and I believe some give you options to control this specific behavior.  I don't have a Linux handy at the moment to test, though.


Subject: Re: Looking for non-modal alternatives to tk_messageBox
From: jtyler
Newsgroups: comp.lang.tcl
Organization: Aioe.org NNTP Server
Date: Mon, 18 Apr 2022 05:52 UTC
References: 1 2 3 4 5 6 7
Path: i2pn2.org!i2pn.org!aioe.org!YN2ulY6LKp1eoOUw2OJ8ig.user.46.165.242.91.POSTED!not-for-mail
From: jtyler...@gmail.com (jtyler)
Newsgroups: comp.lang.tcl
Subject: Re: Looking for non-modal alternatives to tk_messageBox
Date: Sun, 17 Apr 2022 22:52:14 -0700
Organization: Aioe.org NNTP Server
Message-ID: <t3iuae$h47$1@gioia.aioe.org>
References: <10556088-a5a7-429c-80e7-81bf1ffaa3f6n@googlegroups.com>
<t3alak$6o6$1@gioia.aioe.org>
<b2e1d5fd-e709-4a2e-8330-417f5db860a2n@googlegroups.com>
<t3d1bc$1o1h$1@gioia.aioe.org> <slrnt5lloa.10f1.avl@logic.at>
<cafb07f9-6299-4d09-8d83-1468eaa11087n@googlegroups.com>
<t3eqbu$oi8$1@gioia.aioe.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Info: gioia.aioe.org; logging-data="17543"; posting-host="YN2ulY6LKp1eoOUw2OJ8ig.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.7.0
Content-Language: en-US
X-Notice: Filtered by postfilter v. 0.9.2
View all headers
On 4/16/2022 9:20 AM, saitology9@gmail.com wrote:
On 4/16/22 11:23 AM, Michael Soyka wrote:

However, on my linux box running Tk 8.6.9 neither order works, i.e., the text widget is unresponsive.


Hello,

That is interesting.  It looks like Linux side only has global grab vs. local.  Also consider that Linux has several window managers and I believe some give you options to control this specific behavior.  I don't have a Linux handy at the moment to test, though.

Well, maybe then using a thread is not overkill :)

[1650]$ rlwrap -pred tclsh
% package require Thread
2.8.4
% set tid [thread::create {package require Tk;wm withdraw . ; thread::wait}]
tid0x7fad67cdb700
% package require Tk
8.6.9
% button .b -text hello -command {puts hi} ; pack .b
% hi
hi
hi

% thread::send -async $tid {tk_messageBox -message "hello world"}
% hi
hi
hi

In the above, I clicked on button, that produced the "hi" regardless of the message box being present or not.


Subject: Re: Looking for non-modal alternatives to tk_messageBox
From: Schelte
Newsgroups: comp.lang.tcl
Organization: KPN B.V.
Date: Mon, 18 Apr 2022 10:18 UTC
References: 1 2 3 4 5 6 7 8
Date: Mon, 18 Apr 2022 12:18:32 +0200
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
Thunderbird/91.8.0
Subject: Re: Looking for non-modal alternatives to tk_messageBox
Content-Language: en-US
Newsgroups: comp.lang.tcl
References: <10556088-a5a7-429c-80e7-81bf1ffaa3f6n@googlegroups.com>
<t3alak$6o6$1@gioia.aioe.org>
<b2e1d5fd-e709-4a2e-8330-417f5db860a2n@googlegroups.com>
<t3d1bc$1o1h$1@gioia.aioe.org> <slrnt5lloa.10f1.avl@logic.at>
<cafb07f9-6299-4d09-8d83-1468eaa11087n@googlegroups.com>
<t3eqbu$oi8$1@gioia.aioe.org> <t3iuae$h47$1@gioia.aioe.org>
From: nos...@wanadoo.nl (Schelte)
In-Reply-To: <t3iuae$h47$1@gioia.aioe.org>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Message-ID: <nnd$4dac7ed6$17e2e06e@1bf337566d6feef7>
Organization: KPN B.V.
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!newsreader4.netcologne.de!news.netcologne.de!peer03.ams1!peer.ams1.xlned.com!news.xlned.com!peer03.ams4!peer.am4.highwinds-media.com!news.highwinds-media.com!feed.abavia.com!abe004.abavia.com!abp003.abavia.com!news.kpn.nl!not-for-mail
Lines: 15
Injection-Date: Mon, 18 Apr 2022 12:18:33 +0200
Injection-Info: news.kpn.nl; mail-complaints-to="abuse@kpn.com"
X-Received-Bytes: 1547
View all headers
On 18/04/2022 07:52, jtyler wrote:
Well, maybe then using a thread is not overkill :)

It is. You can achieve the same result with just a slave interpreter:
% interp create foo
foo
% foo eval {package require Tk; wm withdraw .}
% package require Tk
8.6.12
% button .b -text hello -command {puts hi}; pack .b
% foo eval {tk_messageBox -message "hello world"}


Schelte.


Subject: Re: Looking for non-modal alternatives to tk_messageBox
From: Michael Soyka
Newsgroups: comp.lang.tcl
Date: Mon, 18 Apr 2022 14:18 UTC
References: 1 2 3 4 5
X-Received: by 2002:a05:622a:1182:b0:2f1:fefa:f1c4 with SMTP id m2-20020a05622a118200b002f1fefaf1c4mr3189917qtk.365.1650291504957;
Mon, 18 Apr 2022 07:18:24 -0700 (PDT)
X-Received: by 2002:a05:6870:d294:b0:e1:936a:7145 with SMTP id
d20-20020a056870d29400b000e1936a7145mr6375323oae.220.1650291504747; Mon, 18
Apr 2022 07:18:24 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.tcl
Date: Mon, 18 Apr 2022 07:18:24 -0700 (PDT)
In-Reply-To: <YZydnRDrw9GYdMT_nZ2dnUU7-fPNnZ2d@giganews.com>
Injection-Info: google-groups.googlegroups.com; posting-host=24.38.189.127; posting-account=BNremgoAAAA8qNSnkohRhaCVs-73LJUv
NNTP-Posting-Host: 24.38.189.127
References: <10556088-a5a7-429c-80e7-81bf1ffaa3f6n@googlegroups.com>
<t3alak$6o6$1@gioia.aioe.org> <b2e1d5fd-e709-4a2e-8330-417f5db860a2n@googlegroups.com>
<slrnt5jls6.10f1.avl@logic.at> <YZydnRDrw9GYdMT_nZ2dnUU7-fPNnZ2d@giganews.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <9834d8ff-a9e8-4dee-bc9b-3d7466178e2an@googlegroups.com>
Subject: Re: Looking for non-modal alternatives to tk_messageBox
From: mssr...@gmail.com (Michael Soyka)
Injection-Date: Mon, 18 Apr 2022 14:18:24 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
View all headers
On Friday, April 15, 2022 at 5:52:14 PM UTC-4, Robert Heller wrote:


grab(3tk) Tk Built-In Commands grab(3tk)

______________________________________________________________________________

NAME
grab - Confine pointer and keyboard events to a window sub-tree

SYNOPSIS
grab ?-global? window

grab option ?arg arg ...?
______________________________________________________________________________

DESCRIPTION
This command implements simple pointer and keyboard grabs for Tk. Tk's
grabs are different than the grabs described in the Xlib documentation.
When a grab is set for a particular window, Tk restricts all pointer
events to the grab window and its descendants in Tk's window hierarchy.
Whenever the pointer is within the grab window's subtree, the pointer
will behave exactly the same as if there had been no grab at all and
all events will be reported in the normal fashion.

It was suggested in an earlier post to associate the tk_messageBox window with a hidden toplevel as a way of keeping my text widget responsive.  This worked on Windows but not linux.  If I understand the following two sentences in the manpage, does it not follow that the linux behavior correctly implements "grab" and that Windows does not?

When the pointer is
outside window's tree, button presses and releases and mouse motion
events are reported to window, and window entry and window exit events
are ignored. The grab subtree "owns" the pointer: windows outside the
grab subtree will be visible on the screen but they will be insensitive
until the grab is released. The tree of windows underneath the grab
window can include top-level windows, in which case all of those top-
level windows and their descendants will continue to receive mouse
events during the grab.


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


Subject: Re: Looking for non-modal alternatives to tk_messageBox
From: Robert Heller
Newsgroups: comp.lang.tcl
Organization: Deepwoods Software
Date: Mon, 18 Apr 2022 15:37 UTC
References: 1
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!buffer2.nntp.dca1.giganews.com!buffer1.nntp.dca1.giganews.com!news.giganews.com.POSTED!not-for-mail
NNTP-Posting-Date: Mon, 18 Apr 2022 10:37:20 -0500
MIME-Version: 1.0
From: hel...@deepsoft.com (Robert Heller)
Organization: Deepwoods Software
X-Newsreader: TkNews 3.0 (1.2.12)
Subject: Re: Looking for non-modal alternatives to tk_messageBox
In-Reply-To: <9834d8ff-a9e8-4dee-bc9b-3d7466178e2an@googlegroups.com>
References: <10556088-a5a7-429c-80e7-81bf1ffaa3f6n@googlegroups.com>?
<t3alak$6o6$1@gioia.aioe.org>
<b2e1d5fd-e709-4a2e-8330-417f5db860a2n@googlegroups.com>?
<slrnt5jls6.10f1.avl@logic.at>
<YZydnRDrw9GYdMT_nZ2dnUU7-fPNnZ2d@giganews.com>
<9834d8ff-a9e8-4dee-bc9b-3d7466178e2an@googlegroups.com>
Newsgroups: comp.lang.tcl
Content-Type: text/plain;
charset="us-ascii"
Originator: heller@sharky4.deepsoft.com
Message-ID: <J_2dnVvEIdctGMD_nZ2dnUU7-b3NnZ2d@giganews.com>
Date: Mon, 18 Apr 2022 10:37:20 -0500
Lines: 58
X-Usenet-Provider: http://www.giganews.com
X-Trace: sv3-YW1E2BusslCA4XO95dx/jwPzCHFcFPI9Bv3G/5NvalCQPB1480h7d1IYopm5BEUhaJKCt/ubNcw9NgQ!Hqi6ZD2zgRL/1umXO2AGHXJ7WOJUeg9fgGQ81MW9ognnT47J0gNsAuOYSeBUAWXNn/nyQWbw2YE1!eCQ=
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-Original-Bytes: 4181
View all headers
At Mon, 18 Apr 2022 07:18:24 -0700 (PDT) Michael Soyka <mssr953@gmail.com> wrote:


On Friday, April 15, 2022 at 5:52:14 PM UTC-4, Robert Heller wrote:


grab(3tk) Tk Built-In Commands grab(3tk)

______________________________________________________________________________

NAME
grab - Confine pointer and keyboard events to a window sub-tree

SYNOPSIS
grab ?-global? window

grab option ?arg arg ...?
______________________________________________________________________________

DESCRIPTION
This command implements simple pointer and keyboard grabs for Tk. Tk's
grabs are different than the grabs described in the Xlib documentation.
When a grab is set for a particular window, Tk restricts all pointer
events to the grab window and its descendants in Tk's window hierarchy.
Whenever the pointer is within the grab window's subtree, the pointer
will behave exactly the same as if there had been no grab at all and
all events will be reported in the normal fashion.

It was suggested in an earlier post to associate the tk_messageBox window with a hidden toplevel as a way of keeping my text widget responsive.  This worked on Windows but not linux.  If I understand the following two sentences in the manpage, does it not follow that the linux behavior correctly implements "grab" and that Windows does not?

Quite possibly.  OTOH, implementing a non-modal version of tk_messageBox is
pretty easy...


When the pointer is
outside window's tree, button presses and releases and mouse motion
events are reported to window, and window entry and window exit events
are ignored. The grab subtree "owns" the pointer: windows outside the
grab subtree will be visible on the screen but they will be insensitive
until the grab is released. The tree of windows underneath the grab
window can include top-level windows, in which case all of those top-
level windows and their descendants will continue to receive mouse
events during the grab.


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



--
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
                                                                                               


Subject: Re: Looking for non-modal alternatives to tk_messageBox
From: saitolo...@gmail.com
Newsgroups: comp.lang.tcl
Organization: Aioe.org NNTP Server
Date: Mon, 18 Apr 2022 16:27 UTC
References: 1 2 3 4 5 6
Path: i2pn2.org!i2pn.org!aioe.org!a5rWVvs5S5ZXUwkNcVnRMw.user.46.165.242.91.POSTED!not-for-mail
From: saitolo...@gmail.com
Newsgroups: comp.lang.tcl
Subject: Re: Looking for non-modal alternatives to tk_messageBox
Date: Mon, 18 Apr 2022 12:27:52 -0400
Organization: Aioe.org NNTP Server
Message-ID: <t3k3i8$18qe$1@gioia.aioe.org>
References: <10556088-a5a7-429c-80e7-81bf1ffaa3f6n@googlegroups.com>
<t3alak$6o6$1@gioia.aioe.org>
<b2e1d5fd-e709-4a2e-8330-417f5db860a2n@googlegroups.com>
<slrnt5jls6.10f1.avl@logic.at>
<YZydnRDrw9GYdMT_nZ2dnUU7-fPNnZ2d@giganews.com>
<9834d8ff-a9e8-4dee-bc9b-3d7466178e2an@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="41806"; posting-host="a5rWVvs5S5ZXUwkNcVnRMw.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.6.1
X-Notice: Filtered by postfilter v. 0.9.2
Content-Language: en-US
View all headers
On 4/18/22 10:18 AM, Michael Soyka wrote:
______________________________________________________________________________

DESCRIPTION
This command implements simple pointer and keyboard grabs for Tk. Tk's
grabs are different than the grabs described in the Xlib documentation.
When a grab is set for a particular window, Tk restricts all pointer
events to the grab window and its descendants in Tk's window hierarchy.
Whenever the pointer is within the grab window's subtree, the pointer
will behave exactly the same as if there had been no grab at all and
all events will be reported in the normal fashion.

It was suggested in an earlier post to associate the tk_messageBox window with a hidden toplevel as a way of keeping my text widget responsive.  This worked on Windows but not linux.  If I understand the following two sentences in the manpage, does it not follow that the linux behavior correctly implements "grab" and that Windows does not?



Hello,

First, a brief comment on the above and then a solution that should work on Linux just as it does on Windows.

Widget hierarchy is a tree structure - top-down from a toplevel all the way down through various frames to individual widgets.  So when the documentation says "subtree" and its "descendants", it refers to that pathway from the toplevel down. A "subtree" does not include widgets from another toplevel.  For example, ".a.b.c" and ".x.b.c.d" have nothing in common except for sharing the root window as parent. Hopefully this description is clear.

Now, as to why the original suggestion did not work on Linux: I think it comes down to the ".hidden" window being invisible. We can fix it by keeping it visible but not too distracting to the user.

Please try this code on Linux and see if it works better:


package req Tk

toplevel .hidden
wm overrideredirect .hidden 1
wm geometry .hidden 1x1+0+0


# insert your script here

tk_messageBox -message "Not blocking anything..." -parent .hidden









Subject: Re: Looking for non-modal alternatives to tk_messageBox
From: Robert Heller
Newsgroups: comp.lang.tcl
Organization: Deepwoods Software
Date: Mon, 18 Apr 2022 17:42 UTC
References: 1
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!buffer2.nntp.dca1.giganews.com!buffer1.nntp.dca1.giganews.com!news.giganews.com.POSTED!not-for-mail
NNTP-Posting-Date: Mon, 18 Apr 2022 12:42:14 -0500
MIME-Version: 1.0
From: hel...@deepsoft.com (Robert Heller)
Organization: Deepwoods Software
X-Newsreader: TkNews 3.0 (1.2.12)
Subject: Re: Looking for non-modal alternatives to tk_messageBox
In-Reply-To: <t3k3i8$18qe$1@gioia.aioe.org>
References: <10556088-a5a7-429c-80e7-81bf1ffaa3f6n@googlegroups.com>?
<t3alak$6o6$1@gioia.aioe.org>?
<b2e1d5fd-e709-4a2e-8330-417f5db860a2n@googlegroups.com>?
<slrnt5jls6.10f1.avl@logic.at>?
<YZydnRDrw9GYdMT_nZ2dnUU7-fPNnZ2d@giganews.com>?
<9834d8ff-a9e8-4dee-bc9b-3d7466178e2an@googlegroups.com>
<t3k3i8$18qe$1@gioia.aioe.org>
Newsgroups: comp.lang.tcl
Content-Type: text/plain;
charset="us-ascii"
Originator: heller@sharky4.deepsoft.com
Message-ID: <qOWdnSIEns5rP8D_nZ2dnUU7-b3NnZ2d@giganews.com>
Date: Mon, 18 Apr 2022 12:42:14 -0500
Lines: 89
X-Usenet-Provider: http://www.giganews.com
X-Trace: sv3-8c6sI+AiDfpWWUZg6iSZlFcSgbCeHuKSY/tOgEyOx9SbeIOzVVJEvWRFTYZaDM7+2cQuODLaAV1Zu2z!RkY4lSmJh4XyoKmyQMxwHSoOOWYjM60YcOTMCt3uJsakryLvGldL3C5sTBmDytEIxcUcByLVgocu!G0Q=
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-Original-Bytes: 4981
View all headers
At Mon, 18 Apr 2022 12:27:52 -0400 saitology9@gmail.com wrote:


On 4/18/22 10:18 AM, Michael Soyka wrote:
______________________________________________________________________________

DESCRIPTION
This command implements simple pointer and keyboard grabs for Tk. Tk's
grabs are different than the grabs described in the Xlib documentation.
When a grab is set for a particular window, Tk restricts all pointer
events to the grab window and its descendants in Tk's window hierarchy.
Whenever the pointer is within the grab window's subtree, the pointer
will behave exactly the same as if there had been no grab at all and
all events will be reported in the normal fashion.

It was suggested in an earlier post to associate the tk_messageBox window with a hidden toplevel as a way of keeping my text widget responsive.  This worked on Windows but not linux.  If I understand the following two sentences in the manpage, does it not follow that the linux behavior correctly implements "grab" and that Windows does not?



Hello,

First, a brief comment on the above and then a solution that should work
on Linux just as it does on Windows.

Widget hierarchy is a tree structure - top-down from a toplevel all the
way down through various frames to individual widgets.  So when the
documentation says "subtree" and its "descendants", it refers to that
pathway from the toplevel down. A "subtree" does not include widgets
from another toplevel.  For example, ".a.b.c" and ".x.b.c.d" have
nothing in common except for sharing the root window as parent.
Hopefully this description is clear.

Now, as to why the original suggestion did not work on Linux: I think it
comes down to the ".hidden" window being invisible. We can fix it by
keeping it visible but not too distracting to the user.

Please try this code on Linux and see if it works better:


package req Tk

toplevel .hidden
wm overrideredirect .hidden 1
wm geometry .hidden 1x1+0+0


# insert your script here

tk_messageBox -message "Not blocking anything..." -parent .hidden

Really, the best way is to just implement a non-modal version of
tk_messageBox.  Which is really quite simple...

Playing games with hidden or almost hidden toplevels is just plain hokey...

Actually, in most of my applications, I make very minimual use of
tk_messageBox.  Instead I have a general purpose Dialog widget class, which
has a flag for being modal or not.  In some applications where I have a lot of
non-modal informational windows, I create a widget class just for that.  (It
is not rocket science...)

If all you want to put up a non-modal message box that looks exactly like
tk_messageBox, just grap the code in /usr/share/tcltk/tk8.6/msgbox.tcl and
remove some (all) of the code starting with the line "# 8. Set a grab and
claim the focus too." -- this is where all of the modal fun and games starts. 
Change the name of the function and you are all set.




 
        








                                                                    


--
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
                       


Subject: Re: Looking for non-modal alternatives to tk_messageBox
From: Michael Soyka
Newsgroups: comp.lang.tcl
Date: Mon, 18 Apr 2022 18:24 UTC
References: 1 2 3 4 5 6 7 8
X-Received: by 2002:a05:620a:4456:b0:69e:7630:b29e with SMTP id w22-20020a05620a445600b0069e7630b29emr6607180qkp.111.1650306299860;
Mon, 18 Apr 2022 11:24:59 -0700 (PDT)
X-Received: by 2002:a05:6808:3006:b0:2ec:8fcb:1d4a with SMTP id
ay6-20020a056808300600b002ec8fcb1d4amr7179634oib.162.1650306299663; Mon, 18
Apr 2022 11:24:59 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.tcl
Date: Mon, 18 Apr 2022 11:24:59 -0700 (PDT)
In-Reply-To: <qOWdnSIEns5rP8D_nZ2dnUU7-b3NnZ2d@giganews.com>
Injection-Info: google-groups.googlegroups.com; posting-host=24.38.189.127; posting-account=BNremgoAAAA8qNSnkohRhaCVs-73LJUv
NNTP-Posting-Host: 24.38.189.127
References: <10556088-a5a7-429c-80e7-81bf1ffaa3f6n@googlegroups.com>
<t3alak$6o6$1@gioia.aioe.org> <b2e1d5fd-e709-4a2e-8330-417f5db860a2n@googlegroups.com>
<slrnt5jls6.10f1.avl@logic.at> <YZydnRDrw9GYdMT_nZ2dnUU7-fPNnZ2d@giganews.com>
<9834d8ff-a9e8-4dee-bc9b-3d7466178e2an@googlegroups.com> <t3k3i8$18qe$1@gioia.aioe.org>
<qOWdnSIEns5rP8D_nZ2dnUU7-b3NnZ2d@giganews.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <d7fcebb7-ec05-4f32-b5b4-c1fa0cf25028n@googlegroups.com>
Subject: Re: Looking for non-modal alternatives to tk_messageBox
From: mssr...@gmail.com (Michael Soyka)
Injection-Date: Mon, 18 Apr 2022 18:24:59 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Lines: 49
View all headers
On Monday, April 18, 2022 at 1:42:23 PM UTC-4, Robert Heller wrote:

Really, the best way is to just implement a non-modal version of
tk_messageBox. Which is really quite simple...

and, as I mentioned in my initial post, I've done that and it works just fine (and it was easy).

My reason for posting was to learn from others about possible alternatives.  So far, threads and slave interpreters were mentioned and those are the kinds of responses I was hoping for.   Nonetheless, I do appreciate the explanations of how tk_messageBox works and it caused to crack-open my old Tk books, something I should have done from the start (RTFM as some might say). 

Playing games with hidden or almost hidden toplevels is just plain hokey....

Actually, in most of my applications, I make very minimual use of
tk_messageBox. Instead I have a general purpose Dialog widget class, which
has a flag for being modal or not. In some applications where I have a lot of
non-modal informational windows, I create a widget class just for that. (It
is not rocket science...)

By the way, what you describe is sounds similar to the custom dialog implementation given in "Effective Tcl/Tk Programming" by Harrison & McLennan except for the modality flag.


If all you want to put up a non-modal message box that looks exactly like
tk_messageBox, just grap the code in /usr/share/tcltk/tk8.6/msgbox.tcl and
remove some (all) of the code starting with the line "# 8. Set a grab and
claim the focus too." -- this is where all of the modal fun and games starts.
Change the name of the function and you are all set.

All I needed was a non-modal replacement with retry/cancel capability , the visual appearance of tk_messageBox served as a useful guide.

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


Subject: Re: Looking for non-modal alternatives to tk_messageBox
From: Schelte
Newsgroups: comp.lang.tcl
Organization: KPN B.V.
Date: Mon, 18 Apr 2022 18:43 UTC
References: 1 2 3 4 5 6 7
Date: Mon, 18 Apr 2022 20:43:17 +0200
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
Thunderbird/91.8.0
Subject: Re: Looking for non-modal alternatives to tk_messageBox
Content-Language: en-US
Newsgroups: comp.lang.tcl
References: <10556088-a5a7-429c-80e7-81bf1ffaa3f6n@googlegroups.com>
<t3alak$6o6$1@gioia.aioe.org>
<b2e1d5fd-e709-4a2e-8330-417f5db860a2n@googlegroups.com>
<slrnt5jls6.10f1.avl@logic.at>
<YZydnRDrw9GYdMT_nZ2dnUU7-fPNnZ2d@giganews.com>
<9834d8ff-a9e8-4dee-bc9b-3d7466178e2an@googlegroups.com>
<t3k3i8$18qe$1@gioia.aioe.org>
From: nos...@wanadoo.nl (Schelte)
In-Reply-To: <t3k3i8$18qe$1@gioia.aioe.org>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Message-ID: <nnd$29fb125c$57f62c37@5ee216bc46b01296>
Organization: KPN B.V.
Path: i2pn2.org!i2pn.org!aioe.org!news.uzoreto.com!newsreader4.netcologne.de!news.netcologne.de!peer02.ams1!peer.ams1.xlned.com!news.xlned.com!peer03.ams4!peer.am4.highwinds-media.com!news.highwinds-media.com!abe005.abavia.com!abp003.abavia.com!news.kpn.nl!not-for-mail
Lines: 19
Injection-Date: Mon, 18 Apr 2022 20:43:17 +0200
Injection-Info: news.kpn.nl; mail-complaints-to="abuse@kpn.com"
X-Received-Bytes: 1857
View all headers
On 18/04/2022 18:27, saitology9@gmail.com wrote:
So when the documentation says "subtree" and its "descendants", it refers to that pathway from the toplevel down. A "subtree" does not include widgets from another toplevel.

The documentation refers to "the grab window and its descendants" *as* the "subtree". So it's not from the toplevel down, but from the grab window down. And only that part of the window hierarchy is active. All the rest is blocked. That includes other toplevels and their descendants.

Just to confirm: I tried your modified version on linux and it doesn't work either.

Robert Heller is right. Just create your own non-modal message box. It's not hard.


Schelte.


Subject: Re: Looking for non-modal alternatives to tk_messageBox
From: saitolo...@gmail.com
Newsgroups: comp.lang.tcl
Organization: Aioe.org NNTP Server
Date: Mon, 18 Apr 2022 18:56 UTC
References: 1 2 3 4 5 6 7 8
Path: i2pn2.org!i2pn.org!aioe.org!a5rWVvs5S5ZXUwkNcVnRMw.user.46.165.242.91.POSTED!not-for-mail
From: saitolo...@gmail.com
Newsgroups: comp.lang.tcl
Subject: Re: Looking for non-modal alternatives to tk_messageBox
Date: Mon, 18 Apr 2022 14:56:10 -0400
Organization: Aioe.org NNTP Server
Message-ID: <t3kc8a$12e3$1@gioia.aioe.org>
References: <10556088-a5a7-429c-80e7-81bf1ffaa3f6n@googlegroups.com>
<t3alak$6o6$1@gioia.aioe.org>
<b2e1d5fd-e709-4a2e-8330-417f5db860a2n@googlegroups.com>
<slrnt5jls6.10f1.avl@logic.at>
<YZydnRDrw9GYdMT_nZ2dnUU7-fPNnZ2d@giganews.com>
<9834d8ff-a9e8-4dee-bc9b-3d7466178e2an@googlegroups.com>
<t3k3i8$18qe$1@gioia.aioe.org>
<qOWdnSIEns5rP8D_nZ2dnUU7-b3NnZ2d@giganews.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="35267"; posting-host="a5rWVvs5S5ZXUwkNcVnRMw.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.6.1
Content-Language: en-US
X-Notice: Filtered by postfilter v. 0.9.2
View all headers
On 4/18/22 1:42 PM, Robert Heller wrote:

Really, the best way is to just implement a non-modal version of
tk_messageBox.  Which is really quite simple...


Hello,

I agree with you that it is indeed simple.  I believe I mentioned as much at the very beginning.  The OP had already solved it himself before posting, and any of the alternatives suggested here would work fine and be OK.


Playing games with hidden or almost hidden toplevels is just plain hokey...


I respectfully disagree completely.  What is tricky or hokey about it? Look tk_messageBox up in the manual and you will see that it is a valid command, and it has a "-parent" option, which is implicitly assigned if not given by the user.  If the OP has other windows, he can simply use that other window as the parent and he will still gain interactivity of his target window.  I used an extra toplevel to eliminate that guesswork and provide a quick solution.

If anything, I'd call it a case of a lack of understanding of the tk_messageBox.  It is one of the fundamental widgets in UI and I think it is important to know what it does, properly.



Actually, in most of my applications, I make very minimual use of
tk_messageBox.  Instead I have a general purpose Dialog widget class, which
....

If all you want to put up a non-modal message box that looks exactly like
tk_messageBox, just grap the code in /usr/share/tcltk/tk8.6/msgbox.tcl and



I'd categorize this as technical debt.  It may be easy to roll your own or hack it from the distribution but one will always need to ensure its compliance with future changes.  If it could be avoided by an existing command already, why bother?







Subject: Re: Looking for non-modal alternatives to tk_messageBox
From: saitolo...@gmail.com
Newsgroups: comp.lang.tcl
Organization: Aioe.org NNTP Server
Date: Mon, 18 Apr 2022 19:09 UTC
References: 1 2 3 4 5 6 7 8
Path: i2pn2.org!i2pn.org!aioe.org!a5rWVvs5S5ZXUwkNcVnRMw.user.46.165.242.91.POSTED!not-for-mail
From: saitolo...@gmail.com
Newsgroups: comp.lang.tcl
Subject: Re: Looking for non-modal alternatives to tk_messageBox
Date: Mon, 18 Apr 2022 15:09:45 -0400
Organization: Aioe.org NNTP Server
Message-ID: <t3kd1o$1dcc$1@gioia.aioe.org>
References: <10556088-a5a7-429c-80e7-81bf1ffaa3f6n@googlegroups.com>
<t3alak$6o6$1@gioia.aioe.org>
<b2e1d5fd-e709-4a2e-8330-417f5db860a2n@googlegroups.com>
<slrnt5jls6.10f1.avl@logic.at>
<YZydnRDrw9GYdMT_nZ2dnUU7-fPNnZ2d@giganews.com>
<9834d8ff-a9e8-4dee-bc9b-3d7466178e2an@googlegroups.com>
<t3k3i8$18qe$1@gioia.aioe.org> <nnd$29fb125c$57f62c37@5ee216bc46b01296>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="46476"; posting-host="a5rWVvs5S5ZXUwkNcVnRMw.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.6.1
X-Notice: Filtered by postfilter v. 0.9.2
Content-Language: en-US
View all headers
On 4/18/22 2:43 PM, Schelte wrote:
On 18/04/2022 18:27, saitology9@gmail.com wrote:
So when the documentation says "subtree" and its "descendants", it refers to that pathway from the toplevel down. A "subtree" does not include widgets from another toplevel.

The documentation refers to "the grab window and its descendants" *as* the "subtree". So it's not from the toplevel down, but from the grab


I think we are saying the same thing.  Just to clarify, per the man page, the target of a grab is a window; not a widget.  And the hierarchy by definition must include the top/root end.


window down. And only that part of the window hierarchy is active. All the rest is blocked. That includes other toplevels and their descendants.


I am not sure I read you correctly.  Are you saying all other toplevels are also locked due to the grab?  If so, I would be surprised as it is contrary to my experience and to the documentation. The manual would have to refer to the "application" and not the "window".

Also see the man page for grab.  You can set it as global meaning application-wide, or local, meaning a single toplevel.


 From the man page:

DESCRIPTION

       When  a  grab  is set for a ***particular window***, Tk restricts all pointer
       events to the grab window and its descendants in Tk's window hierarchy.

Please pay attention to "a particular window".

The phrase "its descendants" refers to "the grab window".


       Whenever  the  pointer is within the grab window's subtree, the pointer

"subtree" refers to any widget that is contained or is a child of the "grab window".





       will behave exactly the same as if there had been no grab  at  all  and
       all events will be reported in the normal fashion.  When the pointer is
       outside window's tree, button presses and  releases  and  mouse  motion
       events  are reported to window, and window entry and window exit events
       are ignored. The grab subtree "owns" the pointer: windows  outside  the
       grab subtree will be visible on the screen but they will be insensitive
       until the grab is released.  The tree of windows  underneath  the  grab
       window  can  include top-level windows, in which case all of those top-
       level windows and their descendants  will  continue  to  receive  mouse
       events during the grab.




Subject: Re: Looking for non-modal alternatives to tk_messageBox
From: Robert Heller
Newsgroups: comp.lang.tcl
Organization: Deepwoods Software
Date: Mon, 18 Apr 2022 19:12 UTC
References: 1
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!buffer2.nntp.dca1.giganews.com!buffer1.nntp.dca1.giganews.com!news.giganews.com.POSTED!not-for-mail
NNTP-Posting-Date: Mon, 18 Apr 2022 14:12:00 -0500
MIME-Version: 1.0
From: hel...@deepsoft.com (Robert Heller)
Organization: Deepwoods Software
X-Newsreader: TkNews 3.0 (1.2.12)
Subject: Re: Looking for non-modal alternatives to tk_messageBox
In-Reply-To: <d7fcebb7-ec05-4f32-b5b4-c1fa0cf25028n@googlegroups.com>
References: <10556088-a5a7-429c-80e7-81bf1ffaa3f6n@googlegroups.com>?
<t3alak$6o6$1@gioia.aioe.org>
<b2e1d5fd-e709-4a2e-8330-417f5db860a2n@googlegroups.com>?
<slrnt5jls6.10f1.avl@logic.at>
<YZydnRDrw9GYdMT_nZ2dnUU7-fPNnZ2d@giganews.com>?
<9834d8ff-a9e8-4dee-bc9b-3d7466178e2an@googlegroups.com>
<t3k3i8$18qe$1@gioia.aioe.org>?
<qOWdnSIEns5rP8D_nZ2dnUU7-b3NnZ2d@giganews.com>
<d7fcebb7-ec05-4f32-b5b4-c1fa0cf25028n@googlegroups.com>
Newsgroups: comp.lang.tcl
Content-Type: text/plain;
charset="us-ascii"
Originator: heller@sharky4.deepsoft.com
Message-ID: <n4ydne9WItmdJcD_nZ2dnUU7-cHNnZ2d@giganews.com>
Date: Mon, 18 Apr 2022 14:12:00 -0500
Lines: 53
X-Usenet-Provider: http://www.giganews.com
X-Trace: sv3-IyUxzKRFAsSrD/RU/ceftLaOpt3bv4DaNHLRNKCz4GSBPKQa4fhYZ1JZawDmauBPo6t/oJLkRZqQYNx!z6Wed+fl0UMFPUpWnBejRIZv6U+vyim7ThiqRl1lz0VWhTmiuEdL6VWz+JOJeEU7wVrxYcFbhRcG!1Hk=
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-Original-Bytes: 4307
View all headers
At Mon, 18 Apr 2022 11:24:59 -0700 (PDT) Michael Soyka <mssr953@gmail.com> wrote:


On Monday, April 18, 2022 at 1:42:23 PM UTC-4, Robert Heller wrote:

Really, the best way is to just implement a non-modal version of
tk_messageBox. Which is really quite simple...

and, as I mentioned in my initial post, I've done that and it works just fine (and it was easy).

My reason for posting was to learn from others about possible alternatives.  So far, threads and slave interpreters were mentioned and those are the kinds of responses I was hoping for.   Nonetheless, I do appreciate the explanations of how tk_messageBox works and it caused to crack-open my old Tk books, something I should have done from the start (RTFM as some might say). 

Using the event loop in more than one thread is possibly a bad idea.  I don't
think events will necessarily be delivered to multiple instances of the event
loop.


Playing games with hidden or almost hidden toplevels is just plain hokey...

Actually, in most of my applications, I make very minimual use of
tk_messageBox. Instead I have a general purpose Dialog widget class, which
has a flag for being modal or not. In some applications where I have a lot of
non-modal informational windows, I create a widget class just for that. (It
is not rocket science...)

By the way, what you describe is sounds similar to the custom dialog implementation given in "Effective Tcl/Tk Programming" by Harrison & McLennan except for the modality flag.

Convergent Evolution... :-)



If all you want to put up a non-modal message box that looks exactly like
tk_messageBox, just grap the code in /usr/share/tcltk/tk8.6/msgbox.tcl and
remove some (all) of the code starting with the line "# 8. Set a grab and
claim the focus too." -- this is where all of the modal fun and games starts.
Change the name of the function and you are all set.

All I needed was a non-modal replacement with retry/cancel capability , the visual appearance of tk_messageBox served as a useful guide.

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



--
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
                                                        


Subject: Re: Looking for non-modal alternatives to tk_messageBox
From: saitolo...@gmail.com
Newsgroups: comp.lang.tcl
Organization: Aioe.org NNTP Server
Date: Mon, 18 Apr 2022 19:27 UTC
References: 1 2 3 4 5 6 7 8
Path: i2pn2.org!i2pn.org!aioe.org!a5rWVvs5S5ZXUwkNcVnRMw.user.46.165.242.91.POSTED!not-for-mail
From: saitolo...@gmail.com
Newsgroups: comp.lang.tcl
Subject: Re: Looking for non-modal alternatives to tk_messageBox
Date: Mon, 18 Apr 2022 15:27:57 -0400
Organization: Aioe.org NNTP Server
Message-ID: <t3ke3s$1svf$1@gioia.aioe.org>
References: <10556088-a5a7-429c-80e7-81bf1ffaa3f6n@googlegroups.com>
<t3alak$6o6$1@gioia.aioe.org>
<b2e1d5fd-e709-4a2e-8330-417f5db860a2n@googlegroups.com>
<slrnt5jls6.10f1.avl@logic.at>
<YZydnRDrw9GYdMT_nZ2dnUU7-fPNnZ2d@giganews.com>
<9834d8ff-a9e8-4dee-bc9b-3d7466178e2an@googlegroups.com>
<t3k3i8$18qe$1@gioia.aioe.org> <nnd$29fb125c$57f62c37@5ee216bc46b01296>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="62447"; posting-host="a5rWVvs5S5ZXUwkNcVnRMw.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.6.1
X-Notice: Filtered by postfilter v. 0.9.2
Content-Language: en-US
View all headers
On 4/18/22 2:43 PM, Schelte wrote:

Just to confirm: I tried your modified version on linux and it doesn't work either.


Thank you for trying it.  Interrrresting....


Pages:12
rocksolid light 0.7.2
clearneti2ptor