Welcome to Code Forum!

Join a community that supports you and your coding journey from day one. We strive to be a friendly, supportive community that empowers everyone to be better developers. By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Tutorials listed in this section have not been reviewed nor are affliated by Code Forum. It is the sole responsbility of the authour to properly maintain and ensure information is accurate.

Python Simple Tkinter Calculator Part 1 - Tkinter Window

In this tutorial we will get our tkinter window running and define our 2 classes


Python:
import tkinter as tk
from decimal import Decimal

class Window:
    def __init__(self, parent):
        self.parent = parent
        ''' We will be using the grid manager '''
        parent.columnconfigure(0, weight=1)
        parent.rowconfigure(0, weight=1)

        # Set a minimum size for our window
        parent.geometry('800x600+200+200')
        parent.resizable(False, False)
      
      
class Controller:
    ''' The Controller class will hand all button commands as well as calculations '''
    def __init__(self, window):
        self.window = window
      
      
if __name__ == '__main__':
    root = tk.Tk()
    root.title('Tkinter Calculator')
    controller = Controller(Window(root))
    root.mainloop()
 
Back
Top Bottom