Question: You are going to make a Graphical User Interface for the GeoPoint class you made in previous programs. 1 . The GUI should have a

You are going to make a Graphical User Interface for the GeoPoint class you made in previous programs.
1.The GUI should have a text box where the user can enter the name of a file that contains a list of points and descriptions.
2.The GUI should have three more textboxes where the user can enter their own coordinates and description.
3.There should be a label for each textbox to let the user know what should be entered into those textboxes.
4.The GUI should have a button the user can click.
5.When the user clicks the button, the program should create a point representing the user's location from coordinates and description in the textboxes, read the points from the file used in program 7, and finally display a message in another textbox (*Label") that says something like:You are closest to < description> which is located at point sx, y coordirates>
6.You can reuse program 9 as a library. The GeoPoint class should be fine as is.
7.You can take the functionality in the main part of the program 9 and place it in the Button click event handler and modify it as needed.
8.Alternatively, you can modify the functionality in the main part of the program 9 and turn it into functions in your library that you will call from the Button click event handler in your GUI.
Program 9:
import math
class GeoPoint:
def __init__(self, lat=0, lon=0 description='TBD'):
self.lat = lat
self.lon = lon
self.description = description
def GetPoint(self):
return self.lat, self.lon
def SetPoint(self, point):
self.lat, self.lon = point
def GetDescription(self):
return self.description
def SetDescription(self, description):
self.description = description
def calcDistance(self, point):
lat1= math.radians(self.lat)
lon1= math.radians (self.lon)
lat2= math.radians (point.lat)
lon2= math.radians (point.lon)
dlon = lon2- lon1
dlat = lat2- lat1
a = math.sin(dlat/2)**2+ math.cos(lat1)* math.cos(lat2)* math.sin(dlon/2)**2
c =2* math.atan2(math.sqrt(a), math. sqrt (1-a))
distance_km = R * c
return distance_km
def header():
print ("Distance Calulator ")
print ("C.")
print()
def get_ location():
latitude = float(input("Enter latitude(in decimal degrees): "))
longitude = float (input ("Enter longitude(in decimal degrees): "))
return {"latitude": latitude, "longitude": longitude}
def display_distance(Distance):
print("InThe distance is %.2f km."% Distance)
def do_another():
usr_response = input("
Do another (y/n)?")
another = usr_response.strip()[0].lower()=='y'
print()
return another
def display goodbye():
print(Thank you forDistance Calulator
Please come again!
)
def main():
header ()
while True:
point1= GeoPoint(12.3456)
point2= GeoPoint()
point2.point =(23.4567,-213.456)
point2 description -Loc2'
lat, lon = get location()
point_user = GeoPoint(lat, lon, 'User Location)
distance_ to_one = point1.calcDistance(point_user)
distance to_two = point2.calcDistance(point_user)
if distance_to_one distance_to_ two:
closest_point = point1
else:
closest_point = point2
display_distance(closest_point.calcDistance(point user))
print("You are closest to {) which is located at (}.".format(closest_point.GetDescription(), closest_point.GetPoint()))
if not do_another():
break
print ("Goodbye!")
if __name__==__main__:
main()

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!