see:
http://www.puppyos.net/blog/comments.ph ... 224-201929
http://www.puppyos.net/forum/azbb.php?1172392169
Mark
test.pb
creates a window with a input field.
Uses a XML file created with the GUI-Designer Glade to build the window.
If you enter something and click on the "ok" button, the window-title is set with your entered text.
The script just handles the events
Code: Select all
#!/usr/bin/puppybasic
include "/usr/lib/wxbasicscript/basefunctions.inc"
//# this test must be run with GINS:
//# gins ./test.pb
//------------------------------------
// use "echo()" to print to console
// use "print" to send commands to gins
echo ("GINS test script")
print "[OPEN]"
print "test.glade"
print "[SET]\nwindow1\ntitle\nGINS Test 1\n<str>"
print "[SET]\nlabel1\nlabel\nInput a new window title:\n<str>"
myflag = 0
//------------
// Eventloop
while 1
//-- receive events sent by the window
obj , event , pdata= events()
// uncomment this line to see all events
// echo (obj & " " & event & " " & pdata)
if obj = "window1" then
if event = "GDK_DELETE" then
print "[QUIT]"
end
end if
end if
if obj = "[gins]" then
if event = "OK" then
if myflag = 1 then
//echo(myflag & " " & pdata)
print "[SET]\nwindow1\ntitle\n" & pdata & "\n<str>"
myflag = 0
end if
end if
end if
if obj = "button1" then
if event = "GDK_BUTTON_RELEASE" then
//echo("test0")
print "[GET]\nentry1\ntext\n<str>\n"
myflag = 1
end if
end if
wend
//----------------------------------------------
// HELPER-Functions for gins
//
//--------------------------------------------------
//-- read 3 values from stdin seperated by spaces
//-- and return them in 3 string variables
function events ()
gins_thelist = xwin_system("read a b c; echo -e $a $b $c")
gins_thelist2 = explode(gins_thelist[0] , " ")
gins_thelist = {} //destructor
gins_a = gins_thelist2[0]
gins_b = gins_thelist2[1]
gins_c = trim(gins_thelist2[2])
gins_thelist2 = {} //destructor
return gins_a, gins_b, gins_c
end function
//---------------------------------
//-- print to console using stderr
function echo( gins_thestring)
xwin_system("echo -e '" & gins_thestring & "' 1>&2")
end function