In this TKinter Tutorial we are going to learn creating TKinter Window Class, before this we have learned that how you can create window in tkinter, in this lesson we are going to use Object Oriented Programming for creating window.
OK now this is the complete code for this lesson.
import tkinter as tk
self.title("Tkinter OOP Window")
window = Window()
In the above code we have created main class for our Window, this class extends from tkinter.Tk.
“__init__” is a reserved method in python classes. It is called as a constructor in object oriented programming. This method is called when an object is created from a class and it allows the class to initialize the attributes of the class.
The super() function is used to give access to methods and properties of a parent class. And the super() function makes class inheritance more manageable.
The word ‘self’ is used to represent the instance of the class. By using the “self” keyword we can access the attributes and methods of the class in python.
Run the complete code and this is the result.