#!/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, 21, 19, 35), 'tkinter.Entry', 'tk.Entry', ({(19, 30, 19, 34): 'self'}, {}), '(self)', True, 'import tkinter as tk\n'), ((20, 23, 20, 37), 'tkinter.Entry', 'tk.Entry', ({(20, 32, 20, 36): 'self'}, {}), '(self)', True, 'import tkinter as tk\n'), ((21, 19, 21, 33), 'tkinter.Label', 'tk.Label', ({(21, 28, 21, 32): 'self'}, {}), '(self)', True, 'import tkinter as tk\n'), ((42, 23, 42, 30), 'tkinter.Tk', 'tk.Tk', ({}, {}), '()', True, 'import tkinter as tk\n'), ((27, 8, 27, 36), 'tkinter.Label', 'tk.Label', (), '', True, 'import tkinter as tk\n'), ((30, 8, 30, 38), 'tkinter.Label', 'tk.Label', (), '', True, 'import tkinter as tk\n'), ((33, 8, 33, 34), 'tkinter.Label', 'tk.Label', (), '', True, 'import tkinter as tk\n'), ((35, 8, 35, 67), 'tkinter.Button', 'tk.Button', (), '', True, 'import tkinter as tk\n'), ((36, 8, 36, 63), 'tkinter.Button', 'tk.Button', (), '', True, 'import tkinter as tk\n')]