|
Post by barryk on Aug 16, 2022 17:51:53 GMT 1
Hi, I have just now tried one of the GUI examples: www.basic-converter.org/gui/User_input_graphical.bacIt compiles: # bacon User_input_graphical.bac This does not compile: # bacon -d build User_input_graphical.bac Converting 'User_input_graphical.bac'... done, 25 lines were processed in 0.001 seconds. Creating lexical analyzer... done. Compiling 'User_input_graphical.bac'... cc `pkg-config --cflags gtk+-3.0` -c User_input_graphical.bac.c User_input_graphical.bac:25:10: fatal error: build/User_input_graphical.bac.gui.h: No such file or directory
|
|
|
Post by bigbass on Aug 16, 2022 19:08:53 GMT 1
hello barryk
(I don't have a x86 box to test on but)
Yes, it's a bug / glitch with the new GUI I get the same output as you on the rpi3
because even this works fine with cli and gtk taking it directly from the website and builds correctly in a new directory
bacon -d build http://www.basic-converter.org/sinus.bac
bacon -d build http://www.basic-converter.org/dpi.bac
Joe
|
|
|
Post by barryk on Aug 17, 2022 1:11:44 GMT 1
I've been out of the loop for awhile, and didn't know anything about this new gui. My knowledge is with using HUG to create simple GUIs.
The example, User_inputPgraphical.bac, has these lines of code:
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\" }")
This looks great, but I hunted around, can't find where those widgets are documented.
I have seen the description of GUIDEFINE in the 4.5.1 beta documentation, but it doesn't say much.
Is that because it is a work-in-progress?
|
|
|
Post by bigbass on Aug 17, 2022 1:49:56 GMT 1
hello barryk there is another GUI for bacon as you know HUG works with gtk2 and still works but the new GUI "gui-proxy" works with gtk2 and gtk3 the syntax is very different but after seeing a few working demos it's faster then reading any docs first page just as a reference to when this started basic-converter.proboards.com/thread/1149/new-feature-gui-proxy-baconThe start of the gtk examples there are many demos to sort through and test this is on page 4 almost at the end of the page basic-converter.proboards.com/post/13109I'm sure Peter will point to any docs or added info have fun Joe
|
|
|
Post by Pjot on Aug 17, 2022 6:16:56 GMT 1
Hi Barry, This does not compile: # bacon -d build User_input_graphical.bac Converting 'User_input_graphical.bac'... done, 25 lines were processed in 0.001 seconds. Creating lexical analyzer... done. Compiling 'User_input_graphical.bac'... cc `pkg-config --cflags gtk+-3.0` -c User_input_graphical.bac.c User_input_graphical.bac:25:10: fatal error: build/User_input_graphical.bac.gui.h: No such file or directory Well, that is embarrassing indeed ...however, the fix was easy and can be obtained from here where there is a ZIP or tarball available. Regarding your question on documentation, this is still one of the things on my TODO list. Basically, the idea is that there are no predefined widgets in BaCon. The GUI functions are kind of a generic doorway to different GUI toolkits which allow the programmer to define more sophisticated GUI's compared to the somewhat limited HTML forms model of HUG. The approach is to look at a GUI in terms of "objects" and their "properties", the naming of which depends on the used toolkit. For example, the width in a Xaw widget is called "XtNwidth" while in GTK it is called "width-request". The GUI definition itself then should be written in a descriptive definition, with "type", "name", "parent" and "callback" as main keywords, and in which their toolkit depending properties also can be set. As mentioned, I should document this better, but hopefully the GUI programs in the GUI directory provide some good examples on how it works, as well as the aforementioned link pointed to by Joe. Best regards Peter
|
|
|
Post by barryk on Aug 17, 2022 12:27:44 GMT 1
|
|
|
Post by alexfish on Aug 21, 2022 20:55:58 GMT 1
Hi All & at Barry
Here have taken the original code + added the callback for spin 'type=SPIN_BUTTON name=spin parent=box margin=4 callback=value-changed numeric=TRUE' as a reference to generic HUG one can look at the hug widgets (signal) and the CALLBACK spin signal = 6
SUB CALLBACK (NUMBER hug_widget, void* hug_addr)
LOCAL signal
signal = hug_widget_signal(STR$(hug_widget))
SELECT signal CASE -1 g_signal_connect_data(hug_widget_s_widget(STR$(hug_widget)), hug_widget_external_signal$(STR$(hug_widget)), hug_addr, 0, 0, 0) CASE 1 g_signal_connect_data(hug_widget_s_widget(STR$(hug_widget)), "show", hug_addr, 0, 0, 0) CASE 2 g_signal_connect_data(hug_widget_s_widget(STR$(hug_widget)), "clicked", hug_addr, 0, 0, 0) CASE 3 g_signal_connect_data(hug_widget_s_widget(STR$(hug_widget)), "activate", hug_addr, 0, 0, 0) CASE 4 g_signal_connect_data(hug_widget_s_widget(STR$(hug_widget)), "button-press-event", hug_addr, 0, 0, 0) CASE 5 g_signal_connect_data(hug_widget_s_widget(STR$(hug_widget)), "changed", hug_addr, 0, 0, 0) CASE 6 g_signal_connect_data(hug_widget_s_widget(STR$(hug_widget)), "value-changed", hug_addr, 0, 0, 0) CASE 7 g_signal_connect_data(hug_widget_s_widget(STR$(hug_widget)), "response", hug_addr, 0, 0, 0) CASE 8 g_signal_connect_data(hug_widget_s_widget(STR$(hug_widget)), "set-focus-child", hug_addr, 0, 0, 0) CASE 9 g_signal_connect_data(hug_widget_s_widget(STR$(hug_widget)), "insert-text", hug_addr, 0, 0, 0) DEFAULT PRINT "WARNING: Cannot setup callback for hug_widget!" END END SELECT
END SUB
+ check the events within the main loop
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 callback=value-changed 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) IF event$ = "entry" THEN CALL GUIGET(gui, "entry", "text", &text) PRINT text FORMAT "Entered: %s\n" END IF
IF event$ = "spin" THEN CALL GUIGET(gui, "spin", "value", &data) PRINT data FORMAT "Entered: %g\n" END IF
IF event$ = "button" THEN PRINT "Button Click Exit" END END IF
UNTIL event$ = "window"
ADDED ; changing properties of button label
at the button event can try
IF event$ = "button" THEN PRINT "Button Click Exit" CALL GUISET(gui, "button", "label" ,"Clicked") 'END END IF
As regards getting a hug type TEXT(widget) then name convention is easy
see the following Code Entry widget Specific
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_1 parent=box margin=4 callback=activate } \ { type=ENTRY name=entry_2 parent=box margin=4 callback=activate } \ { type=SPIN_BUTTON name=spin parent=box margin=4 callback=value-changed numeric=TRUE } \ { type=BUTTON_BOX name=bbox parent=box } \ { type=BUTTON name=button parent=bbox margin=4 callback=clicked label=\"Exit\" }") CALL GUISET(gui, "box", "expand",1) CALL GUISET(gui, "spin", "adjustment", gtk_adjustment_new(75000, 0, 100000, 1, 1, 0))
REPEAT event$ = GUIEVENT$(gui) PRINT "Event =" ,event$ IF INSTR(event$,"entry") THEN CALL GUIGET(gui, event$, "text", &text) PRINT text FORMAT "Entry Text: %s\n" END IF
UNTIL event$ = "window"
BR Alex
|
|
|
Post by alexfish on Aug 22, 2022 0:29:16 GMT 1
And so To example , since no docs as yet , For GTK one can also reference on how to TEXT a widget , look at hug.bac TEXT FUNCTION SUB TEXT(NUMBER hug_widget, STRING hug_text$) Simple Bit of Code 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_1 parent=box margin=4 callback=activate } \ { type=ENTRY name=entry_2 parent=box margin=4 callback=activate } \ { type=SPIN_BUTTON name=spin_1 parent=box margin=4 callback=value-changed numeric=TRUE } \ { type=BUTTON_BOX name=bbox parent=box } \ { type=BUTTON name=button_1 parent=bbox margin=4 callback=clicked label=\"Button\" } \ { type=BUTTON name=button_2 parent=bbox margin=4 callback=clicked label=\"Exit\" }") CALL GUISET(gui, "box", "expand",1) CALL GUISET(gui, "spin_1", "adjustment", gtk_adjustment_new(75000, 0, 100000, 1, 1, 0))
REPEAT event$ = GUIEVENT$(gui) PRINT "Event =" ,event$ IF INSTR(event$,"entry") THEN CALL GUIGET(gui, event$, "text", &text) PRINT text FORMAT "Entry Text: %s\n" END IF
IF INSTR(event$,"button") THEN IF event$ = "button_1" THEN CALL GUISET(gui, event$, "label" ,"Clicked") END IF
IF event$ = "button_2" THEN END END IF END IF IF INSTR(event$,"spin") THEN CALL GUIGET(gui, event$, "value", &data) PRINT data FORMAT "Entered: %g\n" END IF
UNTIL event$ = "window"
That's A wrap: RE GTK Have Fun + BR Alex PS as regards the gtk widgets (signals & properties) etc , and easy to Follow Look HEREADDED If a case arises in the context , compile will show a warning an DO YOU Mean , case in exaple 'GTK TEXTVIEW' HERE is final bit of code with TEXTVIEW OPTION GUI TRUE PRAGMA GUI gtk3
DECLARE text TYPE STRING DECLARE data TYPE FLOATING
gui = GUIDEFINE(" \ { type=WINDOW name=window callback=delete-event title=\"TEXT VIEW\" width-request=300 height-request=300} \ { type=GTK_TYPE_TEXT_VIEW name=edit_1 parent=window }")
REPEAT event$ = GUIEVENT$(gui)
UNTIL event$ = "window"
after test then we Know the Short Version OPTION GUI TRUE PRAGMA GUI gtk3
DECLARE text TYPE STRING DECLARE data TYPE FLOATING
gui = GUIDEFINE(" \ { type=WINDOW name=window callback=delete-event title=\"TEXT VIEW\" width-request=300 height-request=300} \ { type=TEXT_VIEW name=edit_1 parent=window }")
REPEAT event$ = GUIEVENT$(gui)
UNTIL event$ = "window"
Attachments:
|
|