The time now is Mon 23 Apr 2018, 19:44
All times are UTC - 4 |
Author |
Message |
MU

Joined: 24 Aug 2005 Posts: 13648 Location: Karlsruhe, Germany
|
Posted: Sun 25 Feb 2007, 20:28 Post subject:
gins and Puppybasic = Visual Puppybasic Subject description: Using Glade to create Basic programs with the mouse |
|
Here is the exampleprogram Barry supplied with gins rewritten in Puppybasic.
see:
http://www.puppyos.net/blog/comments.php?y=07&m=02&entry=entry070224-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: | #!/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
|
Last edited by MU on Sun 25 Feb 2007, 21:01; edited 9 times in total
|
Back to top
|
|
 |
MU

Joined: 24 Aug 2005 Posts: 13648 Location: Karlsruhe, Germany
|
Posted: Sun 25 Feb 2007, 20:30 Post subject:
|
|
test.glade (made no changes, just to keep the code together)
Code: | <?xml version="1.0" standalone="no"?> <!--*- mode: xml -*-->
<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd">
<glade-interface>
<widget class="GtkWindow" id="window1">
<property name="width_request">209</property>
<property name="height_request">88</property>
<property name="visible">True</property>
<property name="title" translatable="yes">window1</property>
<property name="type">GTK_WINDOW_TOPLEVEL</property>
<property name="window_position">GTK_WIN_POS_NONE</property>
<property name="modal">False</property>
<property name="resizable">False</property>
<property name="destroy_with_parent">False</property>
<property name="decorated">True</property>
<property name="skip_taskbar_hint">False</property>
<property name="skip_pager_hint">False</property>
<property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property>
<property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
<signal name="event" handler="gins" last_modification_time="Fri, 31 Dec 2004 11:52:39 GMT"/>
<child>
<widget class="GtkVBox" id="vbox1">
<property name="visible">True</property>
<property name="homogeneous">True</property>
<property name="spacing">0</property>
<child>
<widget class="GtkLabel" id="label1">
<property name="visible">True</property>
<property name="label" translatable="yes">label1</property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkEntry" id="entry1">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="editable">True</property>
<property name="visibility">True</property>
<property name="max_length">0</property>
<property name="text" translatable="yes"></property>
<property name="has_frame">True</property>
<property name="invisible_char" translatable="yes">*</property>
<property name="activates_default">False</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkButton" id="button1">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label">gtk-ok</property>
<property name="use_stock">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
</widget>
</child>
</widget>
</glade-interface>
|
|
Back to top
|
|
 |
MU

Joined: 24 Aug 2005 Posts: 13648 Location: Karlsruhe, Germany
|
Posted: Sun 25 Feb 2007, 21:12 Post subject:
|
|
Works even shorter, you don't need the "myflag".
This file is needed only once, you don't need to change it:
gins.inc
Code: |
//----------------------------------------------
// 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
|
Now this is the only script you need to modify for own projects:
test2.pb
Code: | #!/usr/bin/puppybasic
include "/usr/lib/wxbasicscript/basefunctions.inc"
include "gins.inc"
// this test must be run with GINS:
// gins ./test2.pb
// add your own event-handlers in it.
//------------------------------------
// use "echo()" to print to console
// use "print" to send commands to gins
//-- some general variables needed in every script
gladefile = "test.glade"
windowtitle = "GINS Test 1"
echo ("GINS test script")
print "[OPEN]"
print gladefile
print "[SET]\nwindow1\ntitle\n" & windowtitle & "\n<str>"
print "[SET]\nlabel1\nlabel\nInput a new window title:\n<str>"
//------------
// Eventloop
while 1
//-- receive events sent by the window
obj , event , pdata = events()
// uncomment this line to see all events
// echo (obj & " " & event & " " & pdata)
//-- handle when window is closed
if obj = "window1" then
if event = "GDK_DELETE" then
print "[QUIT]"
end
end if
end if
//-- handle when button was clicked
if obj = "button1" then
if event = "GDK_BUTTON_RELEASE" then
print "[GET]\nentry1\ntext\n<str>\n"
obj , event , pdata = events()
print "[SET]\nwindow1\ntitle\n" & pdata & "\n<str>"
end if
end if
wend
|
|
Back to top
|
|
 |
basd
Joined: 31 Aug 2007 Posts: 24
|
Posted: Thu 01 Nov 2007, 14:25 Post subject:
[somewhat off-topic] asm/io.h and compiling GINS? |
|
Hi everyone,
I don't know if anyone can help me out with a non-Puppy problem. I'm trying to compile GINS on OpenSUSE 10.3. The "make" process fails, looking for asm/io.h. I do have the kernel headers installed and many other "source" packages, but I have not been able to identify the reason GINS will not locate asm/io.h.
I tried linking my /usr/include/linux/io.h file to /usr/include/asm/. However, that merely generated a number of new problems. It seems to me there is a directory that should be in the "make" path that is not there. Searching for "io.h" I find numerous such files and I have no idea which (and which directory tree) should be used to compile GINS. (Or if, indeed, I am missing yet another set of sources ...)
Thanks for any help you can offer!
My efforts with Puppy Linux have been temporarily stalled while I work with an OpenSUSE 10.3 install. I'm working toward solving some of the "business user" issues that confront me for Puppy, and in particular pdfedit and gscan2pdf (or scanning to pdf in general).
GINS now looks highly relevant. I like gscan2pdf a great deal, but it seems to be a large perl program that is a front-end for various other programs, such as sane and unpaper.
I can write scripts that will do a good deal of what I want to do scanning-wise. However, it would be nice to have a simple GUI frontend to the scripts to allow some variables to be entered interactively.
My experimentation so far has been in the OpenSUSE install, and then I hope to transfer what I learn over to my Puppy install (which as you know, runs a whole lot faster ...)
_________________ Everything I know about Puppy http://daltrey.org/tw/tiki-index.php?page=Puppy+Linux
|
Back to top
|
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|