python - Is it possible in tkinter to have two columns of labels with one label below and in the middle of them? -
while picture shows want do, however:
- all labels supposed perfect squares of same size
- labels in 2 columns should aligned
- the label @ bottom should below , in middle of other two.
- the actual labels should solid , there should little space around text of label(text shouldn't take whole label).
grid should used if possible. i'll use python3
yes, of course possible. tkinter arguably has flexible , easy use geometry managers of gui toolkit. pack
, place
, , grid
there no layout can't do.
start piece of paper. seriously. until able visualize this, use paper.
draw 4 equal width columns. divide columns 3 equal-height rows. you'll use lay out.
now, draw labels on top of that. notice on first 2 rows labels occupy columns 1 , 2, , columns 3 , 4. notice on third row label occupies columns 2 , 3.
now, transfer code. tkinter numbers rows , columns starting @ zero, first label row 0, column 0, , spans 2 columns. next label @ row 0, column 2, , spans 2 columns.
the next row done in same way.
for third row label row 2, column 1, , spans 2 columns.
don't forget call grid_rowconfigure
, grid_columnconfigure
. might want use uniform
attribute, example.
to make labels perfect squares, recommend putting each label in frame, setting width of frame whatever size want, , turning geometry propagation off frame sets size of label, rather label setting size of frame. put frames in grid, instead of labels.
you use combination of uniform
, minsize
options rows , columns, tjough might have problems if labels become big fit. experimentation see works best you.
Comments
Post a Comment