Python Forum

Full Version: Grid geometry doesnt work as expected
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Python : The grid geometry manager in tkinter doesnt function as it should, i have to code padding to push widgets around... I hate doing work arounds but there are no good books or websites on this issue...can someone direct to a simple example for grid geometry.

I want to be able to place a widget
In different parts of the grid but they end up side by side no matter what row and column i specify

Thanks
Sig
This is one of the major reasons that I stopped using tkinter, (the second was appearance).
I now use wxpython (phoenix version (python 3)) or Qt5 (pyqt5)
The best write-up on geometry I have found is this: https://tkdocs.com/tutorial/grid.html
Your question is too vague to answer. You didn't say what the problem is, so guessing, if you want empty rows and/or columns in between you have to give the empty rows/columns a weight so they will show up.
Default grid behavior is this, and most likely what you're experiencing, empty cells collapse to 0 width & height. Empty cells collapsing also affects empty rows & columns potentially resulting in rows & columns of 0 width and height. while not desirable in some/many cases empty cells collapsing, directly related to occupying required space facilitating their hosted controls dimensions exclusively, is predictable (consistent) and expected as the lack of content in a cell essentially leaves that cell in an uninitialized-like state.

While columns and rows may be set with weighted characteristics the ability to determine or set a static width and height explicitly is non-existent from what I've found, so far, researching Tkinter and TK both.

A work-around concerning spacing is similar to what is often used in web-grid-layouts utilizing tables long ago requiring shims generally being a transparent image. I'm not a fan of work-arounds myself feeling that they generally disrupt system flow & development intellectually and obscure oversight & laziness if not simply explicit disregard/refusal to advance the underlying system.

I do think Tkinter to be interesting and an excellent, portable solution, but with limitations while being minor have far reaching impact on adoption & built-in functionality. I find that understanding the TK/Tkinter system fundamental, but am looking into Kivy myself. wxPython, mentioned previously by Larz60+, is seasoned, robust and comes with phenomenal back-end support for just about anything imaginable (more like an OS dev kit than GUI library).

Take care and best wishes on finding resolution.