From e874bff7117bdd29823b91460f07b72894ebf86f Mon Sep 17 00:00:00 2001 From: Shikhar9425 <72194627+Shikhar9425@users.noreply.github.com> Date: Mon, 3 Jul 2023 10:35:32 +0530 Subject: [PATCH 1/2] Added Temperature convertor GUI python script --- Added Temperature convertor GUI python script | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 Added Temperature convertor GUI python script diff --git a/Added Temperature convertor GUI python script b/Added Temperature convertor GUI python script new file mode 100644 index 0000000000..70ca96c65d --- /dev/null +++ b/Added Temperature convertor GUI python script @@ -0,0 +1,41 @@ +import tkinter as tk + +def convert_temperature(): + try: + temperature = float(entry.get()) + if var.get() == 0: # Celsius to Fahrenheit + result = temperature * 9/5 + 32 + output_label.configure(text=f"{temperature}°C = {result}°F") + elif var.get() == 1: # Fahrenheit to Celsius + result = (temperature - 32) * 5/9 + output_label.configure(text=f"{temperature}°F = {result}°C") + except ValueError: + output_label.configure(text="Invalid input") + +# Create the main window +window = tk.Tk() +window.title("Temperature Converter") + +# Create input label and entry widget +input_label = tk.Label(window, text="Enter temperature:") +input_label.pack() +entry = tk.Entry(window) +entry.pack() + +# Create radio buttons for temperature conversion options +var = tk.IntVar() +celsius_to_fahrenheit = tk.Radiobutton(window, text="Celsius to Fahrenheit", variable=var, value=0) +celsius_to_fahrenheit.pack() +fahrenheit_to_celsius = tk.Radiobutton(window, text="Fahrenheit to Celsius", variable=var, value=1) +fahrenheit_to_celsius.pack() + +# Create convert button +convert_button = tk.Button(window, text="Convert", command=convert_temperature) +convert_button.pack() + +# Create output label for displaying result +output_label = tk.Label(window) +output_label.pack() + +# Run the main event loop +window.mainloop() From 8c30d52d1f8ec3af83783b41ff3b3af0ac468a1c Mon Sep 17 00:00:00 2001 From: Shikhar9425 <72194627+Shikhar9425@users.noreply.github.com> Date: Thu, 6 Jul 2023 17:07:19 +0530 Subject: [PATCH 2/2] Rename Added Temperature convertor GUI python script to Added_temperature_convertor_GUI_python_script.py --- ...hon script => Added_temperature_convertor_GUI_python_script.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename Added Temperature convertor GUI python script => Added_temperature_convertor_GUI_python_script.py (100%) diff --git a/Added Temperature convertor GUI python script b/Added_temperature_convertor_GUI_python_script.py similarity index 100% rename from Added Temperature convertor GUI python script rename to Added_temperature_convertor_GUI_python_script.py