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 21 Nov 2014, 14:04
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 Posts_count  
Author Message
TIHO0505

Joined: 08 May 2014
Posts: 3

PostPosted: Thu 08 May 2014, 05:13    Post_subject:  Gtkdialog
Sub_title: 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: 5782
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_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: 5782
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_website 
Display_posts:   Sort by:   
Page 1 of 1 Posts_count  
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.6639s ][ Queries: 11 (0.2095s) ][ GZIP on ]