add button in tkinter code example

Example 1: 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 2: add a button on tkinter

import tkinter
button1 = ttk.Button(self, text="anything", command=random command)
        button1.pack()

Example 3: add button python

from tkinter import *


master = Tk()

#program you want the button to execute
def closewindow():
    exit()

#set up button
button = Button(master, text="close window", command=closewindow)

button.pack()

mainloop()