Page 6 of 27
Posted: Sun 14 Nov 2010, 18:13
by seaside
Mechanic,
Replace the function CAT(STRING FileName$): with....
Thanks, that is indeed somewhat different
Regards,
s
Posted: Sun 14 Nov 2010, 21:16
by PjotAwake
Hi jpeps,
As noted, the gtk demo from website also gave the error:
~ $ sudo bacon ./gtk-server-new.bac
Starting conversion... done.
Starting compilation... done.
Program './gtk-server-new' ready.
~ $ ./gtk-server-new
ERROR: signal for SEGMENTATION FAULT received - memory invalid or array out of bounds? Try to compile the program with TRAP LOCAL to find the cause.
It seems you are referring to the
GTK-server program? This is not a GTK demo, but a demo with the
GTK-server.
Did you actually install
GTK-server prior to running the BaCon program? Because for me this demo works fine.
Note that you will find actual GTK demo programs a little bit down below on the
BaCon website.
BTW why are you using 'sudo'?
Regards
Peter
Posted: Sun 14 Nov 2010, 22:28
by jpeps
ah...initially saw it in the gtk-demos dir of bacon.tar.gz, so thought it was independent.
Note that you will find actual GTK demo programs a little bit down below on the
BaCon website.
..just tried a few, everything working fine.
BTW why are you using 'sudo'?
As Barry says, it's like religion. I don't run in root. Thanks for the great work!
Posted: Sun 14 Nov 2010, 23:39
by big_bass
Screen size
Posted: Mon 15 Nov 2010, 09:10
by vovchik
Dear Puppians,
I banged this together to demonstrate how you you can use GDK/GTK libs in a CLI program in BaCon to obtain, for instance, the size of the display.
Code: Select all
' *************************************************************
' PROGRAM: screensize.bac
' PURPOSE: get X screen size in pixels from default display
' AUTHOR: vovchik (Puppy Linux forum)
' COMMENTS: GPL
' DEPENDS: bacon 1.0 build 0.19, gtk, gdk libs
' PLATFORM: Linux (actually, any *nix)
' DATE: 03-10-2010
' VERSION: 0.1a
' *************************************************************
' *********************
' DEF ERROR HANDER
' *********************
TRAP LOCAL
CATCH GOTO PRINT_ERROR
' *********************
' END DEF ERROR HANDER
' *********************
' *********************
' CONSTANTS
' *********************
CONST Gtk$ = "libgtk-x11-2.0.so.0"
CONST Gdk$ = "libgdk-x11-2.0.so.0"
' *********************
' END CONSTANTS
' ********************
' *********************
' DECLARATIONS
' *********************
DECLARE MyScreen$ TYPE STRING
' *********************
' END DECLARATIONS
' *********************
' *********************
' IMPORTS
' *********************
IMPORT "gtk_init(int*,void*)" FROM Gtk$ TYPE void
IMPORT "gtk_exit(int)" FROM Gtk$ TYPE void
IMPORT "gtk_window_get_size(long,int*,int*)" FROM Gtk$ TYPE void
IMPORT "gdk_screen_get_default" FROM Gdk$ TYPE long
IMPORT "gdk_screen_get_width(long)" FROM Gdk$ TYPE int
IMPORT "gdk_screen_height(long)" FROM Gdk$ TYPE int
' *********************
' END IMPORTS
' *********************
' *********************
' FUNCTIONS
' *********************
' ------------------
FUNCTION SCREENSIZE(NUMBER mode)
' ------------------
' mode = 0 returns x (width)
' mode = 1 returns y (height)
' mode = 2 returns space-delimited x (width) and y (height)
' otherwise function returns error message
LOCAL x, y TYPE int
LOCAL myresult$ TYPE STRING
y = gdk_screen_height(gdk_screen_get_default())
x = gdk_screen_get_width(gdk_screen_get_default())
SELECT mode
CASE 0
myresult$ = STR$(x)
CASE 1
myresult$ = STR$(y)
CASE 2
myresult$ = CONCAT$(STR$(x), " ", STR$(y))
DEFAULT
myresult$ = CONCAT$("Error: SCREENSIZE(", STR$(mode), ") mode is bad: 0 = w, 1 = h and 2 = h and w.")
END SELECT
RETURN CHOP$(myresult$)
END FUNCTION
' *********************
' END FUNCTIONS
' *********************
' *********************
' MAIN
' *********************
gtk_init(0, 0)
MyScreen$ = SCREENSIZE(0)
PRINT MyScreen$
MyScreen$ = SCREENSIZE(1)
PRINT MyScreen$
MyScreen$ = SCREENSIZE(2)
PRINT MyScreen$
MyScreen$ = SCREENSIZE(3)
PRINT MyScreen$
gtk_exit(0)
END
' *********************
' END MAIN
' *********************
' *********************
' ERROR HANDLER
' *********************
LABEL PRINT_ERROR
PRINT "GTK library ", Gtk$, " is not available on this platform!"
END
' *********************
' END ERROR HANDLER
' *********************
With kind regards,
vovchik
PS. Nice work, Joe.
PPS. Source and binary are in the attached archive.
Posted: Mon 15 Nov 2010, 14:53
by BarryK
Hey guys, my first GTK application written in BaCon!!!!!
http://bkhome.org/bacon/my-1st-gtk-app/index.html
I will be tweaking it a bit more, to get it integrated into Puppy, and with the network setup tools. It is expected to be in all future puppies.
Note, I'm not sure, but it might be necessary to also put this into /etc/wgetrc:
It was a fun experience.
Here is the binary executable, gunzip it, make sure it is executable and bung it somewhere in the path:
Posted: Mon 15 Nov 2010, 16:32
by esmourguit
Bonjour à tous,
I tested it in Toutou Linux 4.3.1, it seems to work. At least, it opens.
As it seems we're at the beginning of the creation (and maybe later adaptation of old scripts) of programs, written with bacon, for new versions of Wary, Quirky, etc., would it be possible to localize them now with a .mo file?
If possible of course.
Cordialement
Posted: Mon 15 Nov 2010, 22:23
by seaside
Barry,
Always nice to try something new....
I get the following problem of cut off characters, not only in your program, but in some of the gui demos as well. See below.
Regards,
s
Posted: Mon 15 Nov 2010, 22:44
by jpeps
Looking forward to a directory of examples using various widgets, which will save a huge amount of trial & error.
Posted: Tue 16 Nov 2010, 00:43
by BarryK
seaside wrote:Barry,
Always nice to try something new....
I get the following problem of cut off characters, not only in your program, but in some of the gui demos as well. See below.
Regards,
s
Vovchik has kindly looked through my code and made some refinements, including improving that problem with big fonts.
I will be updating the application soon.
Posted: Tue 16 Nov 2010, 01:48
by seaside
big_bass ,
Thanks for all that material on BaCon - it makes it very inviting to try out everything.
Also, perhaps a test of bash version would be useful in your script
Code: Select all
BASHV=$(bash --version)
VN=$(echo $BASHV | cut -f1 -d. | sed 's/^.*\(.\)$/\1/')
[ $VN -lt 4 ] && gxmessage -title "Bash Version Problem" -center -bg orange "$BASHV installed
---------------> Bash must be version 4 <-------------------" & exit
Barry & Vovchik,
Thanks for all your efforts.
Regards,
s
Posted: Tue 16 Nov 2010, 07:03
by jpeps
Any demos of hug radiobuttons? Looks like it should be similar to check buttons with an added group number, but I get segmentation errors after compiling. 'btn_1 = RADIO("text", x, y, grp)' Thanks in advance.
Raio buttons
Posted: Tue 16 Nov 2010, 09:11
by vovchik
Dear jpeps,
In my tests, radio buttons in HUG work exactly as advertised. Try this code:
Code: Select all
INCLUDE "hug.bac"
win_width = 200
win_height = 100
mainwin = WINDOW("Radio test", win_width, win_height)
my_radio1 = RADIO("On", 50, 30, my_radio2)
my_radio2 = RADIO("Off", 50, 30, my_radio1)
ATTACH(mainwin, my_radio1, 20, 20)
ATTACH(mainwin, my_radio2, 20, 50)
DISPLAY
With kind regards,
vovchik
Re: Raio buttons
Posted: Tue 16 Nov 2010, 11:01
by jpeps
vovchik wrote:Dear jpeps,
In my tests, radio buttons in HUG work exactly as advertised. Try this code:
Code: Select all
INCLUDE "hug.bac"
win_width = 200
win_height = 100
mainwin = WINDOW("Radio test", win_width, win_height)
my_radio1 = RADIO("On", 50, 30, my_radio2)
my_radio2 = RADIO("Off", 50, 30, my_radio1)
ATTACH(mainwin, my_radio1, 20, 20)
ATTACH(mainwin, my_radio2, 20, 50)
DISPLAY
With kind regards,
vovchik
Thanks vovchik,
And for a group? Specifically, I was looking at:
FUNCTION RADIO (STRING text$, int xsize, int ysize, NUMBER group)
(I did something similar using checkbuttons with a reset function)
Posted: Tue 16 Nov 2010, 14:03
by big_bass
Hey seaside
I used your suggestion and code for the bash test
I just converted it to Xdialog to keep the theme the same
and cut the message down a bit
thanks I will add it to the down loader, compiler, tester
*I added a credit comment to the script for you and mechanic
thanks
Joe
Code: Select all
BASHV=$(bash --version | head -1)
VN=$(echo $BASHV | cut -f1 -d. | sed 's/^.*\(.\)$/\1/')
[ $VN -lt 4 ] && Xdialog --title "bash version test " \
--infobox "\nBash Version Problem $BASHV installed
---------------> Bash must be version 4 or above for BaCon <-------------------" "\n" 0 0
Re: Raio buttons
Posted: Tue 16 Nov 2010, 15:57
by jpeps
jpeps wrote:vovchik wrote:Dear jpeps,
In my tests, radio buttons in HUG work exactly as advertised. Try this code:
Code: Select all
INCLUDE "hug.bac"
win_width = 200
win_height = 100
mainwin = WINDOW("Radio test", win_width, win_height)
my_radio1 = RADIO("On", 50, 30, my_radio2)
my_radio2 = RADIO("Off", 50, 30, my_radio1)
ATTACH(mainwin, my_radio1, 20, 20)
ATTACH(mainwin, my_radio2, 20, 50)
DISPLAY
With kind regards,
vovchik
Thanks vovchik,
And for a group? Specifically, I was looking at:
FUNCTION RADIO (STRING text$, int xsize, int ysize, NUMBER group)
(I did something similar using checkbuttons with a reset function)
This seems to work:
Code: Select all
INCLUDE "hug.bac"
win_width = 200
win_height = 100
mainwin = WINDOW("Radio test", win_width, win_height)
my_radio1 = RADIO("One", 50, 30, my_radio3)
my_radio2 = RADIO("Two", 50, 30, my_radio1)
my_radio3 = RADIO("Three", 50, 30, my_radio1)
ATTACH(mainwin, my_radio1, 20, 20)
ATTACH(mainwin, my_radio2, 20, 50)
ATTACH(mainwin, my_radio3, 20, 80)
DISPLAY
radio buttons
Posted: Tue 16 Nov 2010, 16:35
by vovchik
Dear jpeps,
I was hoping you would do just that. After posting and seeing your reply, I wrote the EXACT same code.
With kind regards,
vovchik
Re: radio buttons
Posted: Tue 16 Nov 2010, 17:22
by jpeps
vovchik wrote:Dear jpeps,
I was hoping you would do just that. After posting and seeing your reply, I wrote the EXACT same code.
With kind regards,
vovchik
Here's revised code for MyFavorites loader:
(note: points to my own programs, so edit)
http://jpeters.net/apps/MyPrograms2.txt
Posted: Tue 16 Nov 2010, 19:25
by 2lss
I gave the source code editor on basic-converter.org a shot and I liked it. So I decided to try adding a few features to make it more like an ide (similar to tinyide)
I added the ability to compile the code (Menu > Build > Compile) and the ability to execute the code ( Menu > Build > Execute).
There are a few issues with each though. When "compile" is clicked, it prompts the user to save the file. If the user clicks yes and the file has not been saved before it will bring up the 'save_as' dialog however, it will compile the code before the 'save' or 'cancel' button is clicked giving an error .
Clicking "execute" will launch xterm (if TERM=xterm) and execute the program. I'm not sure how to make this work with rxvt since it does not have a '-hold' option.
I originally wanted to pipe stdout into a text box widget instead of calling xterm but I was unable to get the pipe to work. Maybe someone else could find the problem. (lines 825 - 846)
Posted: Thu 18 Nov 2010, 12:29
by BarryK
Maybe you guys who are BaCon experts can see how this can be done elegantly....
In many shell scripts we have:
. /etc/rc.d/PUPSTATE
Where PUPSTATE is a file, which has something like this in it:
Code: Select all
PUPMODE=12
PDEV1='sr0'
DEV1FS='iso9660'
PUPSFS='sda7,ext3,/w0981011.143/wary_098.sfs'
PUPSAVE='sda7,ext3,/warysave-098.2fs'
PMEDIA='usbcd'
#kernel with libata pata has both sata and pata drives in ATADRIVES...
ATADRIVES='sda '
#these directories are unionfs/aufs layers in /initrd...
SAVE_LAYER='/pup_rw'
PUP_LAYER='/pup_ro2'
#The partition that has the warysave file is mounted here...
PUP_HOME='/mnt/dev_save'
#(in /initrd) ...note, /mnt/home is a link to it.
#this file has extra kernel drivers and firmware...
ZDRV='sda7,ext3,/w0981011.143/zw098114.sfs'
#complete set of modules in the initrd (moved to main f.s.)...
ZDRVINIT='no'
#Partition no. override on boot drive to which session is (or will be) saved...
PSAVEMARK=''
So the problem is how to read in each line in a BaCon program, ignoring comments, and assign those variables so they can be used in the program.
Unlike the INCLUDE operation in BaCon, this has to be a run-time evaluation. I can't quite see how to do it. I suppose an associative array? ...but I would really like to assign each variable independently.
Perhaps there is some obvious way to do it, and I just can't see the obvious.