i am newish to python specifically in Tkinter and i want to make a script that opens up a window where you can enter a value that opens up a subwindow with a picture as background and a rectangle of specific format is drwan on the image.
I did do already some coding but its not comming out like i want it to. Iwant the script to import a picture in the window, as first part of the question. I also want it to take my entry-widget values and display them on the sub-window. I can do it with absolut values but if i let the user but in the values i dont get them to transver and draw a rectangle, like if i give the function absolut values or preset variables.
from tkinter import *
import tkinter as tk
from tkinter import ttk
from tkinter import filedialog as fd
def ROI(startx=50):
ROI_check=Toplevel(root)
ROI_check.title('ROI Peek')
ROI_check.geometry('800x500')
ROI_check.resizable(width=False,height=False)
canvas = tk.Canvas(ROI_check,width=800,height=500)
# canvas.grid()
ROI_image= ImageTk.PhotoImage(Image.open('af.tif')) #create background of this picture (some arbitrary image)
canvas.create_image(10,10,anchor= NW,image=ROI_image)
canvas.create_rectangle(startx,startx*2, startx*2, startx*3, outline='red') # create rectangle from entry-values
canvas.grid()
def Get_entry():
startx= startx_entry.get()
startx_var.set(startx)
return startx_var
def ROI_peek(start=50):
Get_entry()
ROI(start)
root = tk.Tk()
root.title("GoDS-Tool")
root.geometry('1300x550')
root.minsize(width=1300,height=500)
startx_entry=StringVar()
startx_var=StringVar()
startx_entry = ttk.Entry(root)
startx_entry.grid(column=1, row=1, sticky=tk.W, padx=5, pady=5)
button_peek = ttk.Button(root, text='Peek',command=ROI_peek)
button_peek.grid(column=2, row=1, padx=10)
root.mainloop()