BaCon Bits

For discussions about programming, programming questions/advice, and projects that don't really have anything to do with Puppy.
Post Reply
Message
Author
User avatar
GatorDog
Posts: 138
Joined: Tue 12 Sep 2006, 16:43

Video-Play

#12 Post by GatorDog »

Video-Play - A BaCon example program.
This program is mainly an example of using the FILEDIALOG file browser.

Features:
- Use the filebrowser to pick the video file to play.
- Edit the Mplayer command line and click "Play" to try it out.
- Clicking "Close" or "Play" saves the edited command line and
filename. They will be reloaded the next time Video-Play is run.
- "Restore Default" restores the original Mplayer command line.
- "Cancel" exit/quit.
These are the filtered filetypes:
avi, AVI, aaf, AAF, amv, AMV, amx, arf, asf, , ASF, asx, avs, AVS
bsf, cpi, d2v, dat, divx DIVX, dmb, dpg, dv-avi, dvdmedia, dvr, dvr-ms
dvx, DVX, f4v, flv, FLV, gvi, gvp, h264, hdmov, ifo, k3g, m2t, m2ts
m2v, m4v, mgv, mjp, mkv, mnv, mod, moov, mov, MOV, mp4, MP4, mpeg
MPEG, mpg, MPT, mpv, msdvd, mts, ogv, pgi, pmf, pva, qt, qtm, rm, rv
swf, SWF, tivo, vid, vob, VOB, vro, webm, wmv, WMV, wtv, xvid, yuv
264, 3gp, 3g2
video-play-sa.tar.gz is compiled standalone app. It should not require devx.sfs
video-play.bac.tar.gz is the BaCon source file.

rod
Attachments
video-play-sa.tar.gz
Compiled app video-play
(42.24 KiB) Downloaded 863 times
video-play.bac.tar.gz
BaCon source for video-play
(2.77 KiB) Downloaded 975 times

User avatar
GatorDog
Posts: 138
Joined: Tue 12 Sep 2006, 16:43

HKP - Hug Keyword Parser

#13 Post by GatorDog »

This program is an example of using EDITDIALOG, MSGDIALOG & FILEDIALOG.

If you use hug_imports.bac while developing and want the final app
to use hug.bac, keyword_list...

Hug Keyword Parser - Parses a Bacon source.bak file for HUG keywords.
Displays a new INCLUDE "/path/hug.bac", list_of_keywords In an Edit window.
Then you can copy/paste the Include line into your program.

rod

Edit: I'm using BaCon GUI v 1.0.24 / hug.bac v.61+

- Latest Version 2.1 source attached. Added Direct Import statements from hug_imports.bac
Attachments
hkp-2.1.png
(48.61 KiB) Downloaded 1062 times
HKP-HugKeywordParser-2.1.tar.gz
HKP 2.1 Bacon source
(6.57 KiB) Downloaded 785 times
hkp.tar.gz
Hug Keyword Parser source 1.0r1
(4.52 KiB) Downloaded 918 times
Last edited by GatorDog on Thu 03 Nov 2011, 12:34, edited 1 time in total.

User avatar
vovchik
Posts: 1507
Joined: Tue 24 Oct 2006, 00:02
Location: Ukraine

hug keyword parser

#14 Post by vovchik »

Dear Rod,

Nice job. It is immediately useful. Thanks.

With kind regards,
vovchik

User avatar
sunburnt
Posts: 5090
Joined: Wed 08 Jun 2005, 23:11
Location: Arizona, U.S.A.

#15 Post by sunburnt »

I read in the forum that Barry has included BaCon in Puppy.
I`m running 5.11, which version has it?

I noticed at the BaCon web site a lot of addons, some for GTK+.
BaCon could turn out to be a good replacement for gtkDialog.
# Addendum: Looking at the GTK+ examples, it`s very code intensive.
# A converter needs to be written in BaCon to reduce the required code.

User avatar
GatorDog
Posts: 138
Joined: Tue 12 Sep 2006, 16:43

#16 Post by GatorDog »

Hi sunburnt,

As far as I know, 511 should have BaCon in the 511 DEVX package.
For starters check out this-
http://bkhome.org/bacon/index.html

I've been using BaCon GUI to edit/compile/run as opposed to the
command line compiler (bacon) and a text editor. The gui is great.

I'm running pup 525. Some of the Bacon in the DEVX is getting a little
crispy. Some of the apps above need the latest bacon related files. I'll
attach the current files.

The DEVX package sets up the Bacon files in /usr/share/BaCon .
Put these files there: hug.bac, hug_imports.bac and hug.so .
You can put bacon and bacongui in you search path. I just made a
bacon directory, put bacon / bacongui in there and do developement
from that directory.

If you put the hug.so in a different directory, you'll need to edit the
top of hug_imports.bac to reflect the different path.

for ref hug.bac / hug.so are v.61 and bacongui 1.0.24beta

bacongui.bac and bacon.bac are the source files. When you have the
DEVX package loaded, compile them with "bacon bacon.bac"
and "bacon bacongui.bac"
# Addendum: Looking at the GTK+ examples, it`s very code intensive.
If your talking about making the cool GUI's, that is what HUG is for (hug.bac etc.)


Hopefully that will get you started.

rod
Attachments
bacon_files.tar.gz
bacon / bacongui 1.0.24beta
hug.bac, hug.so .61
hug_imports.bac current
(167.11 KiB) Downloaded 1023 times

User avatar
sunburnt
Posts: 5090
Joined: Wed 08 Jun 2005, 23:11
Location: Arizona, U.S.A.

#17 Post by sunburnt »

Thanks GatorDog; BaCon has a lot of potential, If it can GUIs without lots of code... Great!

User avatar
GatorDog
Posts: 138
Joined: Tue 12 Sep 2006, 16:43

Hello Bacon (World)

#18 Post by GatorDog »

sunburnt wrote: BaCon has a lot of potential, If it can GUIs without lots of code... Great!
Here's the classic Hello Bacon (World ;) )

Code: Select all

' BaCon / HUG  Hello World

INCLUDE "/usr/share/BaCon/hug_imports.bac"
INIT

Mainwin = WINDOW( "Hello Title Bar", 250, 100 )

My_label = MARK( "Hello BaCon!", 150, 30 )
ATTACH( Mainwin, My_label, 50, 20 )

My_btn = BUTTON( "I'm done", 80, 25)
ATTACH( Mainwin, My_btn, 85, 60 )

CALLBACK( My_btn, QUIT)

My_chk = CHECK( "Nada", 50, 25 )
ATTACH( Mainwin, My_chk, 175, 60 )

' Make it so! (A little Star Trek lingo :-)
DISPLAY
You start with the main window, then start making widgets.
Use x,y co-ords to place them on the window and away you go.

rod
Attachments
hello_bacon.png
Hello Bacon
(7.36 KiB) Downloaded 1825 times

User avatar
GatorDog
Posts: 138
Joined: Tue 12 Sep 2006, 16:43

Hello Bacon (World)

#19 Post by GatorDog »

Here is a commented version-

Code: Select all

' BaCon / HUG  Hello World

' Include the files for making a GUI.
INCLUDE "/usr/share/BaCon/hug_imports.bac"
INIT

' Create your main working window, 250 pixels wide x 100 pixels high
Mainwin = WINDOW( "Hello Title Bar", 250, 100 )

' Create a label with text, 150 x 30
My_label = MARK( "Hello BaCon!", 150, 30 )

' Attach the label to the main window 
' at coordinates 50x 20y from top left corner
ATTACH( Mainwin, My_label, 50, 20 )

' Make a button
My_btn = BUTTON( "I'm done", 80, 25)

' Attach button to window
ATTACH( Mainwin, My_btn, 85, 60 )

' Make button do something
CALLBACK( My_btn, QUIT)

' Create a checkbox widget.
My_chk = CHECK( "Nada", 50, 25 )
ATTACH( Mainwin, My_chk, 175, 60 )

' Make it so! (A little Star Trek lingo :-)
DISPLAY

User avatar
sunburnt
Posts: 5090
Joined: Wed 08 Jun 2005, 23:11
Location: Arizona, U.S.A.

#20 Post by sunburnt »

Thanks GatorDog; Actually your first example was so easy to understand...
The only Q was what the numbers were setting. But that`s obvious.

The window and the control statements have their sizes set.
The ATTACH statements set the screen positions relative to the window.
CALLBACK is the button action and DISPLAY is the whole window action.

The ATTACH statements seem unnecessarily overdone.
A less wordy and typing intensive method:

Code: Select all

My_btn = BUTTON( "I'm done", 80, 25, Mainwin, 85, 60 )
Just specify everything in one statement, less repetition of words.
Words and typing saved: ATTACH, My_btn, and the extra set of ( ).
Nit-picky I know... But I look at things from an engineering view. KISS. :lol:

Q: Apparently a Label is called a MARK? ( My_label = MARK ) Seems so...

This appears to be much closer to the syntax I`ve had in mind.
And BaCon takes this code and produces C executables from it, very nice!
Executables instead of shell scripts to describe and generate GUIs. Great!
The GUIs are bound to be way faster than Bash scrip for sure.

I`ll be taking a serious look at this, I may have more Qs for youGatorDog...

User avatar
GatorDog
Posts: 138
Joined: Tue 12 Sep 2006, 16:43

Extending "Hello BaCon"

#21 Post by GatorDog »

To add a couple of elements to the example.

- STOCK(.....) creates a button using the built in 'icon and text' buttons. ex Quit, Close, etc.
List of built in buttons Built in buttons

- Create a SUB routine()

- Execute the SUB when the button is clicked

Code: Select all

' BaCon / HUG  Hello World
' With SUB routine example

INCLUDE "/usr/share/BaCon/hug_imports.bac"
INIT

' ******************
' SUBS & FUNCTIONS
' ******************
SUB CHANGE_MY_TEXT()
	' TEXT changes the text of a widget/My_label
	TEXT( My_label, "Goodbye BaCon")
END SUB

' ******************
' END SUBS & FUNCTIONS
' ******************

' Create your main working window, 250 pixels wide x 100 pixels high
Mainwin = WINDOW( "Hello Title Bar", 250, 100 )

' Create a label with text, 150 x 30
My_label = MARK( "Hello BaCon!", 150, 30 )

' Attach the label to the main window 
' at coordinates 50x 20y from top left corner
ATTACH( Mainwin, My_label, 50, 20 )

' --- BUTTONS ---
My_btn = BUTTON( "Change text", 100, 25)
ATTACH( Mainwin, My_btn, 5, 60 )

' Make an exit button
My_close = STOCK("gtk-close", 100, 25)
ATTACH(Mainwin, My_close, 140, 60)

' --- CALLBACKS ---
CALLBACK( My_btn, CHANGE_MY_TEXT)
CALLBACK( My_close, QUIT)

' Make it so! (A little Star Trek lingo :-)
DISPLAY
rod
Attachments
hello_bacon.png
(25.48 KiB) Downloaded 1132 times

User avatar
sunburnt
Posts: 5090
Joined: Wed 08 Jun 2005, 23:11
Location: Arizona, U.S.A.

#22 Post by sunburnt »

Excellent !!!
Q: Is there a good IDE or editor, I noticed several at BaCon.

Also I saw that a compiled version of BaCon can run the Basic files directly.
This means a Visual Basic type of IDE to make GUIs could be built !!!

User avatar
GatorDog
Posts: 138
Joined: Tue 12 Sep 2006, 16:43

BaConGUI - IDE

#23 Post by GatorDog »

Q: Is there a good IDE or editor, I noticed several at BaCon.
I think the answer to that is BaconGUI.
- Write/edit/compile/execute etc.
- Keyword highlighting
- etc.

I haven't tried TinyIDE. Looks like a good option if you're working with limited
system resources.

rod

User avatar
sunburnt
Posts: 5090
Joined: Wed 08 Jun 2005, 23:11
Location: Arizona, U.S.A.

#24 Post by sunburnt »

Thanks Rod; I downloaded both, but thought I`d ask.

Terry

User avatar
sunburnt
Posts: 5090
Joined: Wed 08 Jun 2005, 23:11
Location: Arizona, U.S.A.

#25 Post by sunburnt »

Hey Rod; I posted for help getting Puppy to load the devx file, no answers.
I`m wondering what`s in it that`s needed. The dir.: /usr/lib/gcc ?
I noticed that Puppy already has the file: /lib/libgcc_s.so.1
( Maybe it`s not what`s needed at all... )

It appears I have no choice but to try to cobble the compiler together myself.

I downloaded the package for Debian as it has compiled files: bacon and bacongui.
Also the file bacon.bash.
Instead of the library: hug.so it has ".bac" files in: /lib/bacon.

User avatar
GatorDog
Posts: 138
Joined: Tue 12 Sep 2006, 16:43

#26 Post by GatorDog »

sunburnt

afaik, you need the bacon packages and a compiler such as gcc.

I think you'll want the bacon packages that I posted above. They
should have the latest features and updates. Although they're beta
I personally have not had any issues with them.

You can create hug.so from hug.bac. With bacongui it is very easy.
There is a bacon -option to do that but I haven't used it.

I'll attach a compiled bacon 1.0.24beta, which should work on puppy.
You'll probably need gcc available. Then you can roll you own with
bacon bacongui.bac etc.

rod
Attachments
bacon-1.0.24beta.tar.gz
(100.79 KiB) Downloaded 754 times

User avatar
sunburnt
Posts: 5090
Joined: Wed 08 Jun 2005, 23:11
Location: Arizona, U.S.A.

#27 Post by sunburnt »

Thanks Rod; I have the bacon executables: bacon and bacongui in /bin
The gui comes up and I loaded your example, click: tools > execute. Nothing.

As I said, Puppy already has: /lib/libgcc_s.so.1 ... Is this the C compiler?
And then there`s: /usr/lib/gcc/libgcc_s.so ... a link to the library above.

I just got it to convert your example but it errors with:

WARNING: 'cc' not found on this system!
Generated source code cannot be compiled.

Obviously the compiler is missing. Where is it in the SFS file and I can copy it?

User avatar
sunburnt
Posts: 5090
Joined: Wed 08 Jun 2005, 23:11
Location: Arizona, U.S.A.

#28 Post by sunburnt »

Got the devx file to load with the boot manager, use to be it`d load automatically.
So now theres cc but I see no sign of BaCon, good thing I installed it manually.

Your example now runs and compiles from bacongui !!! Thanks again!

User avatar
sunburnt
Posts: 5090
Joined: Wed 08 Jun 2005, 23:11
Location: Arizona, U.S.A.

#29 Post by sunburnt »

Rod; Q: Where can I get a list of the widgets supported by hug and docs on usage?
Of special interest is the TabPanel widget, it`s great at keeping GUI`s small.

Looks like this is a very good setup for Puppy dialogs.
Nice small executables that run much faster than Bash scripts!

User avatar
GatorDog
Posts: 138
Joined: Tue 12 Sep 2006, 16:43

Bacon & HUG Docs

#30 Post by GatorDog »

Hi Terry,
In Bacongui, click on Help / Documentation. Bacongui keeps a copy of the
bacon doc in /root/.bacon/documen...... It opens up in a browser tab.

I usually keep firefox up with these two urls opened.

Bacon doc http://www.basic-converter.org/documentation.html
HUG doc http://www.basic-converter.org/hugdoc.html

rod

Edit, I do not know what the difference is between cc an gcc, but I've been using gcc.

User avatar
sunburnt
Posts: 5090
Joined: Wed 08 Jun 2005, 23:11
Location: Arizona, U.S.A.

#31 Post by sunburnt »

Thanks again GatorDog; I don`t know why I didn`t find it the first time.
Looking at the docs it looks like it`s much more capable than gtkDialog.
It even has the old Basic drawing commands: circle, square, and pixel.
Can you say... Custom controls? :wink:

I signed up at the BaCon forum, see you there!

Post Reply