Each of the coordinates may be specified in any of the forms given in the COORDINATES section. This region is used for scrolling purposes and is considered to be the boundary of the information in the canvas. Note: To generate the above picture, you should add/change the aforementioned lines of code in the example Treeview: Basic example. scrollregion: Specifies a list with four coordinates describing the left, top, right, and bottom coordinates of a rectangular region. The result is a treeview with modified fonts on both the body and headings, no border and different colors for the rows: Tree.tag_configure('even', background='#DFDFDF') Then, for instance, a background color can be associated to the tags: tree.tag_configure('odd', background='#E8E8E8') Also, the command attribute of the scrollbar needs to be set to the. In the case of a vertical scrollbar, the yscrollcommand attribute of the widget needs to be set to the set function of the scrollbar (or something that works just like it). 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',)) You connect scrollbars to a Treeview widget the same as you do for any other scrollable widget. Then, the widget is created giving the above style: tree=ttk.Treeview(master,style="mystyle.Treeview") Using the Treeview widget Populating nested items in a Treeview Displaying. Style.layout("mystyle.Treeview", ) # Remove the borders nfigure("", font=('Calibri', 13,'bold')) # Modify the font of the headings 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() By taking Treeview: Basic example, it can be shown how to customize a basic treeview.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |