• I need a basic tutorial for GUI creation using Cambalache

    From Chris Green@3:633/10 to All on Wed Aug 12 09:26:38 2026
    I am a retired software engineer with a background in assembler, C and
    C++.

    I now dabble (mostly for my own amusement) in various bits and pieces,
    mostly in Python nowadays. I have written quite a lot of Python
    command line programs to run in a terminal. I have also written a
    couple of simple Python GUI programs using PyGObject and Gtk. This is
    all on Debian/Linux.

    I want to go a bit further and it appears that the most obvious next
    step is to use Cambalache which has taken over from Glade as the
    default GUI builder for Gnome/GTK.

    The problem is that there appear to be no tutorials for Cambalache. I
    can find how to install it (which I had done already without problems)
    but I can't find anywhere that simply runs through the sequence of
    actions required to build a working Python GUI using Cambalache.

    I'm sort of aware that Cambalache creates an XML file that represents
    the GUI and that XML file has to be processed somehow (by GTKBuilder?)
    to make a running GUI program. I need a bit more help in
    understanding the actual process though.

    Can anyone point me at anything that might help?

    --
    Chris Green
    ú

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Lawrence D?Oliveiro@3:633/10 to All on Wed Aug 12 21:47:46 2026
    On Wed, 12 Aug 2026 09:26:38 +0100, Chris Green wrote:

    I'm sort of aware that Cambalache creates an XML file that
    represents the GUI and that XML file has to be processed somehow (by GTKBuilder?) to make a running GUI program.

    Yeah, it seems in GTK4 you no longer have public access to the
    individual widget-creation calls. But you can embed the entire XML
    describing your UI inside your program code, which is convenient for
    small, simple programs.

    Here?s an example snippet from my limited dabbling with GTK4 so far:

    ui = \
    (
    "<?xml version='1.0' encoding='utf-8'?>\n"
    "<interface>\n"
    " <requires lib='gtk' version='4.0'/>\n"
    " <object class='GtkWindow' id='main'>\n"
    " <child>\n"
    " <object class='GtkGLArea' id='draw'/>\n"
    " </child>\n"
    " </object>\n"
    "</interface>\n"
    )
    junk = XMLElementTree.fromstring(ui)
    # just to check it?s syntactically OK, because Gtk.Builder.new_from_string simply
    # returns a builder object with no contents instead of reporting errors.
    bld = Gtk.Builder.new_from_string(ui, -1) # don?t know why wrapper insists on length arg
    sys.stdout.write("objects = %s\n" % repr(bld.get_objects())) # debug
    wdw = bld.get_object("main")
    drw = bld.get_object("draw")

    Yeah, I discovered that, if there was an error in your XML, you didn?t
    get any error message (that I could find), the returned Builder object
    simply ended up with nothing in it.

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Jon Ribbens@3:633/10 to All on Wed Aug 12 22:23:39 2026
    On 2026-08-12, Lawrence D?Oliveiro <ldo@nz.invalid> wrote:
    Here?s an example snippet from my limited dabbling with GTK4 so far:

    ui = \
    (
    "<?xml version='1.0' encoding='utf-8'?>\n"
    "<interface>\n"
    " <requires lib='gtk' version='4.0'/>\n"
    " <object class='GtkWindow' id='main'>\n"
    " <child>\n"
    " <object class='GtkGLArea' id='draw'/>\n"
    " </child>\n"
    " </object>\n"
    "</interface>\n"
    )

    Just to say that would obviously be a lot easier and cleaner like this:

    ui = '''
    <?xml version='1.0' encoding='utf-8'?>
    <interface>
    <requires lib='gtk' version='4.0'/>
    <object class='GtkWindow' id='main'>
    <child>
    <object class='GtkGLArea' id='draw'/>
    </child>
    </object>
    </interface>
    '''

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Lawrence D?Oliveiro@3:633/10 to All on Thu Aug 13 08:30:25 2026
    On Wed, 12 Aug 2026 21:47:46 -0000 (UTC), I wrote:

    Yeah, it seems in GTK4 you no longer have public access to the
    individual widget-creation calls.

    Of course, I could be wrong ...

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Piergiorgio Sartor@3:633/10 to All on Mon Aug 24 10:30:15 2026
    On 12/08/2026 10.26, Chris Green wrote:
    I am a retired software engineer with a background in assembler, C and
    C++.

    I now dabble (mostly for my own amusement) in various bits and pieces,
    mostly in Python nowadays. I have written quite a lot of Python
    command line programs to run in a terminal. I have also written a
    couple of simple Python GUI programs using PyGObject and Gtk. This is
    all on Debian/Linux.

    I want to go a bit further and it appears that the most obvious next
    step is to use Cambalache which has taken over from Glade as the
    default GUI builder for Gnome/GTK.

    Not sure if this is the obvious next step.
    Depending on what your objective is.

    There are plenty of different Python modules
    to *create* (not to *design*) GUIs.

    For example: Gradio, DearPyGUI, Pyside6 and
    many more.

    All those are plenty documented, with many
    examples as well.
    With more or less pre-cooked structures.

    Of course, if the objective is to *design*
    the GUI, then possibly Cambalache may be
    the right tool.

    bye,

    --

    piergiorgio

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)