site  contact  subhomenews

BaCon has a new integrated GUI framework

August 17, 2022 — BarryK

I was very keen on the BaCon language, back around 2010 - 2011, and wrote some documentation, now archived:

https://bkhome.org/archive/bacon/

That link describes HUG, Highlevel Universal GUI, which is a very simple way to create little GUI apps. One shortcoming is that widgets can only be placed by fixed coordinates (relative to the window).

One utility that uses HUG and is still in EasyOS is 'popup'. Open a terminal, and type "popup" to see the required parameters. It does what the name suggests, very handy in scripts, and I use it a lot.

A few years ago, I lost interest in BaCon, as was having problems with cross-compiling in OpenEmbedded; however, these seem to be resolved:

https://bkhome.org/news/202208/the-return-of-bacon.html

I have been "out of the loop", not watching development of BaCon, and I have just discovered that they are working on something very interesting; a new integrated GUI framework. I compiled this little example:

OPTION GUI TRUE
PRAGMA GUI gtk3

DECLARE text TYPE STRING
DECLARE data TYPE FLOATING

gui = GUIDEFINE(" \
{ type=WINDOW name=window callback=delete-event title=\"Rosetta Code\" width-request=300 } \
{ type=BOX name=box parent=window orientation=GTK_ORIENTATION_VERTICAL } \
{ type=ENTRY name=entry parent=box margin=4 callback=activate } \
{ type=SPIN_BUTTON name=spin parent=box margin=4 numeric=TRUE } \
{ type=BUTTON_BOX name=bbox parent=box } \
{ type=BUTTON name=button parent=bbox margin=4 callback=clicked label=\"Exit\" }")

CALL GUISET(gui, "spin", "adjustment", gtk_adjustment_new(75000, 0, 100000, 1, 1, 0))

REPEAT
event$ = GUIEVENT$(gui)
UNTIL event$ = "button" OR event$ = "window"

CALL GUIGET(gui, "entry", "text", &text)
PRINT text FORMAT "Entered: %s\n"

CALL GUIGET(gui, "spin", "value", &data)
PRINT data FORMAT "Entered: %g\n"

Which reminds me, Geany has a plugin to export a file with colour syntax highlighting as HTML. That would be nice. Anyway, here is the little GUI window:

img1

Pretty simple looking code to create that, but what caught my attention is that it is also size-efficient; the binary executable is just 31KB. I didn't even do any optimizations, just ran "bacon User_input_graphic.bac", then "strip User_input_graphic".

I asked about this new GUI framework on the BaCon forum:

https://basic-converter.proboards.com/thread/1261/example-compile-fail-wrong-path

Joe (bigbass) replied with a couple of links:

https://basic-converter.proboards.com/thread/1149/new-feature-gui-proxy-bacon

And one post about GTK from that thread:

https://basic-converter.proboards.com/post/13109

I have uploaded the latest BaCon source to my repo:

https://distro.ibiblio.org/easyos/source/alphabetical/b/bacon-4.5.0.1.tar.gz

It is interesting that Peter (Pjot) has investigated giving libXaw and Motif a new lease of life.   

Tags: easy