1from tkinter import *
2
3
4# def click func
5def click():
6 # Getting the text info as an int() & Error handling
7 try:
8 text_info_1 = float(text1.get())
9 text_info_2 = float(text2.get())
10 except Exception as e:
11 text1.delete(0, END)
12 text2.delete(0, END)
13 text3.delete(0, END)
14 text3.insert(0, f'Error: {e}')
15 return
16 # actual part of the func
17 text3.delete(0, END)
18 text3.insert(0, text_info_1 + text_info_2)
19
20# Gui Config
21root = Tk()
22root.geometry('300x400')
23root.title('Poop')
24
25# The actual gui
26label1 = Label(root, text='Write something!')
27label1.pack()
28
29spacing1 = Label(root)
30spacing1.pack()
31
32text1 = Entry(root)
33text1.pack(ipadx=20)
34
35spacing2 = Label(root, text='+')
36spacing2.pack()
37
38text2 = Entry(root)
39text2.pack(ipadx=20)
40
41spacing3 = Label(root)
42spacing3.pack()
43
44button = Button(root, text='Click me!', command=click)
45button.pack()
46
47spacing4 = Label(root)
48spacing4.pack()
49
50text3 = Entry(root)
51text3.pack(ipadx=60)
52
53# Making the gui run
54root.mainloop()
55
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()
1# App python gui
2
3import tkinter as tk
4import webbrowser as wb
5
6
7def Facebook():
8 wb.open('facebook.com')
9
10
11def Instagram():
12 wb.open('instagram.com')
13
14
15def Twitter():
16 wb.open('twitter.com')
17
18
19def Youtube():
20 wb.open('youtube.com')
21
22
23def Google():
24 wb.open('google.com')
25
26
27window = tk.Tk()
28window.title('Browser')
29
30google = tk.Button(window, text='Google', command=Google)
31youtube = tk.Button(window, text='Youtube', bg='red', fg='white', command=Youtube)
32twitter = tk.Button(window, text='Twitter', bg='powder blue', fg='white', command=Twitter)
33Instagram = tk.Button(window, text='Instagram', bg='white', fg='black', command=Instagram)
34facebook = tk.Button(window, text='Facebook', bg='blue', fg='white', command=Facebook)
35facebook.pack()
36Instagram.pack()
37twitter.pack()
38youtube.pack()
39google.pack()
40
41window.mainloop()
1import tkinter as tk
2#Importing the main module
3window = tk.Tk()
4window.mainloop()