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()
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()
create button tkinter
import tkinter as tk #We will use tkinter
font = 'Helvetica' #This is the font that we will use
def cmd(): #This is the command for our button
label = tk.Label(master,text="Hi to everyone",font=(font,16)) #We'll create
#a label
label.grid(row=1,column=0,sticky='w') #This is the 'grid'
class main: #Our main class
def __init__(self,master):
master.title('Simple Interface') #The title of our interface
master.geometry('500x500+0+0') #Position and Size of master
button = tk.Button(master,text='Ok',command=cmd) #Creating the button
button.grid(row=0,column=0,sticky='w') #Grid of the button
if __name__ == '__main__':
master = tk.Tk() #Now we're creating the window
main = main(master)
master.mainloop #Mainloop of master (the window)
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us