Created
October 12, 2016 14:50
-
-
Save wolfospealain/41d79b84f6f00ebb9e879410ca9c230d to your computer and use it in GitHub Desktop.
Convert Fahrenheit to Celsius (tkinter GUI)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
# Converts Fahrenheit to Celsius | |
import tkinter | |
def convert_to_celsius(): | |
fahrenheit = float(input_box.get()) | |
celsius = (fahrenheit-32)*5/9 | |
output_label.config(text=round(celsius, 2)) | |
window = tkinter.Tk() | |
window.title("C to F Converter") | |
window.minsize(width=250, height=50) | |
input_box = tkinter.Entry(justify=tkinter.RIGHT) | |
output_label = tkinter.Label(text="", justify=tkinter.RIGHT, width=8) | |
action_button = tkinter.Button(text='Convert', command=convert_to_celsius) | |
input_box.pack(padx=20, pady=20) | |
output_label.pack(padx=20, pady=20, side=tkinter.RIGHT) | |
action_button.pack(padx=20, pady=20) | |
window.mainloop() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment