#!/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()

[((448, 462), 'tkinter.Entry', 'tk.Entry', (['self'], {}), '(self)\n', (456, 462), True, 'import tkinter as tk\n'), ((488, 502), 'tkinter.Entry', 'tk.Entry', (['self'], {}), '(self)\n', (496, 502), True, 'import tkinter as tk\n'), ((524, 538), 'tkinter.Label', 'tk.Label', (['self'], {}), '(self)\n', (532, 538), True, 'import tkinter as tk\n'), ((1220, 1227), 'tkinter.Tk', 'tk.Tk', ([], {}), '()\n', (1225, 1227), True, 'import tkinter as tk\n'), ((657, 685), 'tkinter.Label', 'tk.Label', (['self'], {'text': '"""Miles"""'}), "(self, text='Miles')\n", (665, 685), True, 'import tkinter as tk\n'), ((753, 783), 'tkinter.Label', 'tk.Label', (['self'], {'text': '"""Gallons"""'}), "(self, text='Gallons')\n", (761, 783), True, 'import tkinter as tk\n'), ((847, 873), 'tkinter.Label', 'tk.Label', (['self'], {'text': '"""MPG"""'}), "(self, text='MPG')\n", (855, 873), True, 'import tkinter as tk\n'), ((915, 972), 'tkinter.Button', 'tk.Button', (['self'], {'text': '"""Calculate"""', 'command': 'self.calculate'}), "(self, text='Calculate', command=self.calculate)\n", (924, 972), True, 'import tkinter as tk\n'), ((1006, 1061), 'tkinter.Button', 'tk.Button', (['self'], {'text': '"""Quit"""', 'command': 'self.root.destroy'}), "(self, text='Quit', command=self.root.destroy)\n", (1015, 1061), True, 'import tkinter as tk\n')]