Updated 2017-09-09 15:25:38 by APN


How to adjust size of widgets like frame,label,text inside a window with resizing of the window in tcl tk GUI edit


I am new in tcl\tk and I am developing a UI using it. The UI window has a frame that has dynamic number of labels and text widgets filled according to the number of columns in a table. There is an entry widget for each column, data typed in it by user populates each column in the table.

However the problem I am facing is that , I cannot find a way to make the size and position of the widgets inside the frame in the window adjust themselves according to the size of the window. That is if the user enlarges the window by dragging and enlarging its size the widgets inside the window should also increase in size and adjust their positions according to the window size. Vice versa if the window size id decreased. Something like bootstrap in HTML, CSS.

Can anyone please give me any idea?? I have been searching the internet high and low but did not find anything useful. Any help is greatly appreciated. Thanks!

Siqsuruq - 2017-09-08 21:46:26

For example first entry will be small, and second one will fill x horizontally:
package require Tk
pack [ttk::entry .e]
pack [ttk::entry .e1] -fill x

Larry Smith You will likely need the grid manager, not pack. With grid you can weight each of the x,y coordinates according to how fast they need to expand and how much room they should use initially, and it can dynamically resize if individual items change.

[uban] - 2017-09-09 15:04:48

Hi, I am using grid manager. So you mean to do a rowconfigure and columnconfigure with the weight for each widget right? But my widgets are forming dynamically so I could still do the configure weight step in a for each loop for each widget right?


APN Please see http://www.tkdocs.com/tutorial/grid.html for a detailed tutorial. And of course you can do this in a loop.