Question: The following code is the solution. from tkinter import * # Import tkinter width = 220 height = 100 class MainGUI: def __init__(self): window =

 The following code is the solution. from tkinter import * #

The following code is the solution.

from tkinter import * # Import tkinter width = 220 height = 100 class MainGUI: def __init__(self): window = Tk() # Create a window window.title("Mouse Position") # Set a title self.canvas = Canvas(window, bg = "white", width = width, height = height) self.canvas.pack() # Bind canvas with mouse events self.canvas.bind("", self.displayPosition) window.mainloop() # Create an event loop def displayPosition(self, event): self.canvas.delete("text") self.canvas.create_text(event.x, event.y - 4, text = "(" + str(event.x) + ", " + str(event.y) + ")", tags = "text") MainGUI() 

Now also consider the following Exercise:

Import tkinter width = 220 height = 100 class MainGUI: def __init__(self):

And the following code as its solution.

from tkinter import * # Import tkinter width = 240 height = 120 class MainGUI: def __init__(self): window = Tk() # Create a window window.title("Inside the circle?") # Set a title self.canvas = Canvas(window, bg = "white", width = width, height = height) self.canvas.pack() self.canvas.create_oval(100 - 50, 60 - 50, 100 + 50, 60 + 50, tags = "circle") self.canvas.bind("", self.isInside) window.mainloop() # Create an event loop def isInside(self, event): self.canvas.delete("text") if isInsideCircle(100, 60, 50, event.x, event.y): self.canvas.create_text(event.x, event.y - 5, text = "Mouse pointer is in the circle", tags = "text") else: self.canvas.create_text(event.x, event.y - 5, text = "Mouse pointer is not in the circle", tags = "text") def isInsideCircle(xCenter, yCenter, radius, x, y): return distance(xCenter, yCenter, x, y)  

Modify the code so it looks and behaves as follows:

window = Tk() # Create a window window.title("Mouse Position") # Set a

Add your name as a comment in the program and attach it below.

Python Please

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!