Python 是否有用于 Tkinter / 网格几何图形的 GUI 设计应用程序?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14142194/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Is there a GUI design app for the Tkinter / grid geometry?
提问by JDM
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 gridgeometry 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 packor placeinstead.
有谁知道 GUI 设计应用程序可以让您选择/拖放小部件,然后使用grid几何管理器通过适当的 Tkinter 调用和排列将该布局转换为 Python 代码?到目前为止,我已经找到了几个我最终可能会使用的非常好的选项,但是它们使用pack或place替代生成代码。
=========
==========
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.
在你说出来之前:是的,我知道 Tkinter 很容易学习,是的,我已经找到了多个在线资源来帮助我这样做,而且我已经开始学习了。这不是要避免学习的努力,而是要为工作使用正确的工具。很久以前我就发现那些用于编码程序逻辑的拖放小部件环境,当项目超过一定规模时就太笨拙且难以管理——对于更大的东西,构建和维护逻辑更容易当它是纯文本时。最近,我发现设计 GUI 的情况正好相反。编写文本在一定程度上是有效的,但是当你有一个包含 30 或 40 个小部件的主窗口,加上几个具有相似复杂性的侧窗口时,
采纳答案by joaquin
You have VisualTkinteralso known as Visual Python. Development seems not active. You have sourceforgeand googlecodesites. Web site is here.
您有VisualTkinter,也称为 Visual Python。开发似乎并不活跃。你有sourceforge和googlecode站点。网站在这里。
On the other hand, you have PAGEthat seems active and works in python 2.7 and py3k
另一方面,您的PAGE看起来很活跃并且可以在 python 2.7 和 py3k 中使用
As you indicate on your comment, none of these use the gridgeometry. As far as I can say the only GUI builder doing that could probably be Komodo Pro GUI Builderwhich was discontinued and made open source in ca. 2007. The code was located in the SpecTcl repository.
正如您在评论中指出的那样,这些都没有使用grid几何。据我所知,唯一这样做的 GUI 构建器可能是Komodo Pro GUI Builder,它在加州停产并开源。2007. 代码位于SpecTcl 存储库中。
It seems to install fine on win7 although has not used it yet. This is an screenshot from my PC:
虽然还没有使用它,但它似乎在win7上安装得很好。这是我电脑上的截图:


By the way, Rapyd Tkalso had plans to implement grid geometry as in its documentation says it is not ready 'yet'. Unfortunately it seems 'nearly' abandoned.
顺便说一下,Rapyd Tk还计划实施网格几何,因为在其文档中说它“还没有”准备好。不幸的是,它似乎“几乎”被放弃了。
回答by Bryan Oakley
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.
使用网格进行布局的最佳工具,恕我直言,是方格纸和铅笔。我知道您要求某种类型的程序,但它确实有效。我已经做了几十年的 Tk 编程,所以布局对我来说很容易,但是当我有一个复杂的 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.
另一件需要考虑的事情是:Tkinter 几何管理器的真正力量来自于将它们一起使用*。如果您打算只使用网格或只使用包装,那您就错了。相反,首先在纸上设计您的 GUI,然后寻找最适合其中一个解决方案的模式。Pack 是某些类型布局的正确选择,而 grid 是其他布局的正确选择。对于一小部分问题,place 是正确的选择。不要将您的想法限制在仅使用几何管理器之一。
* 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).
* 使用两个几何管理器的唯一警告是每个容器只能使用一个(容器可以是任何小部件,但通常它是一个框架)。
回答by nbro
Apart from the options already given in other answers, there's a current more active, recent and open-source project called pygubu.
除了其他答案中已经给出的选项之外,还有一个当前更活跃、最近的开源项目,名为pygubu.
This is the first description by the author taken from the github repository:
这是作者从github存储库中获取的第一个描述:
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 是一个 RAD 工具,可以快速轻松地为 python tkinter 模块开发用户界面。
设计的用户界面保存为 XML,通过使用 pygubu 构建器,这些可以由应用程序根据需要动态加载。Pygubu 的灵感来自 Glade。
Pygubu hello world programis an introductory video explaining how to create a first project using Pygubu.
Pygubu hello world 程序是一个介绍性视频,解释了如何使用Pygubu.
The following in an image of interface of the last version of pygubudesigner on a OS X Yosemite 10.10.2:
以下pygubu是 OS X Yosemite 10.10.2 上最新版本设计器的界面图像:


I would definitely give it a try, and contribute to its development.
我一定会尝试一下,并为它的发展做出贡献。

