![]() ![]() Tree.insert('', t.END, text = 'Mechanical engineering', iid=1, open=False) Tree.insert('', t.END, text = 'Engineering', iid=0, open=False) Tree.heading('#0', text = 'Courses', anchor=t.W) Root_window.title('Hierarchical representation') Here is a program with an example of the Hierarchical representation we discussed above with courses in engineering: By configuring it, we set the table in the window. Now, as we create a tabular representation, we specify the names of the columns in a tuple.įinally, we assigned headings to the columns, inserted data into them, and created a function to handle the event ( When clicked on a row in the table, it displays a message). Using ttk.Treeview(), we created a Table Tree view widget with the root_window and columns, and by specifying ' headings' to show, we are telling the function to show the header row in the table. We created a root window called root_window, gave it a name, and gave dimensions to it. id(row = 0, column = 0, sticky = 'nsew') #Treeview widget on the root windowįirst, we imported the Tkinter module, the ttk sub-module, and the needed features(show info). Showinfo(title = 'Data', message = ' '.join(str(record))) Tree.heading('Phone number', text = 'Phone number')ĭata.append((f'', f'Phone number')) #list of tuples Tree.heading('Name', text = 'Name of the person') Tree.heading('SNo', text = 'Serial Number') #Headings Tree = ttk.Treeview(root_window, columns = descriptions, show = 'headings') To use themed widgets, we need to use the ttk class of the tkinter module.ĭescriptions = ('SNo', 'Name', 'Phone number') Tkinter has two types of widgets-classic and themed.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |