#import the right GUI libraries
from tkinter import *
from tkinter import ttk
#Function to convert pounds to euros
def convert():
try:
#get what the user typed in
value = float(pounds.get())
euros.set(value * 1.18)
#skip if they input something invalid
#Error cathching
except ValueError:
pass
#Tell them that something is wrong
print("Please provide a valid number. A letter or symbol is NOT a number.")
#main window
root = Tk()
#title of windows
root.title("Pounds to Euros")
#frame to make the window look better
frame = ttk.Frame(root, padding="3 3 12 12")
frame.grid(column=0, row=0, sticky=(N, W, E, S))
frame.columnconfigure(0, weight=1)
frame.rowconfigure(0, weight=1)
#variables for the input and output
pounds = StringVar()
euros = StringVar()
#input for how many pounds they want to convert
pounds_entry = ttk.Entry(frame, width=7, textvariable=pounds)
#make it all neat
pounds_entry.grid(column=2, row=1, sticky=(W, E))
#other widgets like the text you see and the convert button
ttk.Label(frame, textvariable=euros).grid(column=2, row=2, sticky=(W, E))
ttk.Button(frame, text="Convert", command=convert).grid(column=3, row=3, sticky=W)
ttk.Label(frame, text="pounds").grid(column=3, row=1, sticky=W)
ttk.Label(frame, text="is equivalent to").grid(column=1, row=2, sticky=E)
ttk.Label(frame, text="euros").grid(column=3, row=2, sticky=W)
#padding it all equally
for child in frame.winfo_children():
child.grid_configure(padx=5, pady=5)
#focuses the window automatically so we dont have to press on it
pounds_entry.focus()
#binds the enter key so you can press it to convert
root.bind('<Return>', convert)
#Continuously runs until you press the big red X
root.mainloop()