font1=To one of the option we can assign the font style like this. def my_upd(col): if col='white': nfigure('Treeview',background="white", fieldbackground="white", foreground="black") elif col='yellow': nfigure('Treeview',background="yellow", fieldbackground="yellow", foreground="black") else: nfigure('Treeview',background="black", fieldbackground="black", foreground="white")We can include the font style also. r1 = tk.Radiobutton(my_w, text='Black', variable=r1_v, value='black', command=lambda:my_upd('black'))Inside the function my_upd() we will check the parameter value and accordingly update the style. On click of the radio button we will trigger the function my_upd(col) and we passed colour as parameter. We used on StringVar() with default value as 'black'. nfigure('Treeview', rowheight=100) Managing style using Radio buttonsUsing three RadioButtons we will configure the style of Treeview. style = ttk.Style(my_w) style.theme_use("clam") # set theam to nfigure("Treeview", background="black", fieldbackground="black", foreground="white")nfigure('Treeview.Heading', background="PowderBlue")The last line in above code adds different background color to headings. Assigning default style for TreeviewThis is applied to all Treeview widgets.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |