From Newsgroup: comp.lang.python
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.
HererCOs 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 itrCOs 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) # donrCOt 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 didnrCOt
get any error message (that I could find), the returned Builder object
simply ended up with nothing in it.
--- Synchronet 3.22a-Linux NewsLink 1.2