Python Forum
Grid geometry doesnt work as expected
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Grid geometry doesnt work as expected
#1
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
Reply
#2
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
Reply
#3
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.
Reply
#4
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.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Beginner question re: Tkinter geometry return2sender 3 905 Jun-19-2023, 06:19 PM
Last Post: deanhystad
Question [Tkinter] How to change geometry? Meffy 4 2,839 Jan-31-2021, 10:35 AM
Last Post: Meffy
  [Tkinter] Window geometry appears different on Win and Linux steve_shambles 6 6,937 Nov-29-2019, 12:30 AM
Last Post: steve_shambles
  Not understanding the correlation between code and geometry with Tkninter Intelligent_Agent0 3 2,919 Aug-04-2018, 08:22 AM
Last Post: Axel_Erfurt
  Button click doesnt work from my second class/layout in Python imamideb 0 2,327 Feb-13-2018, 12:09 PM
Last Post: imamideb

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020