<p>I've been learning python for a while now with some success. I even managed to create one or two (simple) programs using PyGtk + Glade.</p>

<p>The thing is: I am not sure if the best way to use GTK with python is by building the interfaces using Glade.</p>

<p>I was wondering if the more experienced ones among us (remember, I'm just a beginner) could point out the benefits and caveats of using Glade as opposed to creating everything in the code itself (assuming that learning the correct gtk bindings wouldn't exactly be a problem).</p>

[{'answer_id': 48136, 'author': 'John Millikin', 'author_id': 3560, 'author_profile': 'https://Stackoverflow.com/users/3560', 'pm_score': 4, 'selected': False, 'text': "<p>Use GtkBuilder instead of Glade, it's integrated into Gtk itself instead of a separate library.</p>\n\n<p>The main benefit of Glade is that it's much, much easier to create the interface. It's a bit more work to connect signal handlers, but I've never felt that matters much.</p>\n"}, {'answer_id': 48734, 'author': 'Boris Terzic', 'author_id': 1996, 'author_profile': 'https://Stackoverflow.com/users/1996', 'pm_score': 5, 'selected': True, 'text': '<p>I would say that it depends: if you find that using Glade you can build the apps you want or need to make than that\'s absolutely fine. If however you actually want to learn how GTK works or you have some non-standard UI requirements you will <strong>have</strong> to dig into GTK internals (which are not that complicated).</p>\n\n<p>Personally I\'m usually about 5 minutes into a rich client when I need some feature or customization that is simply impossible through a designer such as Glade or <a href="http://www.mono-project.com/Stetic" rel="noreferrer">Stetic</a>. Perhaps it\'s just me. Nevertheless it is still useful for me to bootstrap window design using a graphical tool.</p>\n\n<p>My recommendation: if making rich clients using GTK is going to be a significant part of your job/hobby then learn GTK as well since you <strong>will</strong> need to write that code someday.</p>\n\n<p>P.S. I personally find <a href="http://www.mono-project.com/Stetic" rel="noreferrer">Stetic</a> to be superior to Glade for design work, if a little bit more unstable.</p>\n'}, {'answer_id': 54313, 'author': '8128', 'author_id': 1530, 'author_profile': 'https://Stackoverflow.com/users/1530', 'pm_score': 3, 'selected': False, 'text': "<p>Glade is very useful for creating interfaces, it means you can easily change the GUI without doing much coding. You'll find that if you want to do anything useful (e.g. build a treeview) you will have to get familiar with various parts of the GTK documentation  - in practice finding a good tutorial/examples. </p>\n"}, {'answer_id': 106889, 'author': 'Jeremy Cantrell', 'author_id': 18866, 'author_profile': 'https://Stackoverflow.com/users/18866', 'pm_score': 3, 'selected': False, 'text': "<p>I started out using glade, but soon moved to just doing everything in code. Glade is nice for simple things, and it's good when you're learning how GTK organizes the widgets (how things are packed, etc). Constructing everything in code, however, you have much more flexibility. Plus, you don't have the glade dependency.</p>\n"}, {'answer_id': 107959, 'author': 'crystalattice', 'author_id': 18676, 'author_profile': 'https://Stackoverflow.com/users/18676', 'pm_score': 2, 'selected': False, 'text': "<p>I usually start with Glade until I come to a point where it doesn't have the features I need, e.g. creating a wizard. As long as I'm using the standard widgets that Glade provides, there's really no reason to hand-code the GUI.</p>\n\n<p>The more comfortable I become with how Glade formats the code, the better my hand-coding becomes. Not to mention, it's real easy to use Glade to make the underlying framework so you don't have to worry about all the initializations.</p>\n"}, {'answer_id': 199167, 'author': 'CyberFonic', 'author_id': 23999, 'author_profile': 'https://Stackoverflow.com/users/23999', 'pm_score': 1, 'selected': False, 'text': "<p>For quick and simple screens I use Glade.  But for anything that needs finer levels of control, I create a custom classes for what I actually need (this is important, because it's too easy to get carried away with generalisations).</p>\n\n<p>With a skinny applications specific classes, I can rapidly change the look and feel application wide from a single place.  Rather like using CSS to mantain consistency for web sites.</p>\n"}, {'answer_id': 305667, 'author': 'markuz', 'author_id': 32526, 'author_profile': 'https://Stackoverflow.com/users/32526', 'pm_score': 2, 'selected': False, 'text': "<p>I recommend using Glade for rapid development, but not for learning. Why? because some times you will need to tune up some widgets in order to work as you want they to work, and if you don't really know/understand the properties attributes of every widget then you will be in troubles.</p>\n"}, {'answer_id': 524614, 'author': 'Bruce van der Kooij', 'author_id': 63736, 'author_profile': 'https://Stackoverflow.com/users/63736', 'pm_score': 2, 'selected': False, 'text': '<p>If you\'re writing a traditional GUI application which reuses a lot of standard components from GTK+ (buttons, labels, containers etc.) I\'d personally go with Glade + Kiwi (a convenience framework for building GTK+ GUI applications). </p>\n\n<p>The single greatest advantage to using Glade is that it greatly reduces layout/packing code. Here\'s an extremely simply example which already shows the issues with manually laying out a GUI (without using any helper functions): </p>\n\n<pre><code>container = gtk.HBox()\nlabel = gtk.Label(str="test")\ncontainer.add(label)\n</code></pre>\n\n<p>For more examples take a <a href="http://marcin.af.gliwice.pl/if-then-else-20071113232114" rel="nofollow noreferrer">look here</a>. Even if you\'re writing a complicated custom widget you can always create a placeholder in Glade and replace that after instantiation. </p>\n\n<p>It shouldn\'t be all too long now for the Glade team to release a new version of the designer (3.6.0). This new version will add support for GtkBuilder, which replaces libglade (the actual library that transforms the Glade XML files into a widget tree). The new Glade designer also once again adds support for defining catalogs (sets of widgets) in Python, so you can easily add your own custom widgets.</p>\n'}, {'answer_id': 751707, 'author': 'user78460', 'author_id': 78460, 'author_profile': 'https://Stackoverflow.com/users/78460', 'pm_score': 1, 'selected': False, 'text': '<p>Personally I would recommend coding it out instead of using Glade. I\'m still learning python and pyGtk but I will say that writing out the UI by hand gave me a lot of insight on how things work under the hood. </p>\n\n<p>Once you have it learned I\'d say to give glade, or other UI designers a try but definitely learn how to do it the "hard" way first.</p>\n'}, {'answer_id': 2149087, 'author': 'Charles Merriam', 'author_id': 1320510, 'author_profile': 'https://Stackoverflow.com/users/1320510', 'pm_score': 2, 'selected': False, 'text': '<p>First, start to put this in perspective.</p>\n\n<p>You will be using GTK.  This is a huge C library built in 1993 using the best traditions of 1970s coding style.  It was built to help implement the GIMP, a Photoshop competitor wanna-be with user interface blunders of legend.  A typical gui field might have forty or more parameters, mostly repetitive, having getters and setters.  There will be pain.</p>\n\n<p>The GTK itself manages a complete dynamic type system in C using GObject.  This makes debugging a special joy that requires manually walking through arrays of pointers to methods full of generic argument lists with implicit inheritance.  You will also be jumping through Pango libraries when you least expect it, e.g., using a Pango constant for where in a label the ellipsis go when the page is small.  Expect more pain.</p>\n\n<p>By now, you are probably vowing to wrap all your GTK interactions in a Model-View-Controller architecture specific to your application.  This is good.</p>\n\n<p>Using Glade, or gtkBuilder, or Stetic, will help coral the huge coupling problem of forty parameters to a function.  Glade provides a basic GUI builder to drag and drop components together.  The parameters and inherited parameters are somewhat separated out.  The output of Glade is .glade XML file which you will then read in, attach your callbacks ("signal handlers") to identically named functions, and query or update the in-memory version of that XML to get widgets that you then use pyGTK to manipulate. Glade itself is a creaky and not well maintained.  </p>\n\n<p>Using pyGTK gives you annoyingly fine grained control in order to build your GUI.  This will be verbose, copy-and-paste code.   Each attribute will be a separate function call.  The attribute setter does not return anything, so chaining the calls is out of the question.  Usually, your IDE will give only minimal help on what functions mean and you will be constantly referring to DevHelp or some other tool.</p>\n\n<p>One would almost expect GTK GUIs were meant to fail.</p>\n'}, {'answer_id': 24449263, 'author': 'Shellexy Wang', 'author_id': 3782631, 'author_profile': 'https://Stackoverflow.com/users/3782631', 'pm_score': -1, 'selected': False, 'text': '<p>You may use glade-2 to design, and use <a href="https://gist.github.com/shellexy/0ad0864b7e4e99a0a95d" rel="nofollow">glade2py.py</a> to generating the pure pygtk code, \nit use pygtkcompat to support gtk3</p>\n'}]
['https://Stackoverflow.com/questions/48123', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/802/']