![]() Note: To generate the above picture, you should add/change the aforementioned lines of code in the example Treeview: Basic example. The result is a treeview with modified fonts on both the body and headings, no border and different colors for the rows: ![]() ![]() Then, for instance, a background color can be associated to the tags: tree.tag_configure('odd', background='#E8E8E8') If you would like to have a different format depending on the rows, you can make use of tags: tree.insert(folder1, "end", "", text="photo1.png", values=("23-Jun-17 11:28","PNG file","2.6 KB"),tags = ('odd',)) Then, the widget is created giving the above style: tree=ttk.Treeview(master,style="mystyle.Treeview") Style.layout("mystyle.Treeview", ) # Remove the borders The former method using Tk 8.5 provides additional benefits including anti-aliased font rendering under X11 and window transparency (requiring a. If Python has not been compiled against Tk 8.5, this module can still be accessed if Tile has been installed. nfigure("", font=('Calibri', 13,'bold')) # Modify the font of the headings The tkinter.ttk module provides access to the Tk themed widget set, introduced in Tk 8.5. nfigure("mystyle.Treeview", highlightthickness=0, bd=0, font=('Calibri', 11)) # Modify the font of the body In this case, we create a style "mystyle.Treeview" with the following code (see the comments to understand what each line does): style = ttk.Style() On Windows, the following screenshot can be obtained from this example.By taking Treeview: Basic example, it can be shown how to customize a basic treeview. Tree.heading("two", text="Type",anchor=tk.W) Tree.heading("one", text="Date modified",anchor=tk.W) lumn("three", width=80, minwidth=50, stretch=tk.NO)ĭefinition of the headings tree.heading("#0",text="Name",anchor=tk.W) By defining stretch=tk.NO, the user cannot modify the width of the column. You can define how many columns, their width and minimum width when the user tries to stretch it. Create the widget tree=ttk.Treeview(master) The basic idea for tkinter.ttk is to separate, to the extent possible. It provides additional benefits including anti-aliased font rendering under X11 and window transparency (requiring a composition window manager on X11). Some nice tables can be also done using treeview widget. The tkinter.ttk module provides access to the Tk themed widget set, introduced in Tk 8.5. For instance, windows explorer can be reproduced in this way. This widget is used to display items with hierarchy.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |