Do you want to know the information regarding “how to make a button in python”. If yes, you’re in the correct article.
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
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()
import tkinter button1 = ttk.Button(self, text="anything", command=random command) button1.pack()
I hope this article helps you to know about “how to make a button in python”. If you have any doubts regarding this tutorial please let us know via the comment section. Share this tutorial with your friends and family via social networks.