![]() 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: Tree.tag_configure('even', background='#DFDFDF') 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 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() We are just performing a print operation on function call or on event calling.By taking Treeview: Basic example, it can be shown how to customize a basic treeview.This function is called when the user double clicks on the option of treeviw widget.In the function definition, we initialized item with identifies property followed by treeview object.Here in the function, we passed the parameter event. Next, we used to bind with double click event and also we have defined a function named callback.Print("Your clicked on ".format(em(item,"text"))) Item=treeview.identify('item',event.x, event.y) In this example, we will see how we can use the bind function for performing a double click operation on the tree view. Please follow the next example for more elaboration.Įxample 2: Advance Example on Tree View widget with click event.Here we have to use the bind function to make it work as a click event. Note: In the tree view, we cannot use the command for the click event.Next, we aligned the items as sub-items as per our requirement.Now we inserted items into our treeview widget using the insert function or method of the tree view widget.In the very next line, we have initialized the tree view object with a Treeview widget with attributes height. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |