Problem resizing a window and button placement

Steve GS Gronicus at SGA.Ninja
Sat Feb 24 21:51:54 EST 2024


import tkinter as tk

#global Ww  Neither global
helps
def on_configure(*args):
#     print(args)
     #global Ww  Neither
global helps
     Ww = root.winfo_width()
     print("WwInside = <" +
str(Ww) + ">")

root = tk.Tk()
root.bind('<Configure>',
on_configure)
print("WwOutside = <" +
str(Ww) + ">")
#NameError: name 'Ww' is not
defined
root.mainloop()

SGA

-----Original Message-----
From: Python-list
<python-list-bounces+gronicus=
sga.ninja at python.org> On
Behalf Of MRAB via Python-list
Sent: Saturday, February 24,
2024 7:49 PM
To: python-list at python.org
Subject: Re: Problem resizing
a window and button placement

On 2024-02-25 00:33, Steve GS
via Python-list wrote:
> "Well, yes, in Python a
> variable created inside a
> function or method is local
to
> that function unless you
> declare it global."
> 
> Yes, I knew that. I tried to
> global it both before the
> function call and within it.
> Same for when I created the
> variable. If I try to use it
> in the rest of the code, it
> keeps coming up as not
> declared.  In other
functions,
> I can 'return' the variable
> but that apparently would
not
> work for this function.
> 
> Is this type of function any
> different that that which I
> have been using?
> 
Please post a short example
that shows the problem.

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



More information about the Python-list mailing list