#!/usr/bin/env python

# Some helpful links
# https://docs.python.org/3/library/tkinter.html
# https://www.python-course.eu/tkinter_entry_widgets.php

import tkinter as tk

class Application(tk.Frame):
    
    def __init__(self, root=None):
        super().__init__(root)
        self.root = root

        self.root.title("Mileage")
        self.root.geometry("250x125")        
        self.pack()
        
        self.miles = tk.Entry(self);
        self.gallons = tk.Entry(self);
        self.mpg = tk.Label(self)
        
        self.init_widgets()       

    def init_widgets(self):
        self.miles.grid(row=0)
        tk.Label(self, text="Miles").grid(row=0, column=1)

        self.gallons.grid(row=1)
        tk.Label(self, text="Gallons").grid(row=1, column=1)

        self.mpg.grid(row=2)
        tk.Label(self, text="MPG").grid(row=2, column=1)
        
        tk.Button(self, text="Calculate", command = self.calculate).grid(row=3, column=1)
        tk.Button(self, text="Quit", command=self.root.destroy).grid(row=4, column=1)

    def calculate(self):
        self.mpg['text'] = float(self.miles.get()) / float(self.gallons.get())


app = Application(root=tk.Tk())
app.mainloop()

[(19, 'tkinter.Entry', 'tk.Entry', (['self'], {}), True, 'import tkinter as tk\n'), (20, 'tkinter.Entry', 'tk.Entry', (['self'], {}), True, 'import tkinter as tk\n'), (21, 'tkinter.Label', 'tk.Label', (['self'], {}), True, 'import tkinter as tk\n'), (42, 'tkinter.Tk', 'tk.Tk', ([], {}), True, 'import tkinter as tk\n'), (27, 'tkinter.Label', 'tk.Label', (['self'], {'text': '"""Miles"""'}), True, 'import tkinter as tk\n'), (30, 'tkinter.Label', 'tk.Label', (['self'], {'text': '"""Gallons"""'}), True, 'import tkinter as tk\n'), (33, 'tkinter.Label', 'tk.Label', (['self'], {'text': '"""MPG"""'}), True, 'import tkinter as tk\n'), (35, 'tkinter.Button', 'tk.Button', (['self'], {'text': '"""Calculate"""', 'command': 'self.calculate'}), True, 'import tkinter as tk\n'), (36, 'tkinter.Button', 'tk.Button', (['self'], {'text': '"""Quit"""', 'command': 'self.root.destroy'}), True, 'import tkinter as tk\n')]