Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #197880

Re: I need a basic tutorial for GUI creation using Cambalache

Path csiph.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail
From Lawrence D’Oliveiro <ldo@nz.invalid>
Newsgroups comp.lang.python
Subject Re: I need a basic tutorial for GUI creation using Cambalache
Date Wed, 12 Aug 2026 21:47:46 -0000 (UTC)
Organization A noiseless patient Spider
Lines 36
Message-ID <115ipm1$15btq$1@dont-email.me> (permalink)
References <uantkm-bbj1.ln1@q957.zbmc.eu>
MIME-Version 1.0
Content-Type text/plain; charset=UTF-8
Content-Transfer-Encoding 8bit
Injection-Date Wed, 12 Aug 2026 21:47:46 +0000 (UTC)
Injection-Info dont-email.me; logging-data="1224634"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19ExVzA3akoBf0caDEcF+Mv"; posting-host="f772758bdb9d9b11eccfcafa40234fa0"
User-Agent Pan/0.165 (Kostiantynivka)
Cancel-Lock sha1:Q4/+qy62B//kvVBUU65/bx+kxhA= sha256:jGTPFOHnbmWH0tXzAVwgBhX9HSvWwG0quP6TRJrR1K8= sha1:jYWYXg+WIvIG51A/oweGKtCJ38s= sha256:aWSngdTX1Y0gTfqDxnfBz/72OMwswjsnLjUwTsp/prA=
Xref csiph.com comp.lang.python:197880

Show key headers only | View raw


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.

Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

I need a basic tutorial for GUI creation using Cambalache Chris Green <cl@isbd.net> - 2026-08-12 09:26 +0100
  Re: I need a basic tutorial for GUI creation using Cambalache Lawrence D’Oliveiro <ldo@nz.invalid> - 2026-08-12 21:47 +0000
    Re: I need a basic tutorial for GUI creation using Cambalache Jon Ribbens <jon+usenet@unequivocal.eu> - 2026-08-12 22:23 +0000
    Re: I need a basic tutorial for GUI creation using Cambalache Lawrence D’Oliveiro <ldo@nz.invalid> - 2026-08-13 08:30 +0000
  Re: I need a basic tutorial for GUI creation using Cambalache Piergiorgio Sartor <piergiorgio.sartor.this.should.not.be.used@nexgo.REMOVETHIS.de> - 2026-08-24 10:30 +0200

csiph-web