- 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