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 Wed 24 May 2017, 19:32
All times are UTC - 4
 Forum index » Off-Topic Area » Programming
Bash/gtkdialog: function is stealing focus? [SOLVED]
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 1 [3 Posts]  
Author Message
zigbert


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

PostPosted: Wed 28 Dec 2016, 20:14    Post subject:  Bash/gtkdialog: function is stealing focus? [SOLVED]
Subject description: Help required
 

This test script shows my issue:
The function is run as a background process, but still it prevents the code to reach the end (gxmessage).
How can I get the Exit-value from the main gui while the function-gui shows? I can not use the launch/close commands in gtkdialog.

Thanks for any help

Code:
#!/bin/bash

myfunc(){
   echo '<vbox><button ok></button></vbox>' | gtkdialog -s
}
export -f myfunc

export XML='
<vbox>
  <text><label>Exit value is correct if pressing the button below. Opening another window corrupts the Exit value</label></text>
  <button>
    <label>My exit value is: Button1</label>
    <action type="exit">Button1</action>
  </button>
  <button>
    <label>Open another window corrupts the exit value</label>
    <action>myfunc &</action>
  </button>
</vbox>
'
I=$IFS; IFS=""
for STATEMENTS in $(gtkdialog -p XML); do
   eval $STATEMENTS
done
IFS=$I

gxmessage "Exit value is: $EXIT"

_________________
Stardust resources

Last edited by zigbert on Thu 29 Dec 2016, 05:02; edited 1 time in total
Back to top
View user's profile Send private message Visit poster's website 
MochiMoppel


Joined: 26 Jan 2011
Posts: 1261
Location: Japan

PostPosted: Thu 29 Dec 2016, 01:19    Post subject:  

Code:
<action>myfunc > /dev/null &</action>
This will let the code proceed to the gxmessage command, showing the EXIT value of the main window, even if the child window is still alive.

If you also need the EXIT value of the child window you can add an eval loop to the function:
Code:
myfunc(){
for STATEMENTS in $(echo '<button></button>' | gtkdialog -s );do
   eval $STATEMENTS
done
gxmessage "Exit value of child is: $EXIT"
}
export -f myfunc
Back to top
View user's profile Send private message 
zigbert


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

PostPosted: Thu 29 Dec 2016, 05:01    Post subject:  

Thanks a lot! Very Happy
_________________
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 [3 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.0634s ][ Queries: 11 (0.0105s) ][ GZIP on ]