Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

Steal my cash, car and TV - but leave the computer! -- Soenke Lange <soenke@escher.north.de>


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

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

1
RE: RE: Problem resizing a window and button placement

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

  copy mid

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

  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: RE: Problem resizing a window and button placement
Date: Mon, 26 Feb 2024 06:02:59 -0500
Lines: 89
Message-ID: <mailman.21.1708945385.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>
Mime-Version: 1.0
Content-Type: text/plain;
charset="utf-8"
Content-Transfer-Encoding: quoted-printable
X-Trace: news.uni-berlin.de AMbHBcI2uhca8GlYBsm+7gd9mypc7r0X0GwNqtjZHv8Q==
Cancel-Lock: sha1:6fHfBnO0b1sJDL0V50A1bphm0xE= sha256:z7T9ty/2vk0SADx5TZQh6JNhR9z4zB+gjbKV7PDTCLE=
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=Fy2503kF;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.005
X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'def': 0.04; '26,': 0.07;
'tkinter': 0.07; 'fails': 0.09; 'other.': 0.09; 'resizing': 0.09;
'url-ip:162.219/16': 0.09; 'import': 0.15; '2024': 0.16; 'flickr':
0.16; 'from:addr:gronicus': 0.16; 'from:addr:sga.ninja': 0.16;
'gauld': 0.16; 'message-id:@SGA.Ninja': 0.16; 'photo-blog': 0.16;
'received:floathosting.com': 0.16;
'received:mars.floathosting.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; '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; 'example,': 0.28; 'this?': 0.29;
'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; 'author': 0.37; 'others': 0.37;
'added': 0.39; 'use': 0.39; 'steve': 0.39; 'still': 0.40; 'alan':
0.40; 'program.': 0.40; 'learn': 0.40; 'event': 0.40; 'from:':
0.62; 'to:': 0.62; 'follow': 0.62; 'skip:o 20': 0.63; 'button':
0.64; 'pass': 0.64; 'skip:r 20': 0.64; 're:': 0.64; 'your': 0.64;
'back': 0.67; 'outside': 0.67; 'discovery': 0.69; 'url:author':
0.69; 'site': 0.70; 'global': 0.73; 'produces': 0.76; 'sent:':
0.78; 'placement': 0.81; 'demand.': 0.84
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=iyfhXeEClzeBbv4kxcKHfapgbxz/NmWwdhE6zKKlgDU=; b=Fy2503kF/FlMpdUsa9E/6uYr1h
kmzN9EWf+abL+k2s+mn9T9CGyRsTEHRJcv+/bNIP+K7xG3uzMroVecSQaqrNSllwvMx5YJgufulXV
1p6+V2r74zO0stj8TuH5WqIjhNaytSJPtdwIzFNa238HpZ/cQjA6fsh+AVURk9zZVdS9SRIUfRuEg
AVEGA6m2FSAfhYIBEXQ9ZVOxxtOpb52r3mND+W7j8SK/T61TVmY7OtAmyoyEkuQa0xD6RrP1rE7qz
bOETX7w2waqEq+Gh8vArapw5rsemy9rEl52JXXTy/pZzCxOlckgRyugXg622BT6/8H/WY8eq5CuTo
4v7GZkzQ==;
In-Reply-To: <1b58d259-699f-dd89-581b-3eecbc4c3e07@yahoo.co.uk>
X-Mailer: Microsoft Outlook 16.0
Thread-Index: AQJGy7zzXF4y2G8MeMWTWHq0fMItvQIzKKK2AzCygCMCTZHTpQJPWNtlAuepcsMCIock6AIvta91AZpYCAsBx1Fa3wLI9NlvAdYvt4cCGeJYTQJPg7Wnr1Z/UoA=
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: <000001da68a3$5cf1a830$16d4f890$@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>
 by: Steve GS - Mon, 26 Feb 2024 11:02 UTC

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.

import tkinter as tk

Ww = None # What does this do? Why not Integer?
WwZ = None

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