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 23 Oct 2014, 12:03
All times are UTC - 4
 Forum index » Off-Topic Area » Programming
Gtkdialog
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 1 [4 Posts]  
Author Message
TIHO0505

Joined: 08 May 2014
Posts: 3

PostPosted: Thu 08 May 2014, 05:13    Post subject:  Gtkdialog
Subject description: Grep and print variables in Gtkdialog
 

Hi
here is the part of code, where are have boxes with entries, and i want to create function that I will call with button, that will grep some values from folder and write them to this boxes (variables Cell12..). Here is how boxes looks


Code:
<hbox>
                                  <text>
                                   <label>Cell2</label>
                                   </text>
                                     <entry activates-default="true">
                                     <variable>Cell12</variable>
                                     <input>echo '$Cell12'</input>
                                     </entry>
                                 </hbox>

                                 <hbox>
                                    <text>
                                    <label>Cell3</label>
                                    </text>
                                      <entry activates-default="true">
                                       <variable>Cell13</variable>
                                       <action>echo '$Cell13'</action>
                                      </entry>
                                 </hbox>


and here is

Code:
<hbox>
  <button>
   <label>Fill</label>
      <action>Cell11=`grep -i Cell11 /home/tihomir/Desktop/FolderCell3 | cut -d"=" -f2`</action>
      <action>refresh:Cell11</action>
   </button>
</hbox>


But it is not working. If somebody know's how could I do this, I would appriciate that. If more explanation is need let me know.

BR
Back to top
View user's profile Send private message 
zigbert


Joined: 29 Mar 2006
Posts: 5753
Location: Valåmoen, Norway

PostPosted: Thu 08 May 2014, 12:49    Post subject:  

Hello, and welcome

It will work if you use temporary files instead
Code:
<entry activates-default="true">
 <input file>/tmp/Cell13</input>
 <variable>Cell13</variable>
 <action signal="activate">echo '$Cell13'</action>
</entry>


Code:
<button>
 <label>Fill</label>
 <action>grep -i Cell13 /home/tihomir/Desktop/FolderCell3 | cut -d"=" -f2 > /tmp/Cell13</action>
 <action>refresh:Cell13</action>
</button>


signal="activate" will run action when user press enter-button

_________________
Stardust resources
Back to top
View user's profile Send private message Visit poster's website 
TIHO0505

Joined: 08 May 2014
Posts: 3

PostPosted: Fri 09 May 2014, 05:50    Post subject:  

Thanks for reply, it's working.

Working with this gtkdialog is a little bit different then bash, so I get stuck from time to time Smile.. for example I have a function with grep command, and I want to pass a argument(varaible) to this function, but from gtkdialog it's not working:


Code:
func_grep () {
$Cell=`grep -i '$Cell' /home/tihomir/Desktop/FolderCell3 | cut -d'"' -f2`
echo '$Cell'
}
 


and calling function form gtkdialog :

Code:
<hbox>
                                   <text>
                                   <label>Cell1</label>
                                   </text>
                                    <entry file-monitor="true" auto-refresh="true">
                            <input>exec $SHELL -c func_grep Cell = "Cell11"</input>
                                     <variable>Cell11</variable>
                                     <visible>disabled</visible>
                                     </entry>
                                 </hbox>


it's not working. Did I miss something, or this is not possible to do this way?

Thanks
Back to top
View user's profile Send private message 
zigbert


Joined: 29 Mar 2006
Posts: 5753
Location: Valåmoen, Norway

PostPosted: Fri 09 May 2014, 14:13    Post subject:  

since func_grep returns echo "$Cell" (you must use double quotes), it is enough to just run the function
Code:
<entry file-monitor="true" auto-refresh="true">
 <input>func_grep</input>
 <variable>Cell11</variable>
 <visible>disabled</visible>
</entry>


Be aware that you probably need to make the function global by
Code:
func_grep () {
$Cell=`grep -i '$Cell' /home/tihomir/Desktop/FolderCell3 | cut -d'"' -f2`
echo "$Cell"
}
export -f func_grep

_________________
Stardust resources
Back to top
View user's profile Send private message Visit poster's website 
Display posts from previous:   Sort by:   
Page 1 of 1 [4 Posts]  
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.0776s ][ Queries: 12 (0.0114s) ][ GZIP on ]