Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Show grid layout cells in tkinter

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?

I have searched a little bit, but have not found nothing yet.

like image 719
nbro Avatar asked Jan 19 '15 13:01

nbro


1 Answers

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.

like image 179
Bryan Oakley Avatar answered Nov 16 '22 03:11

Bryan Oakley