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 *
2
3wow = Tk()
4
5def ree(hi):
6 print(hi)
7
8w = Button ( master=wow, command=ree('hi'), text="hi" )
9
10Output:
11 Tkinter:
12 ______
13 [ hi ] <--- Button
14 ------
15
16 Shell:
17 hi <--- on button pressed
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()