# -*- coding: utf-8 -*- import tkinter as tk root = tk.Tk() root.title("tk13.py") root.geometry("200x200") ##################################### def FtoC(event): f = float(eFahrenheit.get()) c = (f-32)*5/9 lbCentigrade.config(text = "攝氏{}C".format(c), relief = 'raised', height = 2, bg = 'pink', fg = 'blue',font = 'FrankRuehl 12 bold') lbFahrenheit = tk.Label(root, text = '請輸入華氏溫度\n(Fahrenheit)', font="標楷體") eFahrenheit = tk.Entry(root, bg = 'lightgreen', bd = 2, font = "Aharoni", width = 30) btConversion = tk.Button(root, text = 'Conversion') lbCentigrade = tk.Label(root, font="Times 18 bold") lbFahrenheit.pack() eFahrenheit.pack() btConversion.pack() lbCentigrade.pack() eFahrenheit.bind('',FtoC) btConversion.bind('<1>', FtoC) ##################################### root.mainloop()