Text_wid. Text_wid = tk.Text(ame_right, width=30, height=20) ame_right=tk.Frame(self.root, bg="salmon", Tk.Label(ame_left, text="Label %d" % (ctr+1), ame_left=tk.Frame(self.root, bg="lightblue", Tk.Button(self.root, bg="blue", text="Quit", Post some code if you want additional help. When this program was almost finished, it occurred to me that one of tkinter's gotchas is that width is sometimes measured in pixels and sometimes in letters. This is an example of doing something in the ball park of what you are asking. I don't know how to keep the treeview constrained within the pane, i've tried putting it in a frame as well as adjusting the and columnconfigure but still the same thing occurs, i dont necessarily have to use a panedwindow but i just want it to be constrained to a specific portion of the screen and not the whole top halfĭisplaying data on the right half of my window with another free portion on the left side that would have buttons and entry boxes I also tried doing it with just one panedwindow like this but it also had no effect: panel_left=tk.PanedWindow(bd=2,bg='yellow',orient=tk.HORIZONTAL) data_tree = ttk.Treeview(self.root, columns=json_tree_columns, show="headings", ) panel_left.add(data_tree) panel_left.pack(fill=tk.BOTH,expand=True)` but it still makes the treeview take up the entire screen Then this happens when I attempt to add the treeview to the panel_right using the following code: data_tree = ttk.Treeview(panel_right,columns=json_tree_columns, show="headings", ) Panel_right.pack(side='right', fill=tk.BOTH, expand=1) Panel_right = tk.PanedWindow(bd=2, bg='orange') Panel_left.pack(side='left',fill=tk.BOTH,expand=1) Panel_left=tk.PanedWindow(bd=2,bg='yellow') Treeview widget, which displays each week of the. The best explanation I can show is by using the PanedWindow where I made two panes on the left and right side of the screen using the following code: class MyGUI: A practical solution to your GUI development problems with Python and Tkinter. I have tried adding frames directly to the root but as soon as I add the treeview any of the frames, it immediately resizes and takes up the entire top portion of the screen regardless of what I do. Movie_ am trying to have a treeview displaying data on the right half of my window with another free portion on the left side that would have buttons and entry boxes. Is there a way to empty the second one and reload it?įinally got it to work using "delete" #McListBox Example Every time I make a selection in the first, padding is extended between the widgets. The second tree should change with the mouse selection in the first. I'm fairly new to python and am having problems getting multiple TreeViews to work well. Movie_listbox = McListBox(movie_header,Movies_list) Root.wm_title("ttk.TreeView as multicolumn ListBox")Īctor_listbox = McListBox(actor_header,Actors_list) Movie_listbox._init_(movie_header,Movies_list) # switch the heading so that it will sort in the opposite directionĬommand=lambda col=col: sortby(tree, col, int(not descending))) # if the data to be sorted is numeric change to float """sort tree contents when a column header is clicked on"""ĭata = """if the data to be sorted is numeric change to float""" If (self.element_header, width=None) < col_w: # adjust column's width if necessary to fit each value (col, width=tkFont.Font().measure(col.title())) The width, alignment and label of a column can further be specified. # adjust the column's width to the header string Vsb.grid(column=1, row=0, sticky='ns', in_=container)Ĭid_columnconfigure(0, weight=1)Ĭommand=lambda c=col: sortby(ee, c, 0)) (column=0, row=0, sticky='nsew', in_=container) Vsb = ttk.Scrollbar(orient="vertical", command=) ee = ttk.Treeview(columns=self.element_header, show="headings") """use a ttk.TreeView as a multicolumn ListBox"""ĭef _init_(self,element_header,element_list):
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |