64

Does anyone know of a GUI design app that lets you choose/drag/drop the widgets, and then turn that layout into Python code with the appropriate Tkinter calls & arrangement using the grid geometry manager? So far I've turned up a couple of pretty nice options that I may end up using, but they generate code using either pack or place instead.

=========

EDIT: Please note this is not to seek a "recommendation" per se, but rather it is a factual inquiry. I was asking whether or not such an app exists.

=====

Before you say it: Yes, I know Tkinter is easy to learn, and Yes, I've found multiple online sources to help me do so, and I'm already on my way with that. This isn't about avoiding the effort of learning, it's about using the right tool for the job. I found out a long time ago that those drag-and-drop widget environments for coding program logic, are just too klunky and unmanageable when the project gets beyond a certain size -- for bigger stuff, it's just easier to build and maintain the logic when it's in plain text. More recently I've found out that the reverse is true for designing a GUI. Writing text works up to a point, but when you have a main window with 30 or 40 widgets, plus a couple of side windows each with similar complexity, it goes much faster and easier if you can design it graphically rather than typing it all out.

JDM
  • 1,709
  • 3
  • 25
  • 48
  • The options I already looked at use (like I said) either `pack` or `place`, but not both. The perfect layout app would IMO support generating code in any of the three managers. I'd pay some good money out of pocket to get that. – JDM Jan 03 '13 at 20:10
  • 1
    So, what are these other pretty nice options that you mentioned, but didn't share with the rest of us! – voices May 24 '18 at 22:41
  • (Wincing) Sorry, after 5 years I don't remember... and even if I did, the options I did find thru Google have probably fallen out of support by now, or they've been supplanted by newer and much improved utilities. I'd suggest doing your own search, that'll give you better and more up to date information regardless. – JDM May 31 '18 at 11:47
  • I've had a pretty decent search. Everything I find seems to require extensive setup configurations with obscure dependencies, or requiring a substantial effort to.. kind of.. almost work.. sometimes. I really just wanted it as a learning tool, so I could build something graphically, and then check the code to learn how to do it manually. I ended up just grinding away at it. – voices Jun 02 '18 at 06:58
  • To overcome the time wastage of restarting the whole tkinter application even for a minute change, i have created a python script called as [Tk Creator](https://github.com/kurawlefaraaz/TK-Creator), however this wont convert it into python code. – Faraaz Kurawle Sep 18 '22 at 11:38
  • A couple of general observations: (1) Despite my editing the question long ago to clarify that it meets guidelines, it remains Closed. (2) Despite being closed it continues to garner upvotes. – JDM Apr 27 '23 at 17:19

3 Answers3

52

Apart from the options already given in other answers, there's a current more active, recent and open-source project called pygubu.

This is the first description by the author taken from the github repository:

Pygubu is a RAD tool to enable quick & easy development of user interfaces for the python tkinter module.

The user interfaces designed are saved as XML, and by using the pygubu builder these can be loaded by applications dynamically as needed. Pygubu is inspired by Glade.


Pygubu hello world program is an introductory video explaining how to create a first project using Pygubu.

The following in an image of interface of the last version of pygubu designer on a OS X Yosemite 10.10.2:

enter image description here

I would definitely give it a try, and contribute to its development.

gsamaras
  • 71,951
  • 46
  • 188
  • 305
nbro
  • 15,395
  • 32
  • 113
  • 196
  • I've just tried it now under win10, for a frame + labl + Entry. It's quit simple to understand with the project examples and some object knowledge. – Selso Liberado Nov 30 '18 at 18:36
31

You have VisualTkinter also known as Visual Python. Development seems not active. You have sourceforge and googlecode sites. Web site is here.

On the other hand, you have PAGE that seems active and works in python 2.7 and py3k

As you indicate on your comment, none of these use the grid geometry. As far as I can say the only GUI builder doing that could probably be Komodo Pro GUI Builder which was discontinued and made open source in ca. 2007. The code was located in the SpecTcl repository.

It seems to install fine on win7 although has not used it yet. This is an screenshot from my PC:

enter image description here

By the way, Rapyd Tk also had plans to implement grid geometry as in its documentation says it is not ready 'yet'. Unfortunately it seems 'nearly' abandoned.

nbro
  • 15,395
  • 32
  • 113
  • 196
joaquin
  • 82,968
  • 29
  • 138
  • 152
  • Visual Tkinter and PAGE are both pretty nice options that I may end up using, but they generate code using `place` instead. I was looking specifically for an app that generates `grid` geometry. – JDM Jan 03 '13 at 19:56
  • Thanks, I missed this one during my own search. It's running fine on my XP virtual machine and does generate `grid` based layouts. – JDM Jan 04 '13 at 19:13
  • 1
    Rapyd Tk has been released at version 1.0 but it's Python 2 only. The authors make it quite clear at [link](http://www.bitflipper.ca/rapyd/download.html) that they've no intention of porting to Python 3, so that's a complete no-go area for me personally, YMMV. – Mark Lawrence Apr 27 '16 at 06:32
  • @MarkLawrence That version is from 2 years ago. You can only wish they have changed their mind about py3k during this period... – joaquin Apr 27 '16 at 10:34
29

The best tool for doing layouts using grid, IMHO, is graph paper and a pencil. I know you're asking for some type of program, but it really does work. I've been doing Tk programming for a couple of decades so layout comes quite easily for me, yet I still break out graph paper when I have a complex GUI.

Another thing to think about is this: The real power of Tkinter geometry managers comes from using them together*. If you set out to use only grid, or only pack, you're doing it wrong. Instead, design your GUI on paper first, then look for patterns that are best solved by one or the other. Pack is the right choice for certain types of layouts, and grid is the right choice for others. For a very small set of problems, place is the right choice. Don't limit your thinking to using only one of the geometry managers.

* The only caveat to using both geometry managers is that you should only use one per container (a container can be any widget, but typically it will be a frame).

Bryan Oakley
  • 370,779
  • 53
  • 539
  • 685
  • Thanks for the tip regarding 'tunnel vision' in the choice of geometry managers. So far I've focused on `grid` to simplify the learning process (still getting the hang of the widgets themselves), but as I learn my way around better I'll probably branch out to the other managers. Which in turn is the main reason I was hoping to find a `grid`-generating layout app. I'd planned on using the layout app to get a rough cut quickly, then hand-tweaking the resulting widgets/layout code to fine tune the results. – JDM Jan 03 '13 at 20:04
  • At some point your answer seems to indicate that /mixing/ grid, pack, and place is a good thing. It is not. – mmgp Jan 03 '13 at 22:31
  • 8
    @mmgp: mixing pack and grid is not only ok, it's arguably the very best way to get a quality interface. I don't think I've ever created an interface where I didn't use both. The only rule is that you can't use them in the same container; within the app as a whole it's not only possible, I think it's the preferred way to work. Each has strengths and weaknesses -- take advantage of the strengths and avoid the weaknesses. – Bryan Oakley Jan 04 '13 at 01:45
  • @BryanOakley: do you have a special version of Tk so you can mix grid, pack, and place in a single master container ? I'm pretty sure you are going to answer "then use two distinct master container". I really don't see any benefit in mixing pack and grid. The place might be used to do funny things, but I don't see that as a good GUI practice. – mmgp Jan 04 '13 at 01:52
  • On a sheet of paper, you can't easily move or reshape things, you have to erase and redraw them from scratch. Likewise, you can't see how controls would behave when you resize the window. – ivan_pozdeev Mar 29 '19 at 14:26