Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions examples/buttons/button-styled.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
from tkinter import Tk, Button #importing Tk and button from tkinter
from tkinter import ttk #importing ttk from tkinter that is used to style the tkinter widgets

'''initilaizing tkinter window'''
root=Tk()

'''Adding Normal Button '''
btn1 = Button(root, text = 'Normal Button')
btn1.pack(pady=20) #pady means padding along y axis
Comment on lines +7 to +9
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comments like this are not useful and should be deleted. In fact, there is only one useful comment in this file. The code is clearly creating a button, and it is easy to google tkinter pady. If there is too much comments, nobody will read them.


'''#Adding Styled Button'''
style=ttk.Style() #importing Style class from Ttk
style.configure('TButton', font =('@Adobe Kaiti Std R', 10, 'italic', ),foreground="black",background="Green", )#configuring styles in Button

#adding the made style in Button
btn2=ttk.Button(root, text="Styled Button",style ='TButton')
btn2.pack(pady=20)

'''Notice
style option inside styled button comes only with ttk not with the normal Tk button
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the only useful comment in the file. It should be shortened though, e.g. # ttk.Button has style option but tkinter.Button doesn't


'''
root.mainloop()