파이썬
[두근두근파이썬] tkinter를 이용해 화씨 섭씨 구하기
아스키의 공부방
2020. 11. 21. 21:45
728x90
반응형
from tkinter import *
def process():
temp = float(e1.get())
mytemp = (temp-32)*5/9
e2.insert(0, str(mytemp))
e1.delete(0, 'end')
def rev_process():
temp = float(e2.get())
mytemp = (temp*9/5)+32
e1.insert(0, str(mytemp))
e2.delete(0, 'end')
window = Tk()
l1 = Label(window, text = "화씨")
l2 = Label(window, text = "섭씨")
l1.grid(row = 0, column = 0)
l2.grid(row = 1, column = 0)
e1 = Entry(window)
e2 = Entry(window)
e1.grid(row = 0, column = 1)
e2.grid(row = 1, column = 1)
b1 = Button(window, text = "화씨 -> 섭씨", command = process)
b2 = Button(window, text = "섭씨 -> 화씨", command = rev_process)
b1.grid(row = 2, column = 0)
b2.grid(row = 2, column = 1)
window.mainloop()
728x90
반응형