Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

I use technology in order to hate it more properly. -- Nam June Paik


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

SubjectAuthor
o Re: Problem resizing a window and button placementThomas Passin

1
Re: Problem resizing a window and button placement

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

  copy mid

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

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: list1@tompassin.net (Thomas Passin)
Newsgroups: comp.lang.python
Subject: Re: Problem resizing a window and button placement
Date: Mon, 26 Feb 2024 08:34:19 -0500
Lines: 104
Message-ID: <mailman.23.1708954470.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>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: news.uni-berlin.de PGOFDQhRdL68NQ6uqecYEg6AA/3BXkR8YAC3PiZHCk6A==
Cancel-Lock: sha1:dXfUwwEt14bvI5mL39jIL5ft2+4= sha256:wxeQbxooBlh+OLrm6iA/TPxBCcSR9wsmM3GodFtsLjo=
Return-Path: <list1@tompassin.net>
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=tompassin.net header.i=@tompassin.net header.b=RQ/tTBrE;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.007
X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'def': 0.04; '26,': 0.07;
'tkinter': 0.07; 'fails': 0.09; "hasn't": 0.09; 'other.': 0.09;
'received:23.83.212': 0.09; 'received:elm.relay.mailchannels.net':
0.09; 'resizing': 0.09; 'window.': 0.09; 'import': 0.15; '2024':
0.16; 'constructed': 0.16; 'flickr': 0.16; 'gauld': 0.16;
'handler.': 0.16; 'photo-blog': 0.16; 'received:10.0.0': 0.16;
'received:64.90': 0.16; 'received:64.90.62': 0.16;
'received:64.90.62.162': 0.16; 'received:dreamhost.com': 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;
'url:alan_gauld': 0.16; 'url:alangauldphotos': 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; 'cannot': 0.25; 'do?':
0.26; 'function': 0.27; '>>>': 0.28; 'example,': 0.28; 'this?':
0.29; 'header:User-Agent:1': 0.30; 'am,': 0.31; 'program': 0.31;
'python-list': 0.32; 'received:10.0': 0.32;
'received:mailchannels.net': 0.32;
'received:relay.mailchannels.net': 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; 'using': 0.37; "it's": 0.37; 'author':
0.37; 'others': 0.37; 'could': 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;
'skip:r 20': 0.64; 'height': 0.64; 're:': 0.64; 'your': 0.64;
'back': 0.67; 'outside': 0.67; 'header:Received:6': 0.67;
'received:64': 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
X-Sender-Id: dreamhost|x-authsender|tpassin@tompassin.net
ARC-Seal: i=1; s=arc-2022; d=mailchannels.net; t=1708954459; a=rsa-sha256;
cv=none;
b=eISymEL3B5W7dT2F46bdlZbDa96KUTUk2WuN/S4rZ+uifVk5yQNQkb7hUzsaWosxkF8LNZ
ARH0K6Pwq1qV4j2LHZFEi3G3v6GmNdRJoCjcAhJ6ABM2SdFY4tsB9ue3qgrPbp8RRshGW9
AI3FaLO615e1TMvKpH56YUj/8rQXopP98VNvDbHIOU49tBPJyd7vZY0y/c7dutf3O15too
zB7nZQjReam3hRULCB8wzegq6YpKoTdyZjfO5UbmEEcetlNJf6wJ7GRf48UO9BOl++ya1Q
uGdjmn9JQYLKO6jfmXlP/n7yJF8gqj65YdfXYtkdlA7743OJSJAKJjIGcNbq5Q==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed;
d=mailchannels.net; s=arc-2022; t=1708954459;
h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
to:to:cc:mime-version:mime-version:content-type:content-type:
content-transfer-encoding:content-transfer-encoding:
in-reply-to:in-reply-to:references:references:dkim-signature;
bh=In0HoyiozI5CAX5XexRvYzFLCLSXBEhtM2LT/oJCyZ8=;
b=PYS9lKAI64PP4tgf4QdfCbV+eST56JDaDw8LH7Z54HbbYqPSLfkNIAHQxVDq884NZNRk5O
A5LovI+HKYJ11H2WVJ04vFQOGlXF8BVoy/vfbdA9WK+kJi0u8VjffZ1nbaxvUstnuAlgR6
YaBCdiuMvKyI7pxUfl7B7fYHe/ipeJ4+6P/fzJu439SHrA5XxF2cQbaA+mGHqGrc0f8sl1
M3+/8UkUChan8kxds7roR9wxyszpGDuEN0ufFUq7ZiY/NRrBJMayrbnLgFFDPfXG7crxZ3
Xq+qGjRJhy3LoqkZMuy9aZ5qOk1mT1gbk7Pi2BSxFxUrSQqASnHgRGW6iySZHQ==
ARC-Authentication-Results: i=1; rspamd-6bdc45795d-8msw8;
auth=pass smtp.auth=dreamhost smtp.mailfrom=list1@tompassin.net
X-Sender-Id: dreamhost|x-authsender|tpassin@tompassin.net
X-MC-Relay: Neutral
X-MailChannels-SenderId: dreamhost|x-authsender|tpassin@tompassin.net
X-MailChannels-Auth-Id: dreamhost
X-Illustrious-Zesty: 4e8142b57ba6424a_1708954459546_2749482237
X-MC-Loop-Signature: 1708954459545:2799827733
X-MC-Ingress-Time: 1708954459545
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tompassin.net;
s=dreamhost; t=1708954459;
bh=In0HoyiozI5CAX5XexRvYzFLCLSXBEhtM2LT/oJCyZ8=;
h=Date:Subject:To:From:Content-Type:Content-Transfer-Encoding;
b=RQ/tTBrEZNwUkhlWDTyzAtpQMxwXu2Fw2iym3AKE/CyDoioUTDKdViutXCfBLDSU/
upGlVZa3vvi50+nIqaadkoFOgYz3ULw210jj+oyjs7NWihGo1bV434z5GsdcwDHDmT
ohLEyyWCTTtZESQ0yMeXORx/4TsHAViO3kczeiMq9UBiKYJkuVjqtXl7+0AM2NZSDM
ecKWU7XZ+oeaN7ueqTZ1XVKcjfMFWFGGwYolYRS6feZ/h8+hBsWcLRQAzbfamlgJvz
8KmHjN/NGbPb7Y++k17pLQwLG8MTCOxzg4TGPbBsSdA78xGQeZkALMLMuBI5QDH+Iq
CV/Vd03OL1Pzg==
User-Agent: Mozilla Thunderbird
Content-Language: en-US
In-Reply-To: <000001da68a3$5cf1a830$16d4f890$@SGA.Ninja>
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: <97753bba-606f-4cac-a48f-64da2db80e65@tompassin.net>
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>
 by: Thomas Passin - Mon, 26 Feb 2024 13:34 UTC

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_configure)
> 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_configure)
>>> 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/alan_gauld
> Follow my photo-blog on Flickr at:
> http://www.flickr.com/photos/alangauldphotos
>
>

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor