Problem resizing a window and button placement
Steve GS
Gronicus at SGA.Ninja
Sat Feb 24 22:53:40 EST 2024
The print statement in the
function prints.
Does that not mean that the
function is being called?
SGA
-----Original Message-----
From: Python-list
<python-list-bounces+gronicus=
sga.ninja at python.org> On
Behalf Of Thomas Passin via
Python-list
Sent: Saturday, February 24,
2024 10:39 PM
To: python-list at python.org
Subject: Re: Problem resizing
a window and button placement
On 2/24/2024 9:51 PM, Steve GS
via Python-list wrote:
First of all, please make sure
that the formatting is
readable and especially the
indentation. This is Python,
after all.
Do not use tabs; use 3 or 4
spaces instead of each tab.
> 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
The function that declares Ww
hasn't run yet. As I wrote
earlier, the function bound to
the callback should do all the
work for the callback, or it
should call other functions
that do. That's if you don't
let a layout do it all for
you, as others have written.
> 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