Sunday, February 7, 2021

Button Widget

buttons.py


 #!/usr/bin/env python3


from tkinter import *


root =Tk()


#button Function

def myClick():

    myLabel = Label(root, text="Look I clicked a Button!")

    myLabel.pack()


#disable a button

myButton1 = Button(root, text="Click Me!", state=DISABLED)

#make button bigger and add color to text(fg)/button(bg)

myButton2 = Button(root, text="Click Me!", padx=50, pady=50, fg='white', bg='black')

#button calls Function - MyClick

myButton3 = Button(root, text="Click Me!", command=myClick)


#put Buttons in Window-root

myButton1.pack()

myButton2.pack()

myButton3.pack()


root.mainloop( )

No comments:

Post a Comment