Answers for "how to make a button in python tk"

1

how to make a button in python

from tkinter import *  # Importing gui module
def button_function():  # The function that the button will run
	print("Text")
screen = Tk()  # Creating a screen
button_quit = Button(screen, text="Quit", command=lambda:quit)  # Creating a button
button_quit.pack()  # Putting the button on the screen
button2 = Button(screen, text="BUTTON TEXT", command=lambda:button_function())  # Creating another button
button2.pack()  # Putting that button on the screen
screen.mainloop  # Opening the screen
Posted by: Guest on December-19-2021
0

make button in tk

from tkinter import*
Window = Tk()
def YourCommand():
  print ("Button Clicked")
button = Button(Window, text="Click Me", command=YourCommand)
Posted by: Guest on October-27-2021

Python Answers by Framework

Browse Popular Code Answers by Language