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 Sun 19 Nov 2017, 03:09
All times are UTC - 4
 Forum index » Off-Topic Area » Programming
How to clear and modify entry boxes in gtk using variables?
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 1 [5 Posts]  
Author Message
arivas_2005

Joined: 25 Feb 2007
Posts: 191

PostPosted: Sat 30 Sep 2017, 13:16    Post subject:  How to clear and modify entry boxes in gtk using variables?  

regards

i want to learn a little bit of gtk
my auto-lesson " Using Box and Variables (no files, only variables)"
in " GtkDialog - tips" there are many examples
hence I took the following lines
but many scripts, I do not understand them
like the following

in my next script
-- entry B should display mid of A
1) I can not clean two boxes A and B
2) I can not insert mid_A value through ORIGINALFILE=${ORIGINALFILE:$mid_A} in box B
3) I can not clean box A at the time of drag and drop
Code:

#!/bin/sh
RIGHT=550 DOWN=36 WIDTH=600 HEIGHT=150   # define variables with defaults

unset ORIGINALFILE
unset length_A
unset mid_A
unset PDFFILE

function change_pdf_A() {
length_A=${#ORIGINALFILE}
let mid_A=length_A/2
ORIGINALFILE=${ORIGINALFILE:$mid_A}
Xdialog --msgbox "$ORIGINALFILE"" pdf_A" x
}

function change_pdf_B() {
ORIGINALFILE=`echo "Hello John -fill box B-"`
Xdialog --msgbox "$ORIGINALFILE"" pdf_B" x
}

export -f change_pdf_A
export -f change_pdf_B

export MAIN_DIALOG='
<window title="Learning gtk: clear and modify boxs using variables">
   <vbox>
       <text use-markup="true">
         <label>"<span color='"'blue'"' font-family='"'mono'"' weight='"'bold'"' size='"'x-large'"'><big>Learning kgt I</big></span>"
         </label>
        </text>   
       <text use-markup="true">
          <label>"<span color='"'brown'"' weight='"'bold'"' size='"'large'"' >drag ando drop text to A box</span>"
         </label>
    </text>
   
      <hbox>
         <text label="A" xalign="0"></text>
         <entry>
            <variable>ORIGINALFILE</variable>
            <action>refresh:PDFFILE</action>
            <action signal="changed">change_pdf_A</action>
            <action>eval ORIGINALFILE</action>
            <action>refresh:PDFFILE</action>
         </entry>
      </hbox>
      
      <hbox>
         <text label="B" xalign="0"></text>      
         <entry>
            <variable>PDFFILE</variable>
            <input>echo $ORIGINALFILE</input>         
         </entry>
      </hbox>
      
      <hbox>
         <button>
            <label>Clear A and B</label>
            <action>ORIGINALFILE=`ECHO ""`</action>
             <action>refresh:ORIGINALFILE</action>
         </button>
         <button>
            <label>Refresh B</label>
            <action>change_pdf_B</action>
         </button>
         <button>
            <label>Exit</label>
             <action>exit:Exit</action>
         </button>         
     </hbox>
    
   </vbox>

</window>
'
#
# gtkdialog -p GUI -G ${1-${WIDTH}x${HEIGHT}+${RIGHT}+${DOWN}}
#   for STATEMENTS in $(gtkdialog3 -p MAIN_DIALOG); do
I=$IFS; IFS=""
for STATEMENTS in $(gtkdialog -p MAIN_DIALOG -G ${1-${WIDTH}x${HEIGHT}+${RIGHT}+${DOWN}}); do
   eval $STATEMENTS
done
IFS=$I
#eval gtkdialog -p MAIN_DIALOG
unset RIGHT
unset DOWN
unset WIDTH
unset HEIGHT
Xdialog --msgbox "$PDFFILE"" \n""$ORIGINALFILE" x


How could I do it?
Thank you very much for the help
exit

Last edited by arivas_2005 on Sat 30 Sep 2017, 23:26; edited 1 time in total
Back to top
View user's profile Send private message 
arivas_2005

Joined: 25 Feb 2007
Posts: 191

PostPosted: Sat 30 Sep 2017, 23:25    Post subject:  

regards. here again. Embarassed
I have spent hours and hours looking for ..
I have reviewed hundreds of pages.
and I only found something similar
Code:

MY_VAR="DEFAULT VALUE"
export script='
<vbox>
  <entry>
    <variable>ENTRY</variable>
    <input>echo -n '"$MY_VAR"'</input>
  </entry>
  <button>
    <label>Change</label>
    <action>MY_VAR="NEW VALUE"</action>   
    <action>refresh:ENTRY</action>
  </button>
</vbox>'
gtkdialog -p script

http://www.murga-linux.com/puppy/viewtopic.php?t=69188&start=660
(users: @EDDIE_THE_HEAD and @thunor, year: 2012)
without resolving
Then,
It is not possible to use variables to pass data between entry ?
--- Is that it has not yet changed that property (use variables to pass data) in Gtk (2017)?

i will appreciate your support
Thanks you!
Back to top
View user's profile Send private message 
MochiMoppel


Joined: 26 Jan 2011
Posts: 1390
Location: Japan

PostPosted: Sun 01 Oct 2017, 02:42    Post subject:  

It is resolved.
Thunor explained it 2 times to EDDIE_THE_HEAD.
thunor wrote:
Widget variables (the ones that you have created and named yourself) will be placed into the shell when an action executes so that you can read the contents of widgets, but you can't change the contents of widgets by modifying their variables -- you'll likely want something like this:
Code:
<entry>
   <variable>ENTRY</variable>
   <input file>/tmp/inputfile</input>
</entry>
<button>
   <label>Change</label>
   <action>echo "NEW VALUE" > /tmp/inputfile</action>
   <action>refresh:ENTRY</action>
</button>
Back to top
View user's profile Send private message 
arivas_2005

Joined: 25 Feb 2007
Posts: 191

PostPosted: Sun 01 Oct 2017, 11:19    Post subject:  

@ MochiMoppel, Thanks for your reply
then
It is impossible to change the alignment in an entry?
I ask you to comment if this applies also to variables in the properties.
align text in an entry on the fly (o button too...)
see the next code, for example.
Code:
#!/bin/sh
export v_align=0.5


MY_VAR="DEFAULT VALUE"
export script='
<hbox width-request="400">
<vbox>
  <entry width-request="250" xalign="'$v_align'">
    <variable>ENTRY</variable>
    <input>echo -n '"$MY_VAR"'</input>
  </entry>
  <hbox>
      <button>
                <label>Change left</label>
                <action>v_align="0"</action>
                <action>refresh:ENTRY</action>
      </button>
      <button>
               <label>Change center</label>
                <action>v_align="0.5"</action>
                <action>refresh:ENTRY</action>
       </button>
       <button>
               <label>Change right</label>
                <action>v_align="1"</action>
                <action>refresh:ENTRY</action>
       </button>
  </hbox>
</vbox>
</hbox>'
gtkdialog -p script

again, i will appreciate your support
Thanks you!
Back to top
View user's profile Send private message 
MochiMoppel


Joined: 26 Jan 2011
Posts: 1390
Location: Japan

PostPosted: Sun 01 Oct 2017, 21:59    Post subject:  

Unfortunately not possible. Almost all of gtkdialog's properties are read-only. There are only 2 properties that I'm aware of that you can set while gtkdialog is running: visibility and sensibility.
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 1 of 1 [5 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.0408s ][ Queries: 11 (0.0035s) ][ GZIP on ]