1from tkinter import *
2#Creating a win
3win = Tk()
4#Giving a Function To The Button
5def btn1():
6 print("I Don't Know Your Name")
7#Creating The Button
8button1 = Button(win, text="Click Me To Print SomeThing", command=btn1)
9#put on screen
10button1.pack()
11win.mainloop()
12#NB:This programme Will Print Something In The Terminal
13#Check My Profile To See How We Print On The Screen Or Type In Google "Tkinter Label"
1from tkinter import *
2window = Tk()
3
4def got_clicked():
5 print("I got clicked!")
6
7my_button = Button(text="Click me", command=got_clicked)
8my_button.pack()
9
10window.mainloop()
1import tkinter as tk #We will use tkinter
2
3font = 'Helvetica' #This is the font that we will use
4
5def cmd(): #This is the command for our button
6 label = tk.Label(master,text="Hi to everyone",font=(font,16)) #We'll create
7 #a label
8 label.grid(row=1,column=0,sticky='w') #This is the 'grid'
9
10class main: #Our main class
11 def __init__(self,master):
12 master.title('Simple Interface') #The title of our interface
13 master.geometry('500x500+0+0') #Position and Size of master
14 button = tk.Button(master,text='Ok',command=cmd) #Creating the button
15 button.grid(row=0,column=0,sticky='w') #Grid of the button
16
17if __name__ == '__main__':
18 master = tk.Tk() #Now we're creating the window
19 main = main(master)
20 master.mainloop #Mainloop of master (the window)
1import tkinter
2button1 = ttk.Button(self, text="anything", command=random command)
3 button1.pack()
1import Tkinter
2import tkMessageBox
3
4top = Tkinter.Tk()
5
6def helloCallBack():
7 tkMessageBox.showinfo( "Hello Python", "Hello World")
8
9B = Tkinter.Button(top, text ="Hello", command = helloCallBack)
10
11B.pack()
12top.mainloop()