Hope you are all doing well.
Right now, I created a Tkinter Canvas which displays a resizeable circle object. What I need to do is to print the following parameters on canvas:
Window location (according to the screen of the computer, should be Left and Top)
Center Point of the circle image (according to the window X, Y)
Width and Heigth of the circle image
Here is my code:
from tkinter import *
from PIL import ImageTk, Image
def locator():
root = Tk()
root.geometry("300x300")
root.overrideredirect()
bg = ImageTk.PhotoImage(file="Golden-circle (1).png")
root.attributes('-alpha', 0.25)
my_canvas = Canvas(root, width=300, height=300)
my_canvas.pack(fill="both", expand=True)
my_canvas.create_image(350,350, image=bg, anchor="nw",tags="circle")
#Draw an Oval in the canvas
def resizer(e):
global bg1, resized_bg, new_bg
# Open our image
bg1 = Image.open("Golden-circle (1).png")
# Resize the image
resized_bg = bg1.resize((e.width, e.width), Image.ANTIALIAS)
#resized_bg = bg1.resize((e.height, e.height), Image.ANTIALIAS) if e.height < e.width else bg1.resize((e.width, e.width), Image.ANTIALIAS)
# Define our image again
new_bg = ImageTk.PhotoImage(resized_bg)
# Add it back to the canvas
my_canvas.create_image(0,0, image=new_bg, anchor="nw")
root.bind('<Configure>', resizer)
root.mainloop()
locator()
What I should need to do in order to retrieve/print those parameters?