1# check this code first.
2from tkinter import *
3
4app = Tk()
5# The title of the project
6app.title("The title of the project")
7# The size of the window
8app.geometry("400x400")
9
10# Defining a funtion
11def c():
12 # Label
13 m = Label(app, text="Text")
14 m.pack()
15
16
17# Button
18l = Button(app, text="The text of the Butoon", command=c)
19# Packing the Button
20l.pack()
21app.mainloop()
22# Quick Note :
23# When you put a command you should not use parentheses
24# l = Button(app, text="The text of the Butoon", command=c)
25# l = Button(app, text="The text of the Butoon", command=c())
1import tkinter as tk
2root = tk.Tk()
3root.title("my title")
4root.geometry('200x150')
5root.configure(background='black')
6
7# enter widgets here
8
9root.mainloop()
1import tkinter as tk
2#Importing the main module
3window = tk.Tk()
4window.mainloop()
1from tkinter import *
2import os
3
4# window
5window = Tk()
6window.geometry("450x450")
7window.title("Gui App")
8window.configure(bg="powder blue")
9
10# Enter or user input in tkinter
11filename = Entry(window, width=75)
12filename.pack()
13
14# Run file Function
15
16def runFile():
17 try:
18 os.startfile(filename.get())
19
20 except:
21 error = Label(window, text=f"No file found as {filename.get}")
22 error.pack()
23
24 # Run file button
25open_file_button = Button(window, text="Run File", command=runFile)
26open_file_button.pack()
27
28window.mainloop()
29