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 24 Oct 2014, 21:53
All times are UTC - 4
 Forum index » Off-Topic Area » Programming
BaCon - Bash-based Basic-to-C converter/compiler
Post_new_topic   Reply_to_topic View_previous_topic :: View_next_topic
Page 31 of 36 Posts_count   Goto page: Previous 1, 2, 3, ..., 29, 30, 31, 32, 33, 34, 35, 36 Next
Author Message
L18L

Joined: 19 Jun 2010
Posts: 2530
Location: Moved from Hosla to www.eussenheim.de

PostPosted: Sat 02 Feb 2013, 13:23    Post_subject:  

e_mattis wrote:
Thanks sunburnt,

i'll look a little more and see about the GTK import. I think i'm going to like the idea about the combo boxes better though.

Maybe the best way to say what i am looking for is that I want it to open the full display width and height. fullscreen is the ideal, but full display would work. where would i find the dimension- which file?

thanks!

E

I have found my screen size 1920x180 in /var/log/Xorg.0.log
my console wrote:

# grep ' HDisplay:' /var/log/Xorg.0.log
[ 33.159] (II) CHROME(0): HDisplay: 1920
# grep ' VDisplay:' /var/log/Xorg.0.log
[ 33.159] (II) CHROME(0): VDisplay: 1080
#
Back to top
View user's profile Send_private_message 
sunburnt


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

PostPosted: Sat 02 Feb 2013, 18:19    Post_subject:  

Property commands for width and height from a popup menu I wrote:
Code:
PROPERTY(win_, "width-request", winW)
PROPERTY(win_, "height-request", winH)

Some of us like it use "win_, btn_, lst3_, file_" for object variables.
The underline shows that the variable is a handle for the object type.
It helps a lot to clearly see a variable`s purpose when looking at the code.

L18L shows a good way to get the screen resolution.
This is the command way to get it:
Code:
RES=`xrandr | grep '*' | awk '{print $1}'


I find BaCon to be very useful, many cudos to Peter for it`s creation and maintaining.
Being as BaCon uses C, and HUG uses GTK+ it should work on most Linux distros.
So apps. you write are more portable compared to GtkDialog which only Puppy uses
GtkDialog does have more controls ( menu bar I think...) and more properties also.
Back to top
View user's profile Send_private_message 
e_mattis


Joined: 20 Dec 2012
Posts: 114
Location: Williamston, SC

PostPosted: Sun 03 Feb 2013, 00:09    Post_subject:  

Thanks guys!

I seem to be having trouble declaring win_, winW, and winH. I've tried 'DECLARE win_, winW, winH' and 'GLOBAL winW, winH TYPE int' but keep getting errors after compile @ run. . .
GLib-GObject-critical**:g_object_set:assertion ....
with no declaration, it tell me the win_, winW, winH are not declared.

I'm probably jumping the gun and need to read more before trying this but I've just got excited about the possibilities...sorry Very Happy

Just want you guys to know I appreciate your patience and assistance - it is good to have people who know to confer with. Thanks so much!

Thanks!

E
Back to top
View user's profile Send_private_message Visit_website 
sunburnt


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

PostPosted: Sun 03 Feb 2013, 01:18    Post_subject:  

I should show full code examples... I apologize.
Code:
win_ = WINDOW("My App.", 300, 200)

OR:
OPEN File$ FOR READING AS file_

You don`t need to declare control object`s ID variables.!
Back to top
View user's profile Send_private_message 
e_mattis


Joined: 20 Dec 2012
Posts: 114
Location: Williamston, SC

PostPosted: Sun 03 Feb 2013, 12:47    Post_subject:  

yea, lot different than what i'm used to. Gonna have to re-learn a lot.

@sunburnt
to clarify - when setting 'win_=WINDOW("my win", 300,200) - you set the dimensions of the window there, so the max winW would be 300, not the max width of the viewable screen. Am I correct in that assumption?

When I enter the 'RES = 'xrandr | grep '*' | awk '[print $1]' it gives me an error of "character constant too long for its type [enabled by default]". I am thinking this is due to asking for an int rather than a long int. correct?

thanks!

E
Back to top
View user's profile Send_private_message Visit_website 
sunburnt


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

PostPosted: Mon 04 Feb 2013, 15:30    Post_subject:  

Like this example the exact size is set in the control`s ( or widget`s ) statement.
Code:
win_ = WINDOW("My App.", 300, 200)
btnExit_ = BUTTON("Exit", 60, 25) : ATTACH(win_, btnExit_, 10, 10) : CALLBACK(btnExit_, EXIT)

This places the button on the window at 10 x 10 and it calls a SUB named EXIT.

I didn`t explain again, sorry. If you notice the command used grep, so it`s a Linux shell command.
Here`s the command called from BaCon, CHOP$ removes the shell`s LineFeed so Res$ has just text.:
Code:
cmd$ = CONCAT$("xrandr | grep '*' | awk '{print $1}'")
Res$ = CHOP$(EXEC$(cmd$))

You can also read or write a file in one shell command too:
Code:
File$ = EXEC$(CONCAT$("cat FileToRead"))

SYSTEM "echo Text >  FileToWrite"
SYSTEM CONCAT$("echo ", Text$, " > ", FileToWrite$)

The top-bottom example writes "Text" to the file FileToWrite.
The bottom one uses variables for the text and the file.
Notice the spaces in the " literal " parts to separate the command parts.
Back to top
View user's profile Send_private_message 
e_mattis


Joined: 20 Dec 2012
Posts: 114
Location: Williamston, SC

PostPosted: Mon 04 Feb 2013, 19:23    Post_subject:  

Thaks sunburnt,

I'll play around with it a while and see what I figure out. Bad part is that it makes sense to me, but getting it to work when i write it....lol

thanks !

E
Back to top
View user's profile Send_private_message Visit_website 
e_mattis


Joined: 20 Dec 2012
Posts: 114
Location: Williamston, SC

PostPosted: Fri 22 Feb 2013, 22:47    Post_subject:
Sub_title: combobox bacon
 

Hey All,

I'm working with combo boxes in bacon/HUG. From what I can tell, this is the syntax to set up the box:

com_btn=COMBO("File",100,25)
ATTACH(mainwin,com_btn,1,1)
TEXT(com_btn,"Backup")
TEXT(com_btn,"Restore")
TEXT(com_btn,"Exit")

In order to make the program exit when 'exit' is chosen, i tried this:

CALLBACK(com_btn,"Exit",QUIT)

That did not work. Mad So my question is, once a selection is chosen, how do you initiate an action for (or how do you associate an action with) that selection? Confused

Also, I am wondering if there is a means of changing the text color on-screen? I tried the COLOR FG TO WHITE but it had no effect. The text as I have it atm is:

label_title=MARK("test line",80,20)
ATTACH(mainwin,label_title,20,20)

Also tried PROPERTY(label_title,"color","white") to no avail. Sad

Observation: There isn't really an in-depth 'how-to' for Bacon that I can find. Crying or Very sad

Any help is very much appreciated!

Thanks!

E
.
Back to top
View user's profile Send_private_message Visit_website 
L18L

Joined: 19 Jun 2010
Posts: 2530
Location: Moved from Hosla to www.eussenheim.de

PostPosted: Sat 23 Feb 2013, 06:46    Post_subject:
Sub_title: combobox bacon
 

e_mattis wrote:
... i tried this:

CALLBACK(com_btn,"Exit",QUIT)

That did not work. ...


With me it worked this way:
Quote:
Compiler emits messages!

Cause:
too many arguments to function 'CALLBACK'

file:///usr/share/doc/BaCon/hugdoc.html wrote:
CALLBACK

CALLBACK(widget, function)

Type: directive

Defines a self-defined <function> where HUG should jump to when an event for <widget> occurs.

Hope that helps Smile

-------
edited

or this:
Code:
INCLUDE "/usr/share/BaCon/hug_imports.bac"
INIT

SUB myaction
 SELECT GET(com_btn)
  CASE 0
   PRINT "File chosen"
  CASE 1
   PRINT "Backup chosen"
  CASE 2
   PRINT "Restore chosen"
  CASE 3
   QUIT
  DEFAULT
   PRINT "Value not found"
 END SELECT
END SUB

mainwin=WINDOW("combo example", 250, 100)
com_btn=COMBO("File", 100, 25)
ATTACH(mainwin, com_btn, 1, 1)
TEXT(com_btn, "Backup")
TEXT(com_btn, "Restore")
TEXT(com_btn, "Exit")

CALLBACK(com_btn, myaction)

DISPLAY

---
edited:

this works without TIMEOUT

Edited_time_total
Back to top
View user's profile Send_private_message 
sunburnt


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

PostPosted: Sat 23 Feb 2013, 14:29    Post_subject:  

e_mattis; The Bacon ( GTK+ ) COMBO box doesn`t use CALLBACK, you must use the TIMEOUT.
Paste, save, and compile this:
Code:
INCLUDE "/root/0_BaCon/BaCon/hug.bac",INIT,DISPLAY,WINDOW,COMBO,MARK,ATTACH,TIMEOUT,SET,GET,TEXT,GRAB$
INIT

SUB Set_Choice
   SET(cboTest_, GET(cboTest_))
   TEXT(lblTest_, GRAB$(cboTest_))
   PRINT GRAB$(cboTest_)
END SUB

win_ = WINDOW(" Combo Test", 100, 100)

lblTest_ = MARK("Test", 80, 25)
ATTACH(win_, lblTest_, 10, 10)

cboTest_ = COMBO("", 80, 25)
ATTACH(win_, cboTest_, 10, 50)

FOR i = 1 TO 5
   TEXT(cboTest_, CONCAT$("Item #", STR$(i)))
NEXT

SET(cboTest_, 1)

TIMEOUT(1000, Set_Choice)

DISPLAY


A _ "handle" on the end of the widget variables makes them easy to see.
.
Back to top
View user's profile Send_private_message 
e_mattis


Joined: 20 Dec 2012
Posts: 114
Location: Williamston, SC

PostPosted: Sat 23 Feb 2013, 22:24    Post_subject:  

Thanks guys,

Tried both ways. The method L18L gave is a little more familiar to me. I also was able to get the method sunburnt gave me to work, but it read a little confusing to me. Thank both of you for helping me through it. Very Happy

One thing I found is that the 'callback' must come before the 'display'. that was one thing I had wrong in my original. Embarassed (ima still learning Smile )

Now to get the subs for the actions working properly. I'll probably be back soon for more assistance!

Thanks

E

.
Back to top
View user's profile Send_private_message Visit_website 
sunburnt


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

PostPosted: Sun 24 Feb 2013, 02:07    Post_subject:  

Okay... Apparently GTK+ reworked the ComboBox.

If you look way back in this thread you`ll see how it use to only work with TIMEOUT.
It`s good to see changes like this, I always thought TIMEOUT was a stupid way to do it.

I just made a download: mirror, distro., and arch. selector GUI with ComboBoxes.

# The Bacon site needs to point out these changes to it`s patrons.
Back to top
View user's profile Send_private_message 
L18L

Joined: 19 Jun 2010
Posts: 2530
Location: Moved from Hosla to www.eussenheim.de

PostPosted: Sun 24 Feb 2013, 15:13    Post_subject:  

e_mattis wrote:
... One thing I found is that the 'callback' must come before the 'display'. that was one thing I had wrong in my original. Embarassed (ima still learning Smile )


Nothing after DISPLAY is executed.
...after DISPLAY don't forget a new line

We all are learning...
... and continue Smile
Back to top
View user's profile Send_private_message 
vovchik


Joined: 23 Oct 2006
Posts: 1285
Location: Ukraine

PostPosted: Sun 24 Feb 2013, 15:55    Post_subject:  

Dear L18L,

If you are using HUG - and you are - and you need the screen size in pixels, there is no need to call xrandr or another external utility. HUG has this command:

Code:

SCREENSIZE(dimension)
Type: function
Gets the current screensize in pixels. If <dimension> is 0 then the horizontal size is retrieved, and if <dimension> is 1 the vertical size.


Example:

Code:

x = SCREENSIZE(0)
y = SCREENSIZE(1)


If you use it and have a list of keywords after the INCLUDE "hug.bac" business, don't forget to include SCREESIZE in that list.

With kind regards,
vovchik

PS. COMBO works fine with CALLBACK on my machine.
PPS. I also have the situation with a newline being required at the end of the code - but not on all machines![/code]
Back to top
View user's profile Send_private_message 
e_mattis


Joined: 20 Dec 2012
Posts: 114
Location: Williamston, SC

PostPosted: Sun 24 Feb 2013, 23:08    Post_subject:  

Hey guys,

Thanks for the input Vov - I was needing that Very Happy

I have another dilema now Sad I need to understand how to launch and run another 'script' from within a 'script'.

as example,:

Code:
SUB com_btn2
   SELECT GET(com_btn)
      CASE 0
         PRINT "File Chosen"
      CASE 1
         HIDE (mainwin)
         SYSTEM "exec /opt/myProg"
      CASE 2
         PRINT "Restore Chosen"
etc, etc....

END SUB


I have looked over the docs for Bacon and Hug, this is the closet thing I've found. I am familiar with the 'RUN "program_name" ' call in other basics, but see no such function here.

Any help is very appreciated!

Thanks!

E


[update]...

ok, so I found that adding the '&' would cause the script to launch. Embarassed
SYSTEM "exec /opt/myProgram &"
works. Now, is there a means to keep the window close (X) button from showing on the window?

And i'm still trying to figure out how to change font color.

Thanks!



.
Back to top
View user's profile Send_private_message Visit_website 
Display_posts:   Sort by:   
Page 31 of 36 Posts_count   Goto page: Previous 1, 2, 3, ..., 29, 30, 31, 32, 33, 34, 35, 36 Next
Post_new_topic   Reply_to_topic View_previous_topic :: View_next_topic
 Forum index » Off-Topic Area » Programming
Jump to:  

Rules_post_cannot
Rules_reply_cannot
Rules_edit_cannot
Rules_delete_cannot
Rules_vote_cannot
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.1154s ][ Queries: 13 (0.0200s) ][ GZIP on ]