Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Declarative 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.)

like image 396
Danilo Bargen Avatar asked Dec 19 '11 12:12

Danilo Bargen


1 Answers

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.

like image 187
jcollado Avatar answered Sep 28 '22 08:09

jcollado