The time now is Mon 23 Apr 2018, 02:09
All times are UTC - 4 |
Page 31 of 36 [526 Posts] |
Goto page: Previous 1, 2, 3, ..., 29, 30, 31, 32, 33, 34, 35, 36 Next |
Author |
Message |
L18L
Joined: 19 Jun 2010 Posts: 3431 Location: www.eussenheim.de/
|
Posted: 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
|
|
 |
sunburnt

Joined: 08 Jun 2005 Posts: 5087 Location: Arizona, U.S.A.
|
Posted: 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
|
|
 |
e_mattis

Joined: 20 Dec 2012 Posts: 114 Location: Williamston, SC
|
Posted: 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
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
|
|
 |
sunburnt

Joined: 08 Jun 2005 Posts: 5087 Location: Arizona, U.S.A.
|
Posted: 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
|
|
 |
e_mattis

Joined: 20 Dec 2012 Posts: 114 Location: Williamston, SC
|
Posted: 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
|
|
 |
sunburnt

Joined: 08 Jun 2005 Posts: 5087 Location: Arizona, U.S.A.
|
Posted: 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
|
|
 |
e_mattis

Joined: 20 Dec 2012 Posts: 114 Location: Williamston, SC
|
Posted: 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
|
|
 |
e_mattis

Joined: 20 Dec 2012 Posts: 114 Location: Williamston, SC
|
Posted: Fri 22 Feb 2013, 22:47 Post subject:
Subject description: 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. 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?
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.
Observation: There isn't really an in-depth 'how-to' for Bacon that I can find.
Any help is very much appreciated!
Thanks!
E
.
|
Back to top
|
|
 |
L18L
Joined: 19 Jun 2010 Posts: 3431 Location: www.eussenheim.de/
|
Posted: Sat 23 Feb 2013, 06:46 Post subject:
Subject description: 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
-------
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
Last edited by L18L on Sat 23 Feb 2013, 14:46; edited 1 time in total
|
Back to top
|
|
 |
sunburnt

Joined: 08 Jun 2005 Posts: 5087 Location: Arizona, U.S.A.
|
Posted: 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
|
|
 |
e_mattis

Joined: 20 Dec 2012 Posts: 114 Location: Williamston, SC
|
Posted: 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.
One thing I found is that the 'callback' must come before the 'display'. that was one thing I had wrong in my original. (ima still learning )
Now to get the subs for the actions working properly. I'll probably be back soon for more assistance!
Thanks
E
.
|
Back to top
|
|
 |
sunburnt

Joined: 08 Jun 2005 Posts: 5087 Location: Arizona, U.S.A.
|
Posted: 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
|
|
 |
L18L
Joined: 19 Jun 2010 Posts: 3431 Location: www.eussenheim.de/
|
Posted: 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. (ima still learning ) |
Nothing after DISPLAY is executed.
...after DISPLAY don't forget a new line
We all are learning...
... and continue
|
Back to top
|
|
 |
vovchik

Joined: 23 Oct 2006 Posts: 1447 Location: Ukraine
|
Posted: 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
|
|
 |
e_mattis

Joined: 20 Dec 2012 Posts: 114 Location: Williamston, SC
|
Posted: Sun 24 Feb 2013, 23:08 Post subject:
|
|
Hey guys,
Thanks for the input Vov - I was needing that
I have another dilema now 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.
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
|
|
 |
|
Page 31 of 36 [526 Posts] |
Goto page: Previous 1, 2, 3, ..., 29, 30, 31, 32, 33, 34, 35, 36 Next |
|
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
|