boilerplate for tkinter code example

Example 1: tkinter boiler plate

# A simple object oriented tkinter window
import tkinter as tk
from tkinter import ttk
 
# -- Windows only configuration --
try:
    from ctypes import windll
    windll.shcore.SetProcessDpiAwareness(1)
except:
    pass
    
    
class HelloWorld(tk.Tk):
    def __init__(self):
        super().__init__()

        self.geometry("640x200")
        self.title("Title Here")

        label = ttk.Label(self, text="Tkinet window")
        label.config(font=("Comic Sans MS",40))
        label.pack()

root = HelloWorld()
 
root.mainloop()

Example 2: tkinter boiler plate

# A simple tkinter window
import tkinter as tk
from tkinter import ttk

# -- Windows only configuration --
try:
    from ctypes import windll
    windll.shcore.SetProcessDpiAwareness(1)
except:
    pass
# -- End Windows only configuration --


root = tk.Tk()
root.geometry("640x200")
root.title("Title Here")

label = ttk.Label(root, padding=10, text="Tkinter Window")
label.config(font=("Comic Sans MS",40))
label.pack()

root.mainloop()