how to add button in tkinter 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)


Here is what the above code is Doing:
1. We’re creating a button that says “Click me”
2. When the button is clicked, it will run the got_clicked function
3. We’re packing the button into the window
4. We’re running the mainloop function to make sure the window stays open

Similar Posts