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 Thu 17 Apr 2014, 06:20
All times are UTC - 4
 Forum index » Off-Topic Area » Programming
GtkDialog - tips
Post new topic   Reply to topic View previous topic :: View next topic
Page 42 of 62 [928 Posts]   Goto page: Previous 1, 2, 3, ..., 40, 41, 42, 43, 44, ..., 60, 61, 62 Next
Author Message
thunor


Joined: 14 Oct 2010
Posts: 350
Location: Minas Tirith, in the Pelennor Fields fighting the Easterlings

PostPosted: Sun 02 Oct 2011, 07:59    Post subject:  

seaside wrote:
Anyone have a theory on how this could happen? Something using file i/o being faster than memory?

Wait... perhaps it's because Gtkdialog reloads the entire program whenever called, whereas - if from a file it's displayed immediately?

Cheers,
s

I've found the issue and it's fixed in r308.

The problem was that strlen() was being called for every char read from memory to check that a char wasn't being read past the end, but this was pointless anyway since an environment variable is null terminated which is being checked for too.

Reading from a file or stdin are both fine though and it'd be a good idea to stick to these methods for complex apps until everyone is using at least r308.

Something else I've found: loading my rather large app from an environment variable is causing bash to display an error message: "./myapp: line 192: /usr/sbin/gtkdialog: Argument list too long", so I have to load from a file or stdin anyway. The limit I am experiencing which bash won't accept above is somewhere around 123KB.

Regards,
Thunor
Back to top
View user's profile Send private message Visit poster's website 
Geoffrey


Joined: 30 May 2010
Posts: 1213
Location: Queensland Australia ɹǝpu∩uʍop

PostPosted: Tue 11 Oct 2011, 10:18    Post subject:  

post deleted and moved
Back to top
View user's profile Send private message 
SK7000

Joined: 12 Oct 2011
Posts: 4

PostPosted: Wed 12 Oct 2011, 15:03    Post subject: comboboxtext searching?  

Hello,

Today I discovered gtkdialog while building a minimal GUI around a commandline application I use frequently. I've got pretty much everything working except two things.

The first is behaviour I've come to expect of all comboboxes I've come across, and it is to be able to search the entry you are looking for by typing the first few characters. It appears that "comboboxtext" areas in Gtkdialog don't have this functionality built-in, not even the advanced demos do it.

So, is there any way to do it, either by setting some property or clever action-binding?

The second is quite simple, I just can't figure out a way so that the dialogue's "OK" button gets pressed when the user presses Enter while the comboboxtext area is focused. I didn't see any actions that can be bound to the Enter key.

So, again, is there some way to do this?

I imagine I could do without, but it's a bit slow searching the entry you want (amongst a few dozens) without help from the keyboard :/

PS: Thanks for a very interesting and flexible application Surprised
Back to top
View user's profile Send private message 
big_bass

Joined: 13 Aug 2007
Posts: 1747

PostPosted: Wed 12 Oct 2011, 15:08    Post subject:  

I was looking for some simple on screen 600 pixel ruler but nothing I found was simple so
here is as simple as it gets

there is vertical ruler included also
gtk-movable-ruler.png
 Description   
 Filesize   13.77 KB
 Viewed   982 Time(s)

gtk-movable-ruler.png

ruler.tar.gz
Description 
gz

 Download 
Filename  ruler.tar.gz 
Filesize  8.67 KB 
Downloaded  212 Time(s) 

_________________
debian wheezy ,linux mint, slackware I use them all and they all have good points
Mint would be best for general users though
Back to top
View user's profile Send private message 
disciple

Joined: 20 May 2006
Posts: 6378
Location: Auckland, New Zealand

PostPosted: Wed 12 Oct 2011, 20:30    Post subject:  

big_bass wrote:
I was looking for some simple on screen 600 pixel ruler but nothing I found was simple so

IIRC gruler used to be written in C (rather than ruby), and would have met your criteria Wink

_________________
DEATH TO SPREADSHEETS
- - -
Classic Puppy quotes
- - -
Beware the demented serfers!
Back to top
View user's profile Send private message 
technosaurus


Joined: 18 May 2008
Posts: 4133

PostPosted: Thu 13 Oct 2011, 08:29    Post subject:  

thunor wrote:

Reading from a file or stdin are both fine though and it'd be a good idea to stick to these methods for complex apps until everyone is using at least r308.
and the -i file / --include=file is a very robust way of getting a slew of functions without having to use export -f (which is a bashism)

ex.
Code:
#!/bin/sh
. /usr/local/myapp/myfunctions
#code
eval `gtkdialog --include=/usr/local/myapp/myfunctions --file=/usr/local/myapp/myMAIN`
#more code


btw, is there an example of "event driven" anywhere
I have found that commands in the shabang cannot end in a number (#!/usr/sbin/gtkdialog3 -e fails, but #!/usr/sbin/gtkdialog -e succeeds)

ex.
Code:
#!/usr/sbin/gtkdialog -e

function print_this() {
  echo "print: $1"
}

export MAIN_DIALOG='
<vbox>
  <button>
    <label>function</label>
    <action>print_this button</action>
  </button>
  <button>
    <label>Exit</label>
  </button>
</vbox>
'

this works if you make a symlink to gtkdialog but fails if you just change the shabang to gtkdialog3

_________________
Web Programming - Pet Packaging 100 & 101
Back to top
View user's profile Send private message 
vovchik


Joined: 23 Oct 2006
Posts: 1285
Location: Ukraine

PostPosted: Thu 13 Oct 2011, 08:41    Post subject:  

Dear technosaurus,

Great observation (shebang ending with a number) and tip!

With kind regards,
vovchik
Back to top
View user's profile Send private message 
seaside

Joined: 11 Apr 2007
Posts: 878

PostPosted: Thu 13 Oct 2011, 11:04    Post subject:  

technosaurus wrote:


btw, is there an example of "event driven" anywhere

this works if you make a symlink to gtkdialog but fails if you just change the shabang to gtkdialog3


technosaurus,

The gtkdialog "event driven" mode was my first attempt at gtkdialog with "LocnRox" here -

http://www.murga-linux.com/puppy/viewtopic.php?t=47158&sid=4a8c0ef440c5e70f4b7324df43910d84

I think Thunor found that the "gtkdialog" call was hardcoded.

Regards,
s
Back to top
View user's profile Send private message 
seaside

Joined: 11 Apr 2007
Posts: 878

PostPosted: Thu 13 Oct 2011, 11:22    Post subject: Re: comboboxtext searching?  

SK7000 wrote:
Hello,

Today I discovered gtkdialog while building a minimal GUI around a commandline application I use frequently. I've got pretty much everything working except two things.

The first is behaviour I've come to expect of all comboboxes I've come across, and it is to be able to search the entry you are looking for by typing the first few characters. It appears that "comboboxtext" areas in Gtkdialog don't have this functionality built-in, not even the advanced demos do it.

So, is there any way to do it, either by setting some property or clever action-binding?

The second is quite simple, I just can't figure out a way so that the dialogue's "OK" button gets pressed when the user presses Enter while the comboboxtext area is focused. I didn't see any actions that can be bound to the Enter key.

So, again, is there some way to do this?

I imagine I could do without, but it's a bit slow searching the entry you want (amongst a few dozens) without help from the keyboard :/

PS: Thanks for a very interesting and flexible application Surprised


SK7000,

You can do an "enter default" for a single entry box-
Code:
<entry activates-default="true">
.
It doesn't seem to be applicable to comboboxes, as the "enter" behaviour is coded to bring up more choices.

Both of these items seem like good candidates for the Cutting Edge>Gtkdialog Development thread.

Cheers,
s
Back to top
View user's profile Send private message 
SK7000

Joined: 12 Oct 2011
Posts: 4

PostPosted: Thu 13 Oct 2011, 13:08    Post subject: Re: comboboxtext searching?  

seaside wrote:

SK7000,

You can do an "enter default" for a single entry box-
Code:
<entry activates-default="true">
.
It doesn't seem to be applicable to comboboxes, as the "enter" behaviour is coded to bring up more choices.

Both of these items seem like good candidates for the Cutting Edge>Gtkdialog Development thread.

Cheers,
s


Thanks for the information, I submitted the ideas to the development thread. I just thought there might be a way to do these things already, it just wasn't documented. Well, let's wait and see if we get support for at least incremental search, that would be very useful, IMHO.
Back to top
View user's profile Send private message 
brokenman

Joined: 20 Oct 2011
Posts: 22

PostPosted: Thu 20 Oct 2011, 19:25    Post subject: Large projects
Subject description: Splitting up files
 

I have a question in relation o the post above by technosaurus.

I am designing a larger project and don't want to get to the size litmit mentioned only to find failures. I want to break the scripts up. Here is what i have:

main-script.sh
Code:
#!/bin/bash

. ./functions.sh

echo "This is the starter script"

eval `gtkdialog --include=./functions.sh --file=./gtkfile.sh`


functions.sh
Code:
#!/bin/bash

VAR1="variable1-from-$0"

myfunction(){
VAR2="variable2 from $FUNCNAME"
}
myfunction


gtkfile.sh
Code:
#! /usr/bin/gtkdialog -f

<vbox>
<button ok></button>
<text><label>This is some text</label></text>
<text><label>VAR1 is $VAR1</label></text>
<text><label>"VAR2 is $VAR2"</label></text>
</vbox>


After starting the main-script.sh the output gives me a window with:
VAR1=$VAR1
VAR2=$VAR2

According to the post above, i assume i can have this setup ... but i am having trouble passing variables to the gtkdialog application. I get the same result if the variables are exported. How is the technique above useful for large applications split over multiple files?
Back to top
View user's profile Send private message 
seaside

Joined: 11 Apr 2007
Posts: 878

PostPosted: Fri 21 Oct 2011, 12:07    Post subject: Re: Large projects
Subject description: Splitting up files
 

brokenman wrote:
. but i am having trouble passing variables to the gtkdialog application. I get the same result if the variables are exported. How is the technique above useful for large applications split over multiple files?


brokenman,

Usually, if the variables are exported, the problem may be traced to variables being created in a child process. In that case the parent can't see those variables.

You can save those variables to temp files instead for reference.

Cheers,
s
Back to top
View user's profile Send private message 
technosaurus


Joined: 18 May 2008
Posts: 4133

PostPosted: Fri 21 Oct 2011, 12:42    Post subject:  

here is another goody:

you don't even really need to export most functions, you can use something like this:

Code:
gtkdialogworker(){
while read A; do
   case $A in
      #add your stuff here);;
      EXIT)return 0;;
      *)echo $A;;
   esac
done
}

gtkdialog ... | gtkdialogworker


just use echo for your actions and let your "worker" do the rest.
(sorry for the abbreviated explanation, I have somewhere to be and didn't want to forget this ... it may be quite useful)

and I wanted to post this other waitpid quickie:
(no need to use ps and grep to parse output, plus works for multiple processes)
command &
COMMANDPID=$!

while ([ -d /proc/$COMMANDPID ]) do usleep 1000; done

you can do this for multiple commands using " || "

(this could be extremely useful in speeding up scripts like init or others that use "wait" for all child processes to finish when we are only concerned about a couple)

_________________
Web Programming - Pet Packaging 100 & 101
Back to top
View user's profile Send private message 
brokenman

Joined: 20 Oct 2011
Posts: 22

PostPosted: Fri 21 Oct 2011, 13:11    Post subject:  

Thanks seaside. My goal here was to avoid dumping temp files. I gathered it was due to child not being able to pass to parent. This is why i questioned the use of the code:
Code:
. ./functions.sh
echo "This is the starter script"
eval `gtkdialog --include=./functions.sh --file=./gtkfile.sh`

What is the purpose of the --include call?

If i begin the script (main-script.sh) with . ./functions.sh i am running this as a child process and the vars become available to parent (main-script.sh). The 'eval' line appears to me to start the gtkfile.sh while including the functions.sh for access. I must be missing something, i don't entirely understand how this --include line works. Perhaps someone will edify me.

At the moment i have a large main script containing functions of gtkdialog script. I have a separate library script for 'shell only' code. This works ok, but i am having to export everything so it is available for gtkdialog. This concerns me as my script will most certainly exceed the mentioned size limit where problems begin to occur.
Back to top
View user's profile Send private message 
technosaurus


Joined: 18 May 2008
Posts: 4133

PostPosted: Fri 21 Oct 2011, 21:02    Post subject:  

The --include is so you don't have to export the functions (you can't even export the with ash, dash, etc ... as the shell instead of bash) .

BTW, I don't think there is a chance of reaching a size limit, I have been up to 1mb before (bashbox) with no problem. As far as readability goes geany's code folding eliminates that issue. You can do extra code blocks like this:
Code:

{ #begin foo block

Foo code here

} #end foo block

_________________
Web Programming - Pet Packaging 100 & 101
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 42 of 62 [928 Posts]   Goto page: Previous 1, 2, 3, ..., 40, 41, 42, 43, 44, ..., 60, 61, 62 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.0981s ][ Queries: 12 (0.0140s) ][ GZIP on ]