making a button in tkinter code example
Example 1: Function to a button in tkinter
from tkinter import *
win = Tk()
def btn1():
print("I Don't Know Your Name")
button1 = Button(win, text="Click Me To Print SomeThing", command=btn1)
button1.pack()
win.mainloop()
Example 2: how to add button in tkinter
from tkinter import *
window = Tk()
def got_clicked():
print("I got clicked!")
my_button = Button(text="Click me", command=got_clicked)
my_button.pack()
window.mainloop()
Example 3: how to create a button python
import Tkinter
import tkMessageBox
top = Tkinter.Tk()
def helloCallBack():
tkMessageBox.showinfo( "Hello Python", "Hello World")
B = Tkinter.Button(top, text ="Hello", command = helloCallBack)
B.pack()
top.mainloop()
Example 4: add button python
from tkinter import *
master = Tk()
def closewindow():
exit()
button = Button(master, text="close window", command=closewindow)
button.pack()
mainloop()