1from tkinter import * #import
2
3def main():
4 screen = Tk()#initialize
5 screen.geomerty("num1xnum2") #pixels
6 screen.title("Title")
7 screen.cofigure(bg = 'grey')#hex colors or normal colors
8
9 screen.mainloop()
10main()#call
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()
1Make your event handler a lambda function, which calls your command() - in this case get_dir()
2- with whatever arguments you want:
3
4xbBrowse = Button(frameN, text="Browse...", font=fontReg, command=lambda : self.get_dir(xbPath))
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
3obj = tk.Tk() # Creates a tkinter object
4label = tk.Label(obj, text="This is a text button")
1import tkinter as tk #import the tkinter module as tk
2
3core = tk.Tk() #makes the core (or root)
4mylabel = tk.Label(core, text="Hello world!") #makes a label
5mylabel.grid(row=0, column=1) #places the object in a virtual grid
6
7tk.Pack() #Pack the object(s)
8core.mainloop()#Make the application a loop (needed)