Actions
Basic builder » History » Revision 5
« Previous |
Revision 5/7
(diff)
| Next »
iri, 02/22/2011 02:29 PM
Basic builder¶
It's a very simple interface built with GtkBuilder.
- add the file with _gtkBuilderNewFromFile
- if needed, get any included object (for example, a window, a button ...) with _gtkBuilderWidgetGet
- if needed, define any callback and others codes ...
- run the GTK+ loop.
Note : Don't call _gtkWidgetShow(All), all included widgets will be automatically shown.
Look this Scol code :
fun cbDestroy (obj, uparam)=
_fooS strcat "upram = " itoa uparam;
_gtkMainQuit;
0;;
fun cbButtonClicked (obj, uparam)=
_fooS strcat "button param = " uparam;
0;;
fun main ()=
_showconsole;
// add a .xml file
let _gtkBuilderNewFromFile _channel _checkpack "tests/2dgtk/0.glade" -> builder in
// get object from the builder : a window and a button
let _gtkBuilderWidgetGet builder "main_window" -> win in
let _gtkBuilderWidgetGet builder "button_1" -> button in
(
// define the callbacks
_gtkWindowCBdestroyed win @cbDestroy 10;
_gtkButtonCB button @cbButtonClicked "yes !" SCOL_GTK_BUTTON_CB_CLICKED;
// run the GTK+ loop
_gtkMain;
0
);;
and now, the xml file :
<?xml version="1.0"?>
<interface>
<requires lib="gtk+" version="2.16"/>
<!-- interface-naming-policy project-wide -->
<object class="GtkWindow" id="main_window">
<property name="visible">True</property>
<property name="title" translatable="yes">Test 2dGtk - 0</property>
<child>
<object class="GtkVBox" id="main_box">
<property name="visible">True</property>
<property name="spacing">5</property>
<child>
<object class="GtkButton" id="button_1">
<property name="label" translatable="yes">button 1</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
</object>
<packing>
<property name="position">0</property>
</packing>
</child>
</object>
</child>
</object>
</interface>
Return Examples
Updated by iri almost 14 years ago · 5 revisions