-
Notifications
You must be signed in to change notification settings - Fork 0
/
FCFAc2
36 lines (28 loc) · 995 Bytes
/
FCFAc2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import tkinter as tk
def eur_to_fcfa(amount_eur):
exchange_rate = 655.957
amount_fcfa = amount_eur * exchange_rate
return amount_fcfa
def convert():
try:
amount_eur = float(entry.get())
amount_fcfa = eur_to_fcfa(amount_eur)
result_label.config(text=f"{amount_eur:.2f} EUR is equal to {amount_fcfa:.2f} FCFA")
except ValueError:
result_label.config(text="Please enter a valid number")
# Create the main window
root = tk.Tk()
root.title("Currency Converter")
# Create input label and entry
input_label = tk.Label(root, text="Enter amount in EUR:")
input_label.grid(row=0, column=0)
entry = tk.Entry(root)
entry.grid(row=0, column=1)
# Create convert button
convert_button = tk.Button(root, text="Convert", command=convert)
convert_button.grid(row=1, column=0, columnspan=2)
# Create label for displaying result
result_label = tk.Label(root, text="")
result_label.grid(row=2, column=0, columnspan=2)
# Run the application
root.mainloop()