Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

To the systems programmer, users and applications serve only to provide a test load.


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

SubjectAuthor
* Re: Problem resizing a window and button placementThomas Passin
`- Re: Problem resizing a window and button placementStefan Ram

1
Re: Problem resizing a window and button placement

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

  copy mid

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

  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: Sat, 24 Feb 2024 08:39:55 -0500
Lines: 73
Message-ID: <mailman.5.1708784264.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>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: news.uni-berlin.de yWb2HYlpBe5HcCyrCyM0ewlN4nRaY1puqWA7aO6Sm0uQ==
Cancel-Lock: sha1:w6M9hLsEcAfDb/IXjhD5q9oKVrM= sha256:UCJAaL89EcrV1XRGJwSnxiBMRK2r587QcGFDboiXcVk=
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=UOVyV3qp;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.063
X-Spam-Evidence: '*H*': 0.87; '*S*': 0.00; 'variable': 0.05;
'resizing': 0.09; 'values.': 0.09; 'window.': 0.09; 'that.': 0.15;
'2024': 0.16; 'barry': 0.16; 'declare': 0.16; 'design.': 0.16;
'does,': 0.16; 'languages.': 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;
'want,': 0.16; 'wrote:': 0.16; 'problem': 0.16; 'python': 0.16;
'values': 0.17; 'code.': 0.17; 'feb': 0.17; 'to:addr:python-list':
0.20; 'ran': 0.22; 'code': 0.23; 'run': 0.23; 'skip:- 10': 0.25;
'cannot': 0.25; 'programming': 0.25; 'perform': 0.26; 'local':
0.27; 'function': 0.27; 'printed': 0.28; 'header:User-Agent:1':
0.30; 'seem': 0.31; 'am,': 0.31; 'think': 0.32; 'extract': 0.32;
'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; 'header:In-Reply-To:1': 0.34; 'yes,': 0.35;
'those': 0.36; 'added': 0.39; 'use': 0.39; 'steve': 0.39;
'reports': 0.40; 'learn': 0.40; 'try': 0.40; 'should': 0.40;
'event': 0.40; 'method': 0.61; 'from:': 0.62; 'to:': 0.62;
'between': 0.63; 'button': 0.64; 'height': 0.64; 're:': 0.64;
'your': 0.64; 'look': 0.65; 'outside': 0.67; 'header:Received:6':
0.67; 'received:64': 0.67; 'cc:': 0.69; 'instead,': 0.70; 'rules':
0.70; 'global': 0.73; 'languages,': 0.76; 'vary': 0.76; 'sent:':
0.78; 'placement': 0.81; 'capture': 0.84; 'global.': 0.84;
'responds': 0.84; 'saturday,': 0.84; 'sub': 0.91; 'width': 0.91
X-Sender-Id: dreamhost|x-authsender|tpassin@tompassin.net
ARC-Seal: i=1; s=arc-2022; d=mailchannels.net; t=1708782002; a=rsa-sha256;
cv=none;
b=1laVtN/CFYqWfXNs5ECLhrCLG36TDgqQtAvpQGIILjBI0Ha2Ij9i3daLPMp4pqeXFELSBe
Htwn3MAzSn84z34Xdz2ZyVsyJiLDqUZATNj978VrgR5VV+UQ9v0U/C/MBBU3OiG4ODBT9G
09t/IMXbuNuTFVioZkmML9HIYAGIIVefQEyBEyM03dM6NcPnVtyHuLl2nLE98+/lSQ/AkQ
7CBtnm6Z9lIz5wv8q/ApTo2fLu8a1Cy0RuZu9jqdXD+GksDr1HwB43D4fLYlmIwiBMXRYz
Uis2LLYgeCTHIzpnqxqoOUqPQ1Impf+9zEfgq1hkqp/F9W78voapkNA3Afmdfg==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed;
d=mailchannels.net; s=arc-2022; t=1708782002;
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=+sSOoGE+nUa3ta73wlYvgrOUxnbWggEMY5mqvGJD69Q=;
b=qObMgeYVNDGG/BBklvzyJFGQHvnpuThrW9AiJgovPSssUayn3S2fh+/bOvJ2XW4HP4QBwJ
0HLLH1t3lgCxvFXUEVWNIdAQyCauZbcfHnQ9Ogy+Yn2xw11L0cO1iBC+Vkn7tD9ZoqX7h8
nmR4gEKL9v8DEnMIhueCrUiK/zDScepabAyB9TZp1YH/vb4KoKuDxKPkcxPw4NwZmN3axC
2/HwjAxc6xE8DAN4+PzMBshF21R80mA4D7hSOMke0HVV3MnafbhZKXZZ/10KKgb8/WUiyQ
N+ZkGf7QCJpglD8+3aK+bm9XbKalFTfCcr7Z9K0ecItnhrY/K+rnJjcSAwmFzQ==
ARC-Authentication-Results: i=1; rspamd-6bdc45795d-wwsbl;
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-Stretch-Spill: 6e983db54397b448_1708782002759_447307531
X-MC-Loop-Signature: 1708782002759:2017523846
X-MC-Ingress-Time: 1708782002758
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tompassin.net;
s=dreamhost; t=1708782002;
bh=+sSOoGE+nUa3ta73wlYvgrOUxnbWggEMY5mqvGJD69Q=;
h=Date:Subject:To:From:Content-Type:Content-Transfer-Encoding;
b=UOVyV3qp8JdtJtV0LZSSsbTQ5OjKtMvKgXC9+6CgoaMrPvSA99WCpZOMQDoaheQ7+
uVXBAYBR5ZbMzT4PZb+jWuGcQCUyzjJYkmEvKBNfCu1tiJXZYwcdrn37ACRuwVuq3M
US2yZRlYMlZhKcYCeb9jsway+Z2Kdymy9XVe6vJ4iHBmjWbk8FynGEWF5qw8yRjJmh
M92Lgq1B7r7fEJnq2zIA6O+6rlR5z0erN2+eV1BO4SqYEhJjJ7IeuHDimWL+V2eUuh
SKNYUXidZZJ/hfFMISumGuycvR8ODQpYKsQEYx1gqe0HEVOk7RHAfUfxCTJnKVaFGj
hiDKWEQgmSQrw==
User-Agent: Mozilla Thunderbird
Content-Language: en-US
In-Reply-To: <070d01da66fa$5faea870$1f0bf950$@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: <31caf694-99fd-41ca-a98c-cb0d5d4a758e@tompassin.net>
X-Mailman-Original-References: <06f101da66da$902357f0$b06a07d0$@SGA.Ninja>
<C72A9439-2300-4DCD-8A56-7C3AAE718EF4@barrys-emacs.org>
<070d01da66fa$5faea870$1f0bf950$@SGA.Ninja>
 by: Thomas Passin - Sat, 24 Feb 2024 13:39 UTC

On 2/24/2024 3:20 AM, Steve GS via Python-list wrote:
> Yes, I ran that elegantly
> simple code. The print
> statement reports the X, Y,
> Height and Width values.
> However, I do not see how to
> capture the width value.
>
> I experimented with the code
> Vwidth = rootV.winfo_width()
> and it also reports the width
> as I resize the window.
>
> However, I cannot seem to use
> the variable Vwidth outside
> the sub routine. It is acting
> as if Vwidth is not global but
> I added that. It is reported
> that Vwidth is not defined
> when I try to use it in my
> code.

Well, yes, in Python a variable created inside a function or method is
local to that function unless you declare it global. That characteristic
is called its "scope". But if you think you need it to be a global
variable you should rethink your design. For one thing, before the next
time you use your global variable the window size may have changed again.

Instead, it would be better to have the function that responds to the
resize event perform the action that you want, or call another function
that does, passing the new width to it.

Note that in most programming languages, variables have a scope. The
rules about those scopes vary between languages.

>
> So close......
> SGA
>
> -----Original Message-----
> From: Barry
> <barry@barrys-emacs.org>
> Sent: Saturday, February 24,
> 2024 3:04 AM
> To: Steve GS
> <Gronicus@sga.ninja>
> Cc: MRAB
> <python@mrabarnett.plus.com>;
> python-list@python.org
> Subject: Re: Problem resizing
> a window and button placement
>
>
>
>> On 24 Feb 2024, at 04:36,
> Steve GS via Python-list
> <python-list@python.org>
> wrote:
>>
>> How do I extract the values
>> from args?
>
> You can look up the args in
> documentation.
> You can run the example code
> MRAB provided and see what is
> printed to learn what is in
> the args.
>
> Barry
>
>

Re: Problem resizing a window and button placement

<globals-20240224152703@ram.dialup.fu-berlin.de>

  copy mid

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

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: ram@zedat.fu-berlin.de (Stefan Ram)
Newsgroups: comp.lang.python
Subject: Re: Problem resizing a window and button placement
Date: 24 Feb 2024 14:37:49 GMT
Organization: Stefan Ram
Lines: 65
Expires: 1 Feb 2025 11:59:58 GMT
Message-ID: <globals-20240224152703@ram.dialup.fu-berlin.de>
References: <mailman.0.1708738860.3452.python-list@python.org> <C72A9439-2300-4DCD-8A56-7C3AAE718EF4@barrys-emacs.org> <mailman.5.1708784264.3452.python-list@python.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Trace: news.uni-berlin.de 1HFpfd4NIag86yZQS+mgvAHpvuXKHPw4+iT++WsnxrcThn
Cancel-Lock: sha1:OgehupPsQjcAPoWDm2/pNnwj1yc= sha256:ZDDPRPIUiwTMFv0zJS0xmwTYDNOJq0PoAZlsfs4fQXY=
X-Copyright: (C) Copyright 2024 Stefan Ram. All rights reserved.
Distribution through any means other than regular usenet
channels is forbidden. It is forbidden to publish this
article in the Web, to change URIs of this article into links,
and to transfer the body without this notice, but quotations
of parts in other Usenet posts are allowed.
X-No-Archive: Yes
Archive: no
X-No-Archive-Readme: "X-No-Archive" is set, because this prevents some
services to mirror the article in the web. But the article may
be kept on a Usenet archive server with only NNTP access.
X-No-Html: yes
Content-Language: en-US
Accept-Language: de-DE-1901, en-US, it, fr-FR
 by: Stefan Ram - Sat, 24 Feb 2024 14:37 UTC

Thomas Passin <list1@tompassin.net> writes:
>Well, yes, in Python a variable created inside a function or method is
>local to that function unless you declare it global.

Or equivalent,

main.py

def f():
globals()[ 'x' ]= 2 # not a declaration!

f()

print( x )

_sys.stderr

2

>But if you think you need it to be a global variable you
>should rethink your design.

"Global" variables in Python are actually just "module variable".
Module variables are not so bad. If you think of the module as a
singleton object it's kinda like a class.

But the usual recommendation is to use a class. I.e., transform

main.py

def write_global():
globals()[ 'x' ]= 2

def read_global():
print( globals()[ 'x' ])

write_global()
read_global()

_sys.stderr

2

into

class Object_:
def write_field( self ):
self.x = 2
def read_field( self ):
print( self.x )

object_ = Object_()
object_.write_field()
object_.read_field()

_sys.stderr

2

>For one thing, before the next time you use your global
>variable the window size may have changed again.

The OP might be sleep walking into writing his own ad hoc,
informally-specified, bug-ridden, slow implementation of
half of a geometry manager like "pack" or "grid".

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor