Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

If imprinted foil seal under cap is broken or missing when purchased, do not use.


devel / comp.lang.python / RE: Problem resizing a window and button placement

SubjectAuthor
o RE: Problem resizing a window and button placementSteve GS

1
RE: Problem resizing a window and button placement

<mailman.24.1709018004.3452.python-list@python.org>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=29564&group=comp.lang.python#29564

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: Gronicus@SGA.Ninja (Steve GS)
Newsgroups: comp.lang.python
Subject: RE: Problem resizing a window and button placement
Date: Tue, 27 Feb 2024 02:13:19 -0500
Lines: 232
Message-ID: <mailman.24.1709018004.3452.python-list@python.org>
References: <06f101da66da$902357f0$b06a07d0$@SGA.Ninja>
<C72A9439-2300-4DCD-8A56-7C3AAE718EF4@barrys-emacs.org>
<070d01da66fa$5faea870$1f0bf950$@SGA.Ninja>
<31caf694-99fd-41ca-a98c-cb0d5d4a758e@tompassin.net>
<077801da6782$4f6046d0$ee20d470$@SGA.Ninja>
<13edcbad-1914-424c-97aa-3679eaf77fd8@mrabarnett.plus.com>
<07b101da6795$97d57df0$c78079d0$@SGA.Ninja>
<5d93173f-b172-408a-a052-c670214581b2@mrabarnett.plus.com>
<07c701da679e$d3a8a6f0$7af9f4d0$@SGA.Ninja>
<dd484037-16c8-b707-89f6-99f327207913@yahoo.co.uk>
<083301da6830$63224480$2966cd80$@SGA.Ninja>
<cd441398-c4d4-4d33-9df7-43163b1d856d@tompassin.net>
<087801da6889$52395bf0$f6ac13d0$@SGA.Ninja>
<1b58d259-699f-dd89-581b-3eecbc4c3e07@yahoo.co.uk>
<000001da68a3$5cf1a830$16d4f890$@SGA.Ninja>
<97753bba-606f-4cac-a48f-64da2db80e65@tompassin.net>
<00c101da694c$71914df0$54b3e9d0$@SGA.Ninja>
Mime-Version: 1.0
Content-Type: text/plain;
charset="us-ascii"
Content-Transfer-Encoding: 7bit
X-Trace: news.uni-berlin.de BLJ8A7iECr2ot0Tm9y9VygMHwQkqVgesmJtDnmdvD2Mw==
Cancel-Lock: sha1:Iw8GD4FIccmQa1VDRs/YQzf3ciA= sha256:/5a0UhZscNmhPe35CFjwMjF5KTOQOw+VqEm8+JGIs4w=
Return-Path: <Gronicus@SGA.Ninja>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=pass
reason="2048-bit key; unprotected key"
header.d=sga.ninja header.i=@sga.ninja header.b=Ic4Uvafa;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.008
X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'def': 0.04; '26,': 0.07;
'tkinter': 0.07; 'fails': 0.09; "hasn't": 0.09; 'other.': 0.09;
'resizing': 0.09; 'window.': 0.09; 'import': 0.15; '2024': 0.16;
'aside': 0.16; 'constructed': 0.16; 'flickr': 0.16;
'from:addr:gronicus': 0.16; 'from:addr:sga.ninja': 0.16; 'gauld':
0.16; 'handler.': 0.16; 'message-id:@SGA.Ninja': 0.16; 'photo-
blog': 0.16; 'program?': 0.16; 'received:floathosting.com': 0.16;
'received:mars.floathosting.com': 0.16; 'sounds': 0.16; 'url-
ip:79.170.44.132/32': 0.16; 'url-ip:79.170.44/24': 0.16; 'url-
ip:79.170/16': 0.16; 'url-ip:79/8': 0.16; 'url:alan-g': 0.16;
'value?': 0.16; 'wrote:': 0.16; 'problem': 0.16; 'values': 0.17;
"can't": 0.17; 'url:amazon': 0.19; 'to:addr:python-list': 0.20;
'code': 0.23; 'idea': 0.24; 'skip:- 10': 0.25; 'url-
ip:188.166.95.178/32': 0.25; 'url-ip:188.166.95/24': 0.25;
'cannot': 0.25; 'url-ip:188.166/16': 0.25; 'do?': 0.26;
'function': 0.27; '>>>': 0.28; 'example,': 0.28; 'this?': 0.29;
'am,': 0.31; 'url-ip:188/8': 0.31; 'program': 0.31; 'python-list':
0.32; 'window': 0.32; 'unless': 0.32; 'but': 0.32; 'there': 0.33;
'able': 0.34; 'header:In-Reply-To:1': 0.34; 'close': 0.35;
'change': 0.36; 'using': 0.37; "it's": 0.37; 'author': 0.37;
'others': 0.37; 'way': 0.38; 'could': 0.38; 'read': 0.38;
'changes': 0.39; 'added': 0.39; 'use': 0.39; 'steve': 0.39;
'still': 0.40; 'alan': 0.40; 'program.': 0.40; 'whenever': 0.40;
'learn': 0.40; 'event': 0.40; 'skip:o 10': 0.61; 'from:': 0.62;
'to:': 0.62; 'point.': 0.62; 'follow': 0.62; 'skip:o 20': 0.63;
'button': 0.64; 'pass': 0.64; 'height': 0.64; 're:': 0.64;
'url:a': 0.64; 'your': 0.64; 'back': 0.67; 'outside': 0.67; 'url-
ip:3/8': 0.67; 'discovery': 0.69; 'url:author': 0.69; 'site':
0.70; 'them,': 0.70; 'global': 0.73; 'produces': 0.76; 'sent:':
0.78; 'placement': 0.81; 'demand.': 0.84; 'sizes': 0.84; 'width':
0.91; 'race': 0.93
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sga.ninja;
s=default;
h=Content-Transfer-Encoding:Content-Type:MIME-Version:Message-ID:
Date:Subject:In-Reply-To:References:To:From:Sender:Reply-To:Cc:Content-ID:
Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc
:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe:
List-Post:List-Owner:List-Archive;
bh=+z54ABOtXxZHOrZwIuFEcxdhDtJvI5evW0FXciFZrBw=; b=Ic4Uvafaq4tlBMdhBRiPNbEBM/
9OumtHPRYQaowi2Av8kjByXP0pnfL1QEYPDTGKb51CfuUe5/PlmWspoXpN7oA1TPev194590CWQK6
myhaC1td+bwnfQXTcElkOl7MyMOTM6H2vCEWDy7z9TIUfkIDrgMfOHzJQ5SVp/hxtbM5xkHZIGFDc
us6QZUGgwIIkclkQqzEsDQN1JhXleY2P2xfrAFYQsW/yQWQlWwzWsOqfKn3BBq7CGttFjuTS809JQ
OAIcq7boXHP+JSdlf+ief+yTou0vMsX9cz2GCC86oMVPheB4MsJOWVdhIkFCAx2ad8J6kZD7nOJhI
hnrtJKzQ==;
In-Reply-To: <97753bba-606f-4cac-a48f-64da2db80e65@tompassin.net>
X-Mailer: Microsoft Outlook 16.0
Thread-Index: AQJGy7zzXF4y2G8MeMWTWHq0fMItvQIzKKK2AzCygCMCTZHTpQJPWNtlAuepcsMCIock6AIvta91AZpYCAsBx1Fa3wLI9NlvAdYvt4cCGeJYTQJPg7WnAlorwc0C5Xw+8K8t2pCw
Content-Language: en-us
X-AntiAbuse: This header was added to track abuse,
please include it with any abuse report
X-AntiAbuse: Primary Hostname - mars.floathosting.com
X-AntiAbuse: Original Domain - python.org
X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12]
X-AntiAbuse: Sender Address Domain - SGA.Ninja
X-Get-Message-Sender-Via: mars.floathosting.com: authenticated_id:
gronicus@sga.ninja
X-Authenticated-Sender: mars.floathosting.com: gronicus@sga.ninja
X-Source:
X-Source-Args:
X-Source-Dir:
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: General discussion list for the Python programming language
<python-list.python.org>
List-Unsubscribe: <https://mail.python.org/mailman/options/python-list>,
<mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive: <https://mail.python.org/pipermail/python-list/>
List-Post: <mailto:python-list@python.org>
List-Help: <mailto:python-list-request@python.org?subject=help>
List-Subscribe: <https://mail.python.org/mailman/listinfo/python-list>,
<mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID: <00c101da694c$71914df0$54b3e9d0$@SGA.Ninja>
X-Mailman-Original-References: <06f101da66da$902357f0$b06a07d0$@SGA.Ninja>
<C72A9439-2300-4DCD-8A56-7C3AAE718EF4@barrys-emacs.org>
<070d01da66fa$5faea870$1f0bf950$@SGA.Ninja>
<31caf694-99fd-41ca-a98c-cb0d5d4a758e@tompassin.net>
<077801da6782$4f6046d0$ee20d470$@SGA.Ninja>
<13edcbad-1914-424c-97aa-3679eaf77fd8@mrabarnett.plus.com>
<07b101da6795$97d57df0$c78079d0$@SGA.Ninja>
<5d93173f-b172-408a-a052-c670214581b2@mrabarnett.plus.com>
<07c701da679e$d3a8a6f0$7af9f4d0$@SGA.Ninja>
<dd484037-16c8-b707-89f6-99f327207913@yahoo.co.uk>
<083301da6830$63224480$2966cd80$@SGA.Ninja>
<cd441398-c4d4-4d33-9df7-43163b1d856d@tompassin.net>
<087801da6889$52395bf0$f6ac13d0$@SGA.Ninja>
<1b58d259-699f-dd89-581b-3eecbc4c3e07@yahoo.co.uk>
<000001da68a3$5cf1a830$16d4f890$@SGA.Ninja>
<97753bba-606f-4cac-a48f-64da2db80e65@tompassin.net>
 by: Steve GS - Tue, 27 Feb 2024 07:13 UTC

>> The configuration event
hasn't fired at the time you
include the print statement in
the handler's def block, and
therefore the print function
inside your handler hasn't
invoked. It won't be invoked
until you resize the window.

Exactly....

>> There is no point (really?)
to saving the width and height
outside your
on_configure() function,
because outside that function
you can't know if they have
been changed. There could
even have been a race
condition where you use one
but the other changes before
you get around to using it.

Aside from using it to resized
the window, is there no way to
know the last value of the
change for use in the program?
I could write the value to a
label and read it back later
in the process but that sounds
to be klugy.

>> It's better just to ask tk
for the values whenever you
need them, as you do inside
your handler.

How would that be done?

SGA

-----Original Message-----
From: Python-list
<python-list-bounces+gronicus=
sga.ninja@python.org> On
Behalf Of Thomas Passin via
Python-list
Sent: Monday, February 26,
2024 8:34 AM
To: python-list@python.org
Subject: Re: Problem resizing
a window and button placement

On 2/26/2024 6:02 AM, Steve GS
via Python-list wrote:
> Although your code produces
the value of Ww outside the
function, I do not see how I
can use the value of Ww unless
I close the program.

The configuration event hasn't
fired at the time you include
the print statement in the
handler's def block, and
therefore the print function
inside your handler hasn't
invoked. It won't be invoked
until you resize the window.

There is no point to saving
the width and height outside
your
on_configure() function,
because outside that function
you can't know if they have
been changed. There could
even have been a race
condition where you use one
but the other changes before
you get around to using it.
It's better just to ask tk for
the values whenever you need
them, as you do inside your
handler.

> import tkinter as tk
>
> Ww = None # What does this
do? Why not Integer?
> WwZ = None
# These could be integers,
like 0, but that would not be
the correct # window sizes at
that point. The window is
either not constructed or it #
has some definite size that is
not zero.

> def on_configure(*args):
> global Ww
> global WwZ
> Ww =
root.winfo_width()
> print("9 Ww Inside
=<"+str(Ww)+">") # works
> WwZ = Ww * 2
> print("11 WwZ
Inside =<"+str(WwZ)+">") #
works
> return(Ww) #Can I
use this?
>
> root = tk.Tk()
>
root.bind('<Configure>',on_con
figure)
> print("15 Ww Inside1 =
<"+str(Ww)+">")
> #Ww2 = int(Ww) * 2 # fails
> print("17 WwZ Inside2 =
<"+str(WwZ)+">")
>
> root.mainloop()
>
> Ww2 = int(Ww) * 2 #Works
but only after the program
stops
> print("21 Ww Outside2 =
<"+str(WwZ)+">") # Can I have
concentric
> loops?
>
>
> SGA
>
> -----Original Message-----
> From: Alan Gauld
<learn2program@gmail.com>
> Sent: Monday, February 26,
2024 4:04 AM
> To: Steve GS
<Gronicus@SGA.Ninja>;
python-list@python.org
> Subject: Re: RE: Problem
resizing a window and button
placement
>
> On 26/02/2024 07:56, Steve
GS via Python-list wrote:
>
>> Then there is that
discovery
>> element: Why is my original
>> idea not working? I still
>> cannot pass the value back
>> from the function. What is
>> different about this
function
>> that others would have
given
>> me the value?
>
> There is nothing different,
see the code below.
> print() is a function like
any other.
> In this case it is called
after you close the window, ie
after mainloop() exits.
> But any other function
called inside
> mainloop - eg any other
event handler can also access
it.
>
> For example, if you added a
button:
>
> def printW(): print("Button
Ww = ", Ww)
>
> bw = tk.Button(root,
text="Print Width",
command=printW)
> bw.pack()
>
> You would be able to print
the value on demand.
>
>>> import tkinter as tk
>>>
>>> Ww = None
>>>
>>> def on_configure(*args):
>>> global Ww
>>> Ww =
root.winfo_width()
>>> print("Ww Inside
=<"+str(Ww)+">")
>>>
>>> root = tk.Tk()
>>>
root.bind('<Configure>',on_con
figure)
>>> root.mainloop()
>>>
>>> print("Ww Outside =
<"+str(Ww)+">")
>
> --
> Alan G
> Author of the Learn to
Program web site
http://www.alan-g.me.uk/
>
http://www.amazon.com/author/a
lan_gauld
> Follow my photo-blog on
Flickr at:
>
http://www.flickr.com/photos/a
langauldphotos
>
>

--
https://mail.python.org/mailma
n/listinfo/python-list

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor