gui python tkinter code example
Example 1: basic tkinter gui
import tkinter as tk
root = tk.Tk()
root.title("my title")
root.geometry('200x150')
root.configure(background='black')
root.mainloop()
Example 2: python gui
import tkinter as tk
window = tk.Tk()
window.mainloop()
Example 3: gui in tkinter
from tkinter import *
import os
window = Tk()
window.geometry("450x450")
window.title("Gui App")
window.configure(bg="powder blue")
filename = Entry(window, width=75)
filename.pack()
def runFile():
try:
os.startfile(filename.get())
except:
error = Label(window, text=f"No file found as {filename.get}")
error.pack()
open_file_button = Button(window, text="Run File", command=runFile)
open_file_button.pack()
window.mainloop()
Example 4: how to create tkinter window
import tkinter
master = tkinter.Tk()
master.mainloop()