Tkinter Designer

← All templates

Temperature converter template for tkinter

Open this design in the browser-based designer, rearrange it, and download the Python. Nothing to install, and you don't need an account to try it.

Open in designer →

What this template shows you

  • Converting Entry text to a number safely with try/except
  • Showing results by updating a Label with .configure(text=…)
  • A complete tiny app in three widgets

The Python it generates

This is the actual main.py you get when you download it: standard-library tkinter, no framework, yours to edit:

import tkinter as tk
from tkinter import ttk


class Application:
    def __init__(self, root):
        self.root = root
        root.title("Temperature converter")
        root.geometry("340x200")

        self.label1 = tk.Label(root, text="Celsius")
        self.label1.place(x=30, y=34, width=90, height=26)

        self.entry1 = tk.Entry(root)
        self.entry1.place(x=130, y=32, width=170, height=28)

        self.button1 = tk.Button(root, text="Convert", command=self.on_button1)
        self.button1.place(x=130, y=80, width=110, height=34)

        self.label2 = tk.Label(root, text="")
        self.label2.place(x=30, y=134, width=270, height=26)

    def on_button1(self):
        try:
            celsius = float(self.entry1.get())
        except ValueError:
            self.label2.configure(text="Type a number first.")
            return
        fahrenheit = celsius * 9 / 5 + 32
        self.label2.configure(text=f"{celsius:g} °C = {fahrenheit:g} °F")


if __name__ == "__main__":
    root = tk.Tk()
    app = Application(root)
    root.mainloop()

Save it and run it the usual way:

python main.py

Make it your own. Edit the layout visually, then download the code.

Open the temperature converter template →

Other templates

  • Login form: Username + password entries with a working submit handler.
  • Calculator: Display plus a 4×4 keypad with working press/clear/equals code.
  • To-do list: Entry, listbox, and add/remove buttons, all wired up.
  • Quiz app: Multiple-choice question with radiobuttons and answer checking.