Reputation: 503
I'm trying to fit all widget, I have tree frames:
First frame: Have a label (that need to have some name with a big letter size) A custom combobox to change the value of the label if nedded A button to make the selection of the combobox
Second frame: Have a treeview with some information that when I make a clic in one row another treeview appears in the 3rd frame. This treeview have occupy all the frame
Third frame: Have three columns: The first one have two rows: Fist row two buttons add and remove, that have occupy all the row. Second row a treeview that have occupy all it space. This treeview appears when click a row in the first treeview, how can I show the empty treeview and fill in when click the row. The function is OnDoubleClick The second column: Have two buttons that have to be in the center of the rows. The third column: Same as the first but with other treeview.
Here is an image of what i want to achive:
Upvotes: 1
Views: 5108
Reputation: 386020
I'm not going to rewrite your whole program because that's a lot of code, but I'll explain the way I would approach the problem. Tkinter layout is really simple if you are methodical and organized, and try to solve only one problem at a time.
First, you seem to have three main sections: a toolbar across the top, a middle section with a treeview, and a bottom section with a whole bunch of stuff. So, first thing I would do is create three frames, one for each section. Then, I would use pack
like this:
toolbar.pack(side="top", fill="x")
main.pack(side="top", fill="both", expand=True)
bottom.pack(side="top", fill="both", expand=False)
This one is very straight-forward. It's three widgets spread equally. You can use pack
or grid
, either will work just fine.
This just has a treeview, or maybe a treeview with scrollbars? Again, pack
or grid
works just fine with such a simple layout.
This one appears to be made up of three sections: a left section, a middle section, and a right section. Like with the main layout, I would start by creating three frames, all as children of the "bottom" frame created earlier. Then, I would again use pack
since it's a simple horizontal layout:
left.pack(side="left", fill="both", expand=True)
middle.pack(side="left", fill="both", expand=False)
right.pack(side="left", fill="both", expand=True)
By setting expand=True
to the left and right sides, if the window grows or shrinks, these will grow or shrink too while the middle section stays its natural size.
Both of these look identical. It looks like the easiest thing to do would be to create the widgets (ie: no more frames), and then use grid
to lay them out. Though, if by "buttons" you mean you could have several, you could create a frame for the buttons so that you can more easily pack all the buttons from left to right.
You can create buttons that are a child of this frame, and use either grid
or pack
.
Upvotes: 3