Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Fri 28 Nov 2014, 07:13
All times are UTC - 4
 Forum index » Off-Topic Area » Programming
BaCon Bits
Post new topic   Reply to topic View previous topic :: View next topic
Page 2 of 12 [168 Posts]   Goto page: Previous 1, 2, 3, 4, ..., 10, 11, 12 Next
Author Message
GatorDog


Joined: 12 Sep 2006
Posts: 136

PostPosted: Fri 29 Jul 2011, 23:39    Post subject: Hello Bacon (World)  

sunburnt wrote:
BaCon has a lot of potential, If it can GUIs without lots of code... Great!


Here's the classic Hello Bacon (World Wink )
Code:

' 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
hello_bacon.png
 Description   Hello Bacon
 Filesize   7.36 KB
 Viewed   1512 Time(s)

hello_bacon.png

Back to top
View user's profile Send private message 
GatorDog


Joined: 12 Sep 2006
Posts: 136

PostPosted: Sat 30 Jul 2011, 09:49    Post subject: Hello Bacon (World)  

Here is a commented version-
Code:
' 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
Back to top
View user's profile Send private message 
sunburnt


Joined: 08 Jun 2005
Posts: 5042
Location: Arizona, U.S.A.

PostPosted: Sat 30 Jul 2011, 13:38    Post subject:  

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:
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. Laughing

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...
Back to top
View user's profile Send private message 
GatorDog


Joined: 12 Sep 2006
Posts: 136

PostPosted: Sat 30 Jul 2011, 15:04    Post subject: Extending "Hello BaCon"  

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:
' 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
hello_bacon.png
 Description   
 Filesize   25.48 KB
 Viewed   821 Time(s)

hello_bacon.png

Back to top
View user's profile Send private message 
sunburnt


Joined: 08 Jun 2005
Posts: 5042
Location: Arizona, U.S.A.

PostPosted: Sat 30 Jul 2011, 17:51    Post subject:  

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 !!!
Back to top
View user's profile Send private message 
GatorDog


Joined: 12 Sep 2006
Posts: 136

PostPosted: Sat 30 Jul 2011, 23:46    Post subject: BaConGUI - IDE  

Quote:
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
Back to top
View user's profile Send private message 
sunburnt


Joined: 08 Jun 2005
Posts: 5042
Location: Arizona, U.S.A.

PostPosted: Sun 31 Jul 2011, 00:45    Post subject:  

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

Terry
Back to top
View user's profile Send private message 
sunburnt


Joined: 08 Jun 2005
Posts: 5042
Location: Arizona, U.S.A.

PostPosted: Sun 31 Jul 2011, 16:57    Post subject:  

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.
Back to top
View user's profile Send private message 
GatorDog


Joined: 12 Sep 2006
Posts: 136

PostPosted: Sun 31 Jul 2011, 17:37    Post subject:  

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
bacon-1.0.24beta.tar.gz
Description 
gz

 Download 
Filename  bacon-1.0.24beta.tar.gz 
Filesize  100.79 KB 
Downloaded  452 Time(s) 
Back to top
View user's profile Send private message 
sunburnt


Joined: 08 Jun 2005
Posts: 5042
Location: Arizona, U.S.A.

PostPosted: Sun 31 Jul 2011, 21:20    Post subject:  

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?
Back to top
View user's profile Send private message 
sunburnt


Joined: 08 Jun 2005
Posts: 5042
Location: Arizona, U.S.A.

PostPosted: Sun 31 Jul 2011, 22:23    Post subject:  

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!
Back to top
View user's profile Send private message 
sunburnt


Joined: 08 Jun 2005
Posts: 5042
Location: Arizona, U.S.A.

PostPosted: Sun 31 Jul 2011, 22:40    Post subject:  

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!
Back to top
View user's profile Send private message 
GatorDog


Joined: 12 Sep 2006
Posts: 136

PostPosted: Mon 01 Aug 2011, 01:20    Post subject: Bacon & HUG Docs  

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.
Back to top
View user's profile Send private message 
sunburnt


Joined: 08 Jun 2005
Posts: 5042
Location: Arizona, U.S.A.

PostPosted: Mon 01 Aug 2011, 14:11    Post subject:  

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!
Back to top
View user's profile Send private message 
GatorDog


Joined: 12 Sep 2006
Posts: 136

PostPosted: Mon 08 Aug 2011, 03:45    Post subject: Hello Bacon (World)
Subject description: Using a COMBO widget
 

A project to demo some of the BaCon HUG widgets.
This program demos the COMBO widget ie. drop down box.

This is the naming convention that I've started using.
It should prevent collisions with items used in the compiler.

    ALL_UPPER_CASE ( All uppercase for SUB's and FUNCTIONs )
    Unnnn_nnnn_ ( Uppercase first letter, end with "_" for widget handles )
    Unnnn_nnnn ( Variable names )
    Unnnn_nnnn$ ( String variables )

NEW -
The GLOBAL statement.
Although not strictly necessary, declaring variables becomes
more useful the bigger a program gets. The "TYPE NUMBER" declares
these variables to be numbers. We can have as many GLOBAL statements
as we want.

COMBO
The COMBO widget is initialized like this:
Widget_handle_ = COMBO( "first item", size-x, size-y )

Items are added to the COMBO widget with the TEXT method:
TEXT( Widget_handle_, "2nd item" )
TEXT( Widget_handle_, "3rd item" )
TEXT( Widget_handle_, "4th item" )

Then the COMBO is added to the widow in the same way the buttons
were in the previous example.
ATTACH(Mainwin_, Widget_handle_, x-coord, y-coord )

rod
Code:
' BaCon / HUG  Hello BaCon (World)
' Add a Combo widget (drop down)

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

GLOBAL Mainwin_, Menu_label_, Drink_label_, Drink_combo_, My_close_ TYPE int

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

' ------------------
SUB MAKE_GUI
' ------------------
   Mainwin_ = WINDOW( "Hello BaCon", 400, 400 )

   Menu_label_ = MARK( "Please choose items from Menu", 200, 28 )
   ATTACH( Mainwin_, Menu_label_, 100, 0 )

   Drink_label_ = MARK("Select Drink", 100, 28)
   ATTACH( Mainwin_, Drink_label_, 10, 25)

   '--- Add a COMBO widget with 4 items
   Drink_combo_ = COMBO("Coffee", 100, 28 )
   TEXT( Drink_combo_, "Tea")
   TEXT( Drink_combo_, "Milk")
   TEXT( Drink_combo_, "O,J.")
   ATTACH( Mainwin_, Drink_combo_, 10, 50 )


   '--- BUTTONS ---
   Close_btn_ = STOCK("gtk-close", 100, 28)
   ATTACH(Mainwin_, Close_btn_, 290, 365)

   '--- CALLBACKS ---
   CALLBACK(Close_btn_, QUIT)
END SUB

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


' ******************
' MAIN PROGRAM
' ******************

MAKE_GUI

DISPLAY
hello_bacon.png
 Description   
 Filesize   9.68 KB
 Viewed   1189 Time(s)

hello_bacon.png

hello_bacon_combo.tar.gz
Description  source file
gz

 Download 
Filename  hello_bacon_combo.tar.gz 
Filesize  641 Bytes 
Downloaded  375 Time(s) 
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 2 of 12 [168 Posts]   Goto page: Previous 1, 2, 3, 4, ..., 10, 11, 12 Next
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Off-Topic Area » Programming
Jump to:  

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
[ Time: 0.0942s ][ Queries: 12 (0.0071s) ][ GZIP on ]