Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #197879 > unrolled thread
| Started by | Chris Green <cl@isbd.net> |
|---|---|
| First post | 2026-08-12 09:26 +0100 |
| Last post | 2026-08-24 10:30 +0200 |
| Articles | 5 — 4 participants |
Back to article view | Back to comp.lang.python
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
| From | Chris Green <cl@isbd.net> |
|---|---|
| Date | 2026-08-12 09:26 +0100 |
| Subject | I need a basic tutorial for GUI creation using Cambalache |
| Message-ID | <uantkm-bbj1.ln1@q957.zbmc.eu> |
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 ·
[toc] | [next] | [standalone]
| From | Lawrence D’Oliveiro <ldo@nz.invalid> |
|---|---|
| Date | 2026-08-12 21:47 +0000 |
| Message-ID | <115ipm1$15btq$1@dont-email.me> |
| In reply to | #197879 |
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.
[toc] | [prev] | [next] | [standalone]
| From | Jon Ribbens <jon+usenet@unequivocal.eu> |
|---|---|
| Date | 2026-08-12 22:23 +0000 |
| Message-ID | <slrn117psjb.8e8.jon+usenet@raven.unequivocal.eu> |
| In reply to | #197880 |
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>
'''
[toc] | [prev] | [next] | [standalone]
| From | Lawrence D’Oliveiro <ldo@nz.invalid> |
|---|---|
| Date | 2026-08-13 08:30 +0000 |
| Message-ID | <115jvb1$1fu8e$1@dont-email.me> |
| In reply to | #197880 |
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 ...
[toc] | [prev] | [next] | [standalone]
| From | Piergiorgio Sartor <piergiorgio.sartor.this.should.not.be.used@nexgo.REMOVETHIS.de> |
|---|---|
| Date | 2026-08-24 10:30 +0200 |
| Message-ID | <n1ctlm-p84.ln1@lazy.lzy> |
| In reply to | #197879 |
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
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web