Show grid layout cells in tkinter

前端 未结 1 1760
醉酒成梦
醉酒成梦 2021-02-14 12:36

Is there a trick to show the grid layout cells (or the borders of the cells) when using it, in order to have a visual idea of what is going on behind the scenes?

<
相关标签:
1条回答
  • 2021-02-14 12:55

    If you give the containing frame a color, and use options to put padding between cells, the background will bleed through the gaps. This only works where there are widgets. If you have spans that are empty, you won't see grid lines.

    It's important to realize that you aren't creating a grid object. "grid" is not a thing, it's just instructions for how to lay out a set of widgets. If there is nothing in a row or column, that column won't show up. You don't create a grid per se, you tell a widget to display inner widgets using conceptual rows and columns.

    Another trick to learning to work with grid is to give each frame you're trying to use in a grid a distinctive color so you can see where one frame ends and another begins.

    The best thing to do when struggling with a layout is to get out pencil and paper. Draw out your UI, and natural borders should be evident. You can then use that as a guide to decide what the grid options should be.

    0 讨论(0)
提交回复
热议问题