声明式GTK
TL;DR:是否有使用 GTK 创建声明式 UI 的库?最好有 Python 支持。
我是一名 Python/Django 开发人员,我关于用户界面的大部分经验都来自网络,其中声明式、松散耦合的 UI 设计是标准的。最近,我必须使用 Java/Swing 为学校项目创建一个 GUI 应用程序,最终使用 SwiXML 来为项目创建声明性 Swing 布局。
我问自己 Python 是否也有类似的可能性。我不太喜欢 Java,所以我不会开始开发 Swing 应用程序。在寻找Python GUI工具包时,我最终得出的结论是,该领域的三个主要参与者是GTK、QT和Wx。
在这 3 个中,我更喜欢 GTK,但我找不到任何方法来使用 GTK 创建声明式 UI。根据我使用 HTML 和 SwiXML 的经验,我发现基于代码的 UI 创建非常混乱,并且不希望这样做。声明式 UI 更加灵活且松散耦合。
是否有使用 GTK 创建声明式 UI 的库?最好有Python支持。
如果没有这样的东西(我认为是这样,因为我找不到任何东西),我可能最终会开始使用QT,即使我不喜欢默认的外观Linux下的它。 (但也许这也是可定制的,在某种程度上它看起来与 GTK 类似。)
TL;DR: Is there a library for declarative UI creation using GTK? Preferrably with Python support.
I'm a Python/Django developer, most of my experience about user interfaces is from the web, where declarative, loosely coupled UI designs are standard. Recently I've had to create a GUI app using Java/Swing for a school project and ended up using SwiXML to create declarative Swing layouts for the project.
I asked myself whether there are similar possibilities to use for Python. I'm not very fond of Java, so I won't start developing Swing applications. When looking for Python GUI Toolkits, I ended up concluding that the three main players in this field are GTK, QT and Wx.
Of those 3 I'd prefer GTK, but I could not find any way to create a declarative UI with GTK. From my experience with HTML and SwiXML, I find code based UI creation a huge mess and would prefer not having to do it that way. Declarative UI is much more flexible and more loosly coupled.
Is there a library for declarative UI creation using GTK? Preferrably with Python support.
If there isn't such a thing (which I assume, as I couldn't find anything), I might end up getting started with QT, even though I don't like the default look of it under Linux. (But maybe that's customizable too, in a way so that it looks similar to GTK.)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为您正在寻找的是
gtk.Builder
。基本上,gtk.Builder 对象可用于加载包含 xml 数据的 .ui 文件,该 xml 数据描述了用户界面的小部件以及对应该执行的事件的回调。由代码暴露。.ui
文件可以使用 glade 创建,因此您甚至不需要自己写xml。I think what you're looking for is
gtk.Builder
. Basically,gtk.Builder
objects can be used to load a.ui
file that contains xml data that describes the widgets for the user interface and the callbacks to the events that should be exposed by the code. The.ui
file can be created with glade so you don't even need to write the xml yourself.查看 enaml。虽然没有 GTK 工具包,但它是我所知道的唯一真正的 Python 声明式框架。
Look at enaml. Although there is no GTK toolkit, it is the only truly declarative framework for python that I'm aware of.