Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p> I find the <code>place</code> manager the most intuitive and accurate of all three, because of the possibility to specify combinations of absolute and relative lengths for both positions and size:</p> <pre class="lang-py prettyprint-override"><code>mywidget.place(x=..., y=..., width=..., height=...) # absolute mywidget.place(relx=..., rely=..., relwidth=..., relheight=...) # relative # combination pad_left=5 pad_right=5 pad_top=5 pad_bottom=5 mywidget.place(relx=0, x=pad_left, rely=0, y=pad_top,\ relwidth=1, width=-pad_left-pad_right,\ relheight=1, height=-pad_top-pad_bottom, anchor="e") # use the whole space except some padding </code></pre> <p>For some reason, the <code>.place</code> manager doesn't seem very liked, but I find it makes a particulary good job to define how your widgets should move around and resize when the parent window is resized.</p> <p>To ease the construction of complex windows, I sometimes use a function (to kind of emulate a grid behaviour I suppose) to aid in the vertical placement, such as:</p> <pre class="lang-py prettyprint-override"><code>def offset_y(line_no): if line_no == 0: return 0 else: return height_label + (line_no - 1)*height_button mylabel.place(..., y=offset_y(0)) mybtn1.place(..., y=offset_y(1)) etc. </code></pre> <p>to pack vertically a Label and then a series of buttons. (Of course, the <code>.pack</code> manager could be used in this case, but the reason I prefer the <code>.place</code> manager is for understanding more accurately how things will move around when the window is resized).</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload