Rocksolid Light

Welcome to Rocksolid Light

mail  files  register  newsreader  groups  login

Message-ID:  

"A mind is a terrible thing to have leaking out your ears." -- The League of Sadistic Telepaths


devel / comp.lang.tcl / Notebooks: the lost tabs problem

SubjectAuthor
* Notebooks: the lost tabs problemaldo.w....@gmail.com
`* Notebooks: the lost tabs problemnemethi
 `- Notebooks: the lost tabs problemaldo.w....@gmail.com

1
Notebooks: the lost tabs problem

<8638a35a-58f1-4f5b-aa2b-97b7ab0e0685n@googlegroups.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=12026&group=comp.lang.tcl#12026

  copy link   Newsgroups: comp.lang.tcl
X-Received: by 2002:a05:6214:4a4a:b0:63c:f55e:5960 with SMTP id ph10-20020a0562144a4a00b0063cf55e5960mr23661qvb.1.1692195304868;
Wed, 16 Aug 2023 07:15:04 -0700 (PDT)
X-Received: by 2002:a17:90a:9386:b0:26b:46db:839c with SMTP id
q6-20020a17090a938600b0026b46db839cmr359492pjo.4.1692195304544; Wed, 16 Aug
2023 07:15:04 -0700 (PDT)
Path: i2pn2.org!rocksolid2!i2pn.org!usenet.blueworldhosting.com!diablo1.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: Wed, 16 Aug 2023 07:15:03 -0700 (PDT)
Injection-Info: google-groups.googlegroups.com; posting-host=93.44.166.97; posting-account=CpQfUQoAAACWuSZdT5zfmIK7a0FfbQ0B
NNTP-Posting-Host: 93.44.166.97
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <8638a35a-58f1-4f5b-aa2b-97b7ab0e0685n@googlegroups.com>
Subject: Notebooks: the lost tabs problem
From: aldo.w.buratti@gmail.com (aldo.w....@gmail.com)
Injection-Date: Wed, 16 Aug 2023 14:15:04 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 3404
 by: aldo.w....@gmail.com - Wed, 16 Aug 2023 14:15 UTC

I like very much what Csaba Nemethi did for enahnacing the notebook widget.
In particular the close-tab-button ...
but there's one thing I think is missing from this API , which brings us to the "lost tabs problem.."

Just a premise:
As long you remove a notebook tab "by-program" ( $nb forget $tabid ) you also have complete control about what to do with the no-more-visible (unmapped) slave widget .
You can choose to destroy the widget (and all the involved resources like channels, images, ...)
or simply
put it in a list for a next add/insert ...
You have the full control ...

On the contrary, when you press the small close-tab button, you simply 'forget' (i.e. unmap) the slave widget,
but then ... the slave widget becomes a sort of lost widget ....

What I feel is that we need a generic and simple mechanism for telling the slave widget ".. hey ,you've been removed from the notebook" ,
so that this umapped widget can choose what to do (destroy itself, free the allocated resources, and so on ..)
My first rough ideas:
* generate a virtual event <<NotebookTabClosed>>
or
* add an option for a new callback like -afterforgetcommand

But then, I see a second, and more difficult, problem:
What happens when the whole notebook is destroyed ?
What happens to its contents (i.e. its slave widgets) ?

Let's consider this example;
+------------------
toplevel .z
frame .z.f
pack [ttk::notebook .z.f.nb -expand true -fill both] ;# .z.nb could also be a scrollutil::notebook
..
.z.nb add [frame .z.f.nb.f1 -bg red] -title "f1" ;# --
.z.nb add [frame .z.f.nb.f2 -bg green] -title "f2"
.z.nb add [frame .z.f3 -bg blue] -title "f3" ;# note: this slave is not a descendent of .z.f.nb !!
....
destroy .z.f.nb ; # this might be caused by an interactive cleanup of the .z.f frame ...
+---------

Consider that after notebook has been destroyed:
... slave f1 and f2 are automatically destroyed, but "f3" is always there (unmapped)
... moreover, if "f1" or "f2" were complex megawidgets with some allocated resources like sockets, images .., then thse resources won't be deallocated !

In conclusion, I have just shown what in my opinion is the problem of loss of control when these operations are performed interactively (closing a tab, destroying a notebook); I hope there is a simple general solution...
Suggestions ?

Re: Notebooks: the lost tabs problem

<ubkpbk$6qnh$1@tota-refugium.de>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=12029&group=comp.lang.tcl#12029

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!reader5.news.weretis.net!news.tota-refugium.de!.POSTED!not-for-mail
From: csaba.nemethi@t-online.de (nemethi)
Newsgroups: comp.lang.tcl
Subject: Re: Notebooks: the lost tabs problem
Date: Thu, 17 Aug 2023 11:30:28 +0200
Message-ID: <ubkpbk$6qnh$1@tota-refugium.de>
References: <8638a35a-58f1-4f5b-aa2b-97b7ab0e0685n@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 17 Aug 2023 09:30:28 -0000 (UTC)
Injection-Info: tota-refugium.de;
logging-data="223985"; mail-complaints-to="abuse@news.tota-refugium.de"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
Thunderbird/102.13.0
Cancel-Lock: sha1:9G1E/U3/FNSnvhaZ5Zsqn8fNXb0=
X-User-ID: eJwFwYEBwCAIA7CXUNrizpGN/n/CEqaW3oIo0HQHgfjqXpnPGc9RKErYqQDctqInCXlp/xAeEHc=
In-Reply-To: <8638a35a-58f1-4f5b-aa2b-97b7ab0e0685n@googlegroups.com>
Content-Language: en-US
 by: nemethi - Thu, 17 Aug 2023 09:30 UTC

Am 16.08.23 um 16:15 schrieb aldo.w....@gmail.com:
> I like very much what Csaba Nemethi did for enahnacing the notebook widget.
> In particular the close-tab-button ...
> but there's one thing I think is missing from this API , which brings us to the "lost tabs problem.."
>
> Just a premise:
> As long you remove a notebook tab "by-program" ( $nb forget $tabid ) you also have complete control about what to do with the no-more-visible (unmapped) slave widget .
> You can choose to destroy the widget (and all the involved resources like channels, images, ...)
> or simply
> put it in a list for a next add/insert ...
> You have the full control ...
>
> On the contrary, when you press the small close-tab button, you simply 'forget' (i.e. unmap) the slave widget,
> but then ... the slave widget becomes a sort of lost widget ....
>
> What I feel is that we need a generic and simple mechanism for telling the slave widget ".. hey ,you've been removed from the notebook" ,
> so that this umapped widget can choose what to do (destroy itself, free the allocated resources, and so on ..)
> My first rough ideas:
> * generate a virtual event <<NotebookTabClosed>>
> or
> * add an option for a new callback like -afterforgetcommand
>

From the "FURTHER BINDINGS" section of the Scrollednotebook reference
manual:

4. Closing a tab of a scrollednotebook widget with the aid of the
closetab element: ... after closing the tab, the widget generates a
<<NotebookTabClosed>> virtual event, by invoking event generate with
the -data option set to the path name of the widget contained in that
tab's pane.

5. Closing a tab of a ttk::notebook widget with the aid of the closetab
element: ... the tab is not (yet) closed. Instead, the widget generates
a <<CloseTabRequested>> virtual event, by invoking event generate with
the -data option set to the numerical index of the tab in question. It
is the responsibility of the application to create a binding for this
virtual event and to close the tab from within the binding script by
invoking the widget's forget subcommand if appropriate, ...

According to the above, the programmer has in both cases full control
over the widget that has been removed from the notebook.

Note that the <<NotebookTabClosed>> virtual event is defined for the
plainnotebook widget, too, whose tabs ca be closed interactively with
the aid of the closebtn element.

> But then, I see a second, and more difficult, problem:
> What happens when the whole notebook is destroyed ?
> What happens to its contents (i.e. its slave widgets) ?
>
> Let's consider this example;
> +------------------
> toplevel .z
> frame .z.f
> pack [ttk::notebook .z.f.nb -expand true -fill both] ;# .z.nb could also be a scrollutil::notebook
> ..
> .z.nb add [frame .z.f.nb.f1 -bg red] -title "f1" ;# --
> .z.nb add [frame .z.f.nb.f2 -bg green] -title "f2"
> .z.nb add [frame .z.f3 -bg blue] -title "f3" ;# note: this slave is not a descendent of .z.f.nb !!
> ...
> destroy .z.f.nb ; # this might be caused by an interactive cleanup of the .z.f frame ...
> +---------
>
> Consider that after notebook has been destroyed:
> ... slave f1 and f2 are automatically destroyed, but "f3" is always there (unmapped)
> ... moreover, if "f1" or "f2" were complex megawidgets with some allocated resources like sockets, images .., then thse resources won't be deallocated !
>
>
> In conclusion, I have just shown what in my opinion is the problem of loss of control when these operations are performed interactively (closing a tab, destroying a notebook); I hope there is a simple general solution...
> Suggestions ?

This second problem is independent of the closetab and closebtn elements.

--
Csaba Nemethi https://www.nemethi.de mailto:csaba.nemethi@t-online.de

Re: Notebooks: the lost tabs problem

<68107714-3690-444a-8ebc-ba30cf68a41bn@googlegroups.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=12030&group=comp.lang.tcl#12030

  copy link   Newsgroups: comp.lang.tcl
X-Received: by 2002:ac8:7d46:0:b0:403:acaa:abe0 with SMTP id h6-20020ac87d46000000b00403acaaabe0mr61890qtb.8.1692275916182;
Thu, 17 Aug 2023 05:38:36 -0700 (PDT)
X-Received: by 2002:a05:6a00:1798:b0:67d:4073:9e18 with SMTP id
s24-20020a056a00179800b0067d40739e18mr2426390pfg.2.1692275915745; Thu, 17 Aug
2023 05:38:35 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!tncsrv06.tnetconsulting.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer03.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: Thu, 17 Aug 2023 05:38:35 -0700 (PDT)
In-Reply-To: <ubkpbk$6qnh$1@tota-refugium.de>
Injection-Info: google-groups.googlegroups.com; posting-host=93.44.166.97; posting-account=CpQfUQoAAACWuSZdT5zfmIK7a0FfbQ0B
NNTP-Posting-Host: 93.44.166.97
References: <8638a35a-58f1-4f5b-aa2b-97b7ab0e0685n@googlegroups.com> <ubkpbk$6qnh$1@tota-refugium.de>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <68107714-3690-444a-8ebc-ba30cf68a41bn@googlegroups.com>
Subject: Re: Notebooks: the lost tabs problem
From: aldo.w.buratti@gmail.com (aldo.w....@gmail.com)
Injection-Date: Thu, 17 Aug 2023 12:38:36 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 2312
 by: aldo.w....@gmail.com - Thu, 17 Aug 2023 12:38 UTC

Thank you for your answer, Csaba.
Your reference manual is complete and clear, as usual. It's only my confusion.
I'd just kindly suggest to remove support for Tk <= 8.5 - I wonder who is still using Tk 8.5 for a modern app ! Both code and reference pages will be simplified. - Anyway, this is just my opinion ;-)

About the second question (..what happens when a notebook is deleted..) I understand it's not a problem regarding the closetab, but it's still a problem I solved just for very specific cases, and I'd like to find a more general solution.

To be more clear, what I'm trying to do is to use an "extended" ttk::notebook for building a multi-tab PDF-viewer (using mupdfWidget), much like AcrobatReader. Tabs can be moved, closed, and also 'detached' .
Here the problem is to 'gracefully close' all the enclosed PDF-viewers when the enclosing Notebook is destroyed.
In this specific case, it was easy, because all the enclosed megawidgets have a destructor that is triggered when the notebook is destroyed (and consequently it destroys all its children widgets.. ).
I hope to publish a proof of concept on wiki.tcl.tk, the next days.

Aldo


devel / comp.lang.tcl / Notebooks: the lost tabs problem

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor