Rocksolid Light

News from da outaworlds

mail  files  register  groups  login

Message-ID:  

Break into jail and claim police brutality.


comp / comp.lang.tcl / How do I pack a megawidget?

SubjectAuthor
* How do I pack a megawidget?Luc
+- Re: How do I pack a megawidget?saito
`- Re: How do I pack a megawidget?Rich

1
Subject: How do I pack a megawidget?
From: Luc
Newsgroups: comp.lang.tcl
Organization: A noiseless patient Spider
Date: Wed, 3 Jul 2024 16:59 UTC
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: luc@sep.invalid (Luc)
Newsgroups: comp.lang.tcl
Subject: How do I pack a megawidget?
Date: Wed, 3 Jul 2024 13:59:38 -0300
Organization: A noiseless patient Spider
Lines: 39
Message-ID: <20240703135938.0093ccb5@lud1.home>
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 03 Jul 2024 18:59:39 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="0f80b7f390422deb4886b3704ebb7b0b";
logging-data="2397141"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18LlacQenXbGtL2TSf+pRppQeyvJNUTO1o="
Cancel-Lock: sha1:A4lZp6x7SQhq09jqQ7NNHhCEPnw=
View all headers

I know y'all gonna hate this question because I'm not showing much code,
but I am really more interested in concepts than code.

I made a package. It's supposed to be a megawidget. I haven't snitted it
yet. I can't snit it without understanding where I am supposed to go
with it. So here is the problem.

package require giggles

set of $::w.outerframe
frame $of -height 100
pack $of -fill both -expand 1

set gg $of.giggles
::giggles::giggles $gg -guifont "Arial 14" -geometry pack
pack $gg -fill both -expand 1

And it works. The prototype megawidget is inserted into my test parent
application.

The problem is, commenting out the last 'pack' line makes no difference.
The megawidget still shows. (Also, funny that apparently it's redundant
but nothing clashes.) And of course that is not standard widget behavior.

Of course, I am packing everything in the megawidget. But if I don't,
then what? I can't just leave it hanging because if I do, then the
author of the parent widget will have to inspect the code of the
megawidget to figure out what he is supposed to pack to get it all
working which, again, is not standard widget behavior, it's actually
pretty stupid. I have to expose something. Something that will take
the 'pack' command from the parent application and make the entire
megawidget come together, with all of its components.

How do I do that?

--
Luc
>>

Subject: Re: How do I pack a megawidget?
From: saito
Newsgroups: comp.lang.tcl
Organization: A noiseless patient Spider
Date: Wed, 3 Jul 2024 17:37 UTC
References: 1
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: saitology9@gmail.com (saito)
Newsgroups: comp.lang.tcl
Subject: Re: How do I pack a megawidget?
Date: Wed, 3 Jul 2024 13:37:26 -0400
Organization: A noiseless patient Spider
Lines: 35
Message-ID: <v6428m$29ksi$1@dont-email.me>
References: <20240703135938.0093ccb5@lud1.home>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 03 Jul 2024 19:37:27 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="7294c0979d107698d3a8349e4e0fc5d2";
logging-data="2413458"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+oAwcENWyZmplaz6A+8dh5"
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:sLDMdYNrRA+Kv1D7oQ8ONl72W88=
Content-Language: en-US
In-Reply-To: <20240703135938.0093ccb5@lud1.home>
View all headers

On 7/3/2024 12:59 PM, Luc wrote:
> I know y'all gonna hate this question because I'm not showing much code,
> but I am really more interested in concepts than code.
>
> I made a package. It's supposed to be a megawidget. I haven't snitted it
> yet. I can't snit it without understanding where I am supposed to go
> with it. So here is the problem.
>
> package require giggles
>
> set of $::w.outerframe
> frame $of -height 100
> pack $of -fill both -expand 1
>
> set gg $of.giggles
> ::giggles::giggles $gg -guifont "Arial 14" -geometry pack
> pack $gg -fill both -expand 1
>
> And it works. The prototype megawidget is inserted into my test parent
> application.
>
> The problem is, commenting out the last 'pack' line makes no difference.
> The megawidget still shows. (Also, funny that apparently it's redundant
> but nothing clashes.) And of course that is not standard widget behavior.
>

The reason giggles gets displayed automatically is because it has no
layering between gg and its internal widgets. I think you can easily
solve this by including an additional frame containing your megawidget
with all of its sub widgets packed as you want. Then you let the user
of your megawidget do the final packing. This way they giggles
instances won't automatically show and your users remain in charge of
their visibility.

Subject: Re: How do I pack a megawidget?
From: Rich
Newsgroups: comp.lang.tcl
Organization: A noiseless patient Spider
Date: Wed, 3 Jul 2024 17:58 UTC
References: 1
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: rich@example.invalid (Rich)
Newsgroups: comp.lang.tcl
Subject: Re: How do I pack a megawidget?
Date: Wed, 3 Jul 2024 17:58:32 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 85
Message-ID: <v643g7$29pm8$1@dont-email.me>
References: <20240703135938.0093ccb5@lud1.home>
Injection-Date: Wed, 03 Jul 2024 19:58:32 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="d715ae27fff3334899afc0fb7a53206e";
logging-data="2418376"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/3Paf767y4xdNeS0h1FETP"
User-Agent: tin/2.6.1-20211226 ("Convalmore") (Linux/5.15.139 (x86_64))
Cancel-Lock: sha1:oldrTwMwJnSPlaOG/nCvsc16btI=
View all headers

Luc <luc@sep.invalid> wrote:
> I know y'all gonna hate this question because I'm not showing much code,
> but I am really more interested in concepts than code.
>
> I made a package. It's supposed to be a megawidget. I haven't snitted it
> yet. I can't snit it without understanding where I am supposed to go
> with it. So here is the problem.
>
> package require giggles
>
> set of $::w.outerframe
> frame $of -height 100
> pack $of -fill both -expand 1
>
> set gg $of.giggles
> ::giggles::giggles $gg -guifont "Arial 14" -geometry pack
> pack $gg -fill both -expand 1
>
> And it works. The prototype megawidget is inserted into my test parent
> application.
>
> The problem is, commenting out the last 'pack' line makes no difference.
> The megawidget still shows. (Also, funny that apparently it's redundant
> but nothing clashes.) And of course that is not standard widget behavior.
>
> Of course, I am packing everything in the megawidget. But if I don't,
> then what? I can't just leave it hanging because if I do, then the
> author of the parent widget will have to inspect the code of the
> megawidget to figure out what he is supposed to pack to get it all
> working which, again, is not standard widget behavior, it's actually
> pretty stupid. I have to expose something. Something that will take
> the 'pack' command from the parent application and make the entire
> megawidget come together, with all of its components.
>
> How do I do that?

You have at least two choices:

1) You document "giggles" to require a user of "giggles" creates a
frame widget, and passes it into your "giggles" call, and you pack
everything into that frame. It looks, from the above code, like this
is the option you have chosen. But, this makes your megawidget
different from the Tk native widgets. You don't pass a "frame" to
"text" and have "text" build a "text widget" inside that frame.

2) You redesign "giggles" that it receives a "window path name" and it
creates a frame of that path name, and then packs everything that makes
up a "giggles" into that new frame, and then "giggles" returns the name
of that frame. This makes the megawidget more native like, because you
pass a name of a window that does not yet exist, and the "giggles" call
creates a window of that name.

#2 is also the part where Snit helps, because left to its own devices,
that frame is just a regular Tk frame, and the only configure/cget
options it understands are those for frames. Snit lets you build this
as a window heirarchy (this will only look right with a monospaced
font, and note, I'm making this up):

gframe
|--label
|--inner frame
| |--text widget
| |--scrollbar
|--label

What Snit helps with is allowing "gframe" to be the name of your window
(.something.something.gframe) and also a command for "driving" the
widget. Snit lets you redirect calls to .abc.gframe for say "insert"
to actually be delivered to the buried text widget
(.abc.gframe.inner frame.text widget)[1] so that users can call:

..abc.gframe insert end "This is extra text"

And have it really call:

..abc.gframe.inner frame.text widget insert end "This is extra text"

Without you having to manually do the command renamings necessary to
make that magic happen.

[1] Yes, Tk window paths can't have spaces in reality -- this is just
an explanation of one of the things Snit does for you if you use it to
build a megawidget.

1

rocksolid light 0.9.8
clearnet tor