import tkinter as tk root = tk.Tk() root.title("My Application") root.mainloop()
import tkinter as tk class Application: def __init__(self, master): self.master = master self.master.title("My Application") self.master.geometry("300x300") self.label = tk.Label(self.master, text="Hello, World!") self.label.pack() root = tk.Tk() app = Application(root) root.mainloop()In the above example code, we create a `class` named `Application` and pass `master` as an argument in the `__init__` method. `master` is nothing but the `Tk()` instance. We set the title and geometry of the window. A `Label` widget is created and packed into the window. Finally, the instance of the `Application` class is created and put into the main loop by calling the `mainloop` method. Package Library: tkinter.