Re: RE: Problem resizing a window and button placement
On 25/02/2024 03:58, Steve GS via Python-list wrote:
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('', on_configure)
root.mainloop()
print("Ww Outside = <" + str(Ww) > + ">")
Produces:
Ww Inside = <200>
Ww Inside = <200>
Ww Inside = <205>
Ww Inside = <205>
Ww Inside = <206>
Ww Inside = <206>
Ww Outside = <206>
HTH
--
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
--
https://mail.python.org/mailman/listinfo/python-list
RE: RE: Problem resizing a window and button placement
SOLUTION FOUND!
The fix was to write the code that uses the width value and to place it into
the function itself.
Kluge? Maybe but it works.
Mischief Managed.
As for the most recent suggestion, it fails for me:
Traceback (most recent call last):
File "F:/___zInsulin Code A 08-02-23/WinPic/IOWw.pyw", line 14, in
print("Ww Outside = <" + str(Ww) > + ">")
TypeError: bad operand type for unary +: 'str'
With the need to close the window, it adds an extra step and intervention to
the program to use. I am not sure how this help[s.
As a curio, it would be interesting to see how to use the value of a variable,
created in the function used here, and make it available to the code outside
the function.
SGA
-Original Message-
From: Alan Gauld
Sent: Sunday, February 25, 2024 12:44 PM
To: Steve GS ; [email protected]
Subject: Re: RE: Problem resizing a window and button placement
On 25/02/2024 03:58, Steve GS via Python-list wrote:
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('', on_configure)
root.mainloop()
print("Ww Outside = <" + str(Ww) > + ">")
Produces:
Ww Inside = <200>
Ww Inside = <200>
Ww Inside = <205>
Ww Inside = <205>
Ww Inside = <206>
Ww Inside = <206>
Ww Outside = <206>
HTH
--
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
--
https://mail.python.org/mailman/listinfo/python-list
Re: Problem resizing a window and button placement
On 2/25/2024 4:19 PM, Steve GS via Python-list wrote:
SOLUTION FOUND!
The fix was to write the code that uses the width value and to place it into
the function itself.
Kluge? Maybe but it works.
Right, just what I wrote earlier:
"have the function that responds to the resize event perform the action
that you want"
Mischief Managed.
As for the most recent suggestion, it fails for me:
Traceback (most recent call last):
File "F:/___zInsulin Code A 08-02-23/WinPic/IOWw.pyw", line 14, in
print("Ww Outside = <" + str(Ww) > + ">")
TypeError: bad operand type for unary +: 'str'
With the need to close the window, it adds an extra step and intervention to
the program to use. I am not sure how this help[s.
As a curio, it would be interesting to see how to use the value of a variable,
created in the function used here, and make it available to the code outside
the function.
SGA
-Original Message-
From: Alan Gauld
Sent: Sunday, February 25, 2024 12:44 PM
To: Steve GS ; [email protected]
Subject: Re: RE: Problem resizing a window and button placement
On 25/02/2024 03:58, Steve GS via Python-list wrote:
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('', on_configure)
root.mainloop()
print("Ww Outside = <" + str(Ww) > + ">")
Produces:
Ww Inside = <200>
Ww Inside = <200>
Ww Inside = <205>
Ww Inside = <205>
Ww Inside = <206>
Ww Inside = <206>
Ww Outside = <206>
HTH
--
https://mail.python.org/mailman/listinfo/python-list
Re: Problem resizing a window and button placement
On 2024-02-25 21:19, Steve GS via Python-list wrote:
SOLUTION FOUND!
The fix was to write the code that uses the width value and to place it into
the function itself.
Kluge? Maybe but it works.
Mischief Managed.
As for the most recent suggestion, it fails for me:
Traceback (most recent call last):
File "F:/___zInsulin Code A 08-02-23/WinPic/IOWw.pyw", line 14, in
print("Ww Outside = <" + str(Ww) > + ">")
TypeError: bad operand type for unary +: 'str'
It fails because there's a mistake. It should be:
print("Ww Outside = <" + str(Ww) + ">")
With the need to close the window, it adds an extra step and intervention to
the program to use. I am not sure how this help[s.
As a curio, it would be interesting to see how to use the value of a variable,
created in the function used here, and make it available to the code outside
the function.
[snip]
--
https://mail.python.org/mailman/listinfo/python-list
