Respuesta :
Below is the code for the given question in which are working with interactive graphics that use mouse clicks rather than the console to get user input.
Coding Part:
from tkinter import *
from tkinter.filedialog
import askopenfilename from PIL import Image, ImageTk
import tkinter.simpledialog root = Tk()
#setting up a tkinter canvas
w = Canvas(root, width=1000, height=1000) w.pack()
#adding the image
File = askopenfilename(parent=root, initialdir="./",title='Select an image')
original = Image.open(File) original = original.resize((1000,1000)) #resize
image img = ImageTk.PhotoImage(original) w.create_image(0, 0,
image=img, anchor="nw")
#ask for the temperature and pressure extent
xmt = tkinter.simpledialog.askfloat("Temperature", "degrees in x-axis")
ymp = tkinter.simpledialog.askfloat("Pressure", "bars in y-axis")
#ask for real PT values at origin
xc = tkinter.simpledialog.askfloat("Temperatures", "Temperatures at origin") yc = tkinter.simpledialog.askfloat("Pressure", "Pressure at origin") #instruction on 3 point selection to define grid
tkinter.messagebox.showinfo("Instructions", "Click: \n" "1) Origin \n"
"2) Temperature end \n"
"3) Pressure end")
global x0,y0
x0 = eventorigin.x
y0 = eventorigin.y
print(x0,y0)
w.bind("<Button 1>",getextentx)
#mouseclick event w.bind("<Button 1>",getorigin)
# Determine the extent of the figure in the x direction (Temperature) def getextentx(eventextentx):
global xe
xe = eventextentx.x
print(xe)
w.bind("<Button 1>",getextenty)
global ye
ye = eventextenty.y
print(ye)
tkinter.messagebox.showinfo("Grid", "Grid is set. You can start picking coordinates.")
w.bind("<Button 1>",printcoords)
#Coordinate transformation into Pressure-Temperature space def printcoords(event):
xmpx = xe-x0
xm = xmt/xmpx
ympx = ye-y0
ym = -ymp/ympx
#coordinate transformation
newx = (event.x-x0)*(xm)+xc
newy = (event.y-y0)*(ym)+yc
To know more about interactive graphics, visit: https://brainly.com/question/18068928
#SPJ4
