是否有任何适用于 Python 的“易于编程”的 GUI 工具包?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/35922/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-11-03 19:25:25  来源:igfitidea点击:

Are there any "nice to program" GUI toolkits for Python?

pythonuser-interface

提问by dbr

I've played around with GTK, TK, wxPython, Cocoa, curses and others. They are are fairly horrible to use.. GTK/TK/wx/curses all seem to basically be direct-ports of the appropriate C libraries, and Cocoa basically mandates using both PyObjC and Interface Builder, both of which I dislike..

我玩过 GTK、TK、wxPython、Cocoa、curses 等。它们使用起来相当糟糕.. GTK/TK/wx/curses 似乎基本上都是适当的 C 库的直接端口,而 Cocoa 基本上要求同时使用 PyObjC 和 Interface Builder,我不喜欢这两者。

The Shoes GUI library for Ruby is great.. It's very sensibly designed, and very "rubyish", and borrows some nice-to-use things from web development (like using hex colours codes, or :color => rgb(128,0,0))

Ruby 的 Shoes GUI 库很棒。它的设计非常合理,而且非常“红宝石化”,并且从 Web 开发中借用了一些很好用的东西(例如使用十六进制颜色代码,或者:color => rgb(128,0,0)

As the title says: are there any nice, "Pythonic" GUI toolkits?

正如标题所说:有没有不错的“Pythonic”GUI 工具包?

采纳答案by dF.

Have you looked at Qt/PyQt? Although PyQt isa direct port from the C++ library, I find it much more pythonic and nice to program with compared to the others you listed. It also has very good documentation.

你看过Qt/ PyQt吗?尽管 PyQtC++ 库的直接移植,但我发现与您列出的其他库相比,它更 Python 化且易于编程。它也有很好的文档。

Dabohas a nice ui library implemented on top of wxPython. It's a framework intended mostly for database-centric applications, but the ui library can be used separately.

Dabo有一个很好的 ui 库,它是在 wxPython 之上实现的。它是一个主要用于以数据库为中心的应用程序的框架,但 ui 库可以单独使用。

There are/were several other attempts to create a very pythonic gui as a layer on top of PyGtk or wxPython, such as waxand PyGui, which seem to be "stuck" at various degrees of being complete.

还有其他一些尝试创建一个非常pythonic的gui作为PyGtk或wxPython之上的一个层,例如waxPyGui,它们似乎在不同程度的完成上“卡住”。

Also, an exhaustive list of Python GUI toolkits can be found here.

此外,可以在此处找到 Python GUI 工具包的详尽列表。

回答by Ed Leafe

Please check out Dabo, our framework for desktop applications. http://dabodev.com

请查看我们的桌面应用程序框架 Dabo。http://dabodev.com

We have wrapped the wxPython toolkit for the UI classes, and replaced their ugly C++ style functions with simple properties. You mentioned assigning color: in Dabo, you would do it very simply, using your choice of:

我们为 UI 类包装了 wxPython 工具包,并用简单的属性替换了它们丑陋的 C++ 风格的函数。您提到分配颜色:在 Dabo 中,您可以非常简单地使用以下选项:

obj.BackColor = "red"
obj.BackColor = (255, 0, 0)
obj.BackColor = "FF0000"
obj.BackColor = "#FF0000"

Dabo understands all of these, and handles the differences for you automatically.

大博了解所有这些,并自动为您处理差异。

I am one of the authors of Dabo, and would be happy to answer any other questions that you may have.

我是 Dabo 的作者之一,很乐意回答您可能遇到的任何其他问题。

--- Ed Leafe

---埃德·利夫

回答by Ed Leafe

Seconding PyQt. Coupled with the book Rapid GUI Programming with Python and Qt, it's really easy to learn.

借用PyQt。再加上《Rapid GUI Programming with Python and Qt》这本书,真的很容易学。

回答by Can Berk Güder

I use pyGtk. I think wxPython is nice but it's too limited, and PyQt is, well, Qt. =)

我使用 pyGtk。我认为 wxPython 很好,但它太有限了,而 PyQt 就是 Qt。=)

回答by Tom

I've used Gladewith some success, though I didn't manage to wrap my head around creating anything really complex. It has a nice GUI builder and stores the forms as xml files that are loaded dynamically. Kind of like XAML afiak.

我已经使用Glade取得了一些成功,尽管我没有设法创造任何真正复杂的东西。它有一个很好的 GUI 构建器,并将表单存储为动态加载的 xml 文件。有点像 XAML afiak。