tkinter boilerplate code code example
Example 1: tkinter boiler plate
import tkinter as tk
from tkinter import ttk
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
import tkinter as tk
from tkinter import ttk
try:
from ctypes import windll
windll.shcore.SetProcessDpiAwareness(1)
except:
pass
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()
Example 3: tkinter boilerplate
import tkinter
window = tkinter.Tk()
window.title('my first GUI program')
window.mainloop()