How do you insert a button in python | SoloLearn: Learn to code for FREE!

0

How do you insert a button in python

4/7/2021 7:11:54 PM

Katlego Malefetse

3 Answers

New Answer

+2

You need to use gui python library like tkinter, kviy, qython .

+11

from tkinter import * r = Tk() l = Label(r) l.grid() def showit(): l['text'] = "Hello World!" b = Button(r,text='press me', command=showit) b.grid() r.mainloop()

+1

from tkinter import * from tkinter import ttk def Click(): pass root = Tk() root.geometry('100x200') root.resizable(True, False) lbl = Label(root, text = "click the button", font = ("center", 12, "bold")) lbl.pack() Click_button = ttk.Button(root, text = "click", command = Click, width = 15) Click_button.pack(pady = 5) root.mainloop()