title: Selecting an area of an image with a mouse and recording the dimensions of the selection
body: <p>I want to be able to drag rectangular selection with a mouse cursor over the image displayed in my program and to read the dimensions of the selection, so that I could use them to crop that image later. How do I do it in Python 3?</p>
  
  <p>UPD:</p>
  
  <p>Suppose I am doing it this way:</p>
  
  <pre><code>import tkinter as tk
  from PIL import ImageTk, Image
  
  #This creates the main window of an application
  window = tk.Tk()
  window.title("Join")
  window.geometry("900x900")
  window.configure(background='grey')
  
  path = "Book.jpg"
  
  #Creates a Tkinter-compatible photo image, which can be used everywhere Tkinter expects an image object.
  img = ImageTk.PhotoImage(Image.open(path))
  
  #The Label widget is a standard Tkinter widget used to display a text or image on the screen.
  panel = tk.Label(window, image = img)
  
  #The Pack geometry manager packs widgets in rows or columns.
  panel.pack(side = "bottom", fill = "both", expand = "yes")
  
  #Start the GUI
  window.mainloop()
  </code></pre>