![]() Use the Style.element_options() method to get the element options of an element. ![]() Use the Style.layout() method to retrieve the layout of a widget class. ![]() The layout determines how elements assembled the widget. nfigure( 'Error.TLabel', padding=( 10, 10))Īpp.mainloop() Code language: Python ( python ) Summary nfigure( 'Error.TLabel', font=( 'Helvetica', 12)) nfigure( 'Error.TLabel', background= 'red') ![]() nfigure( 'Error.TLabel', foreground= 'white') Label = ttk.Label(self, text=message, style= 'Error.TLabel') The following shows how to change the appearance of a Label widget: import tkinter as tk SystemButtonFace Code language: Python ( python )Īs you can see clearly from the output, the font is TkDefaultFont, the foreground is SystemWindowText, and the background is SystemButtonFace. Print(style.lookup( 'Label.label', 'background')) Print(style.lookup( 'Label.label', 'foreground')) Print(style.lookup( 'Label.label', 'font')) # attributes of the font, foreground, and background # of the Label.label element The following example shows the attributes of the font, foreground, and background options in the TLabel.label element: import tkinter as tk To get a list of attributes associated with an element option, you use the lookup() method of the Style object: style.lookup(layout_name, option_name) Code language: Python ( python )
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |