classification
Title: Tkinter Flow Geometry Manager
Type: enhancement Stage: resolved
Components: Tkinter Versions: Python 3.11
process
Status: closed Resolution: works for me
Dependencies: Superseder:
Assigned To: Nosy List: Gary73, epaine, gpolo, serhiy.storchaka, zach.ware
Priority: normal Keywords:

Created on 2021-06-15 23:09 by Gary73, last changed 2021-07-24 00:03 by Gary73. This issue is now closed.

Repositories containing patches
https://github.com/garydavenport73/cpython
Messages (6)
msg395900 - (view) Author: Gary Davenport (Gary73) Date: 2021-06-15 23:09
Hi there.  I love Python and Tkinter.  I know that there are geometry managers pack, place, and grid.  I think there should be a flow type management available, like what is done in Java or html/css.  This is more important as responsive GUI design is needed with different screen sizes.

I initially addressed this by inheriting from the Frame in tkinter to a 'FlowFrame' object and anything in that Frame would have flow geometry.

But this is a little awkward because the syntax is widget.pack() or widget.grid(), etc, so the method is linked to the widget.

So I altered the tkinter __init__.py  wrapper to add the .flow method so you can use widget.flow() syntax.

The flow geometry manager uses the grid managers methods.

The changes are straight-forward and I have 3 related projects on github:

1) https://github.com/garydavenport73/tkinterFlow - 
there are only 2 versions so history will demonstrate the relatively simple changes.

2) https://github.com/garydavenport73/FlowFrame -
a related project, FlowFrame object

3) https://github.com/garydavenport73/cpython
the formal changes to the most recent

https://github.com/python/cpython/blob/3.9/Lib/tkinter/__init__.py file.
msg395905 - (view) Author: Zachary Ware (zach.ware) * (Python committer) Date: 2021-06-16 02:44
Hi Gary.

This sounds interesting.  However, Tkinter generally tries to be a pretty thin wrapper around Tcl/Tk; is there something like this already in Tk that could be used instead, or existing discussion to add such to Tk?  We certainly would not want to wind up in the situation of conflicting with Tcl/Tk if they later add something in the same vein :)

Also, the ship has long sailed for adding this to 3.9; 3.11 is the earliest this could happen at this point; I've adjusted the issue metadata accordingly.
msg395911 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2021-06-16 08:12
I concur with Zachary. If the flow geometry manager be added in Tk we will add its support in Tkinter. We can even add pure Python implementation for older Tk versions. But we do not want to risk conflicting with Tk.
msg395916 - (view) Author: E. Paine (epaine) * Date: 2021-06-16 10:43
> But we do not want to risk conflicting with Tk.
I think it's worth noting that tkinter does already have some 'extra' functionality over just what Tk offers (such as the ttk extension widgets `LabeledScale` and `OptionMenu`).


While this would (IMO) be a useful addition, it may be better suited as a third-party library.
msg395934 - (view) Author: Gary Davenport (Gary73) Date: 2021-06-16 15:27
Thank you so much for the kind words and help in giving me some direction with these projects.  I am relatively new to Python, object oriented programming and open source collaboration.

I think the 3rd party module probably makes the most sense, because this is how I am currently using it.  The beginning of my code typically looks like this:

from tkinter import *
from tkinterFlow import *

But I will have to look at how to make or publish a module and so forth.  Then I would maintain the module with new releases.

I am also going to study Tk more.  I am fairly certain I can add the flow manager at that level.  Really the flow geometry manager as I have made isn't really a manager on its own.  It uses the grid managers methods.  (it could use the place instead of grid, but I chose grid).  

The main question I suppose would be does the community want a .flow method added to the Widgets in Tk or a 3rd party module?  I think I could make either one, given some time and study.

For now I will look into making the 3rd party module.  This is a skill I need to develop notwithstanding this flow manager project.

My main goal is just to make it easy for someone to implement flow behaviour.

Thanks again to everyone for your time and direction.
msg398106 - (view) Author: Gary Davenport (Gary73) Date: 2021-07-24 00:03
Just an update on this issue.  I did make 2 packages available on pypi.org:

https://pypi.org/project/flowframe/

and 

https://pypi.org/project/tkinterflow/

Thank you very much for your help.
History
Date User Action Args
2021-07-24 00:03:48Gary73setstatus: open -> closed
resolution: works for me
messages: + msg398106

stage: resolved
2021-06-16 15:27:27Gary73setmessages: + msg395934
2021-06-16 10:43:40epainesetnosy: + epaine
messages: + msg395916
2021-06-16 08:12:32serhiy.storchakasetmessages: + msg395911
2021-06-16 02:44:44zach.waresetversions: + Python 3.11, - Python 3.9
nosy: + gpolo, serhiy.storchaka, zach.ware

messages: + msg395905

type: enhancement
2021-06-15 23:09:33Gary73create