Get gtkdialog to read a file of values before refresh.

For discussions about programming, programming questions/advice, and projects that don't really have anything to do with Puppy.
Post Reply
Message
Author
User avatar
sunburnt
Posts: 5090
Joined: Wed 08 Jun 2005, 23:11
Location: Arizona, U.S.A.

Get gtkdialog to read a file of values before refresh.

#1 Post by sunburnt »

Button`s first action runs Xdialog file dialog that writes OUTFILE="FileName" to $1/vob-avi.encode.
It`s next action runs $1/vob-avi.encode in the current shell to reread it`s $OUTFILE value.
The next action then refreshes the Entry Box and it`s $OUTFILE value.

Code: Select all

	export Encode="<window><vbox>
	<frame Input File><vbox>
	<button><label>Output File</label>
		<action>vob-avi.sh outFILE</action>
		<action>. $1/vob-avi.encode</action>
		<action>refresh:OUTFILE</action>
	</button>
	<entry><variable>OUTFILE</variable><input>echo $OUTFILE</input></entry>
	<button ok></button>
	</vbox></window>"
	gtkdialog3 -p Encode
But running $1/vob-avi.encode doesn`t work, so the value remains the same.
Many of Puppy`s dialogs must kill and rerun themselves to refresh themselves.
I assume that this is the only way to get this to work?

User avatar
zigbert
Posts: 6621
Joined: Wed 29 Mar 2006, 18:13
Location: Valåmoen, Norway
Contact:

#2 Post by zigbert »

sunburnt
The solution is simple. Instead of refresh the internal variable $OUTFILE, you should put its value in a file, - and then refresh the <entry>

Code: Select all

export Encode="<window><vbox>
   <frame Input File><vbox>
   <button><label>Output File</label>
      <action>vob-avi.sh outFILE</action>
      <action>refresh:OUTFILE</action>
   </button>
   <entry><variable>OUTFILE</variable><input>cat /path/file-OUTFILE</input></entry>
   <button ok></button>
   </vbox></window>"
gtkdialog3 -p Encode
vob-avi.sh must hold
echo "refresh-text (filoename)" > /path/file-OUTFILE


Sigmund

User avatar
zigbert
Posts: 6621
Joined: Wed 29 Mar 2006, 18:13
Location: Valåmoen, Norway
Contact:

#3 Post by zigbert »

Code: Select all

   export Encode="<window><vbox>
   <frame Input File><vbox>
   <button><label>Output File</label>
      <action>vob-avi.sh outFILE</action>
      <action>. $1/vob-avi.encode</action>
      <action>refresh:OUTFILE</action>
   </button>
   <entry><variable>OUTFILE</variable><input>echo $OUTFILE</input></entry>
   <button ok></button>
   </vbox></window>"
   gtkdialog3 -p Encode
Remember that the xml-code is a variable itself. That means gtkdialog reads the value of "$OUTFILE" when Encode is executed. That's why $OUTFILE can't be refreshed. it could probably work if you used <input>echo '$OUTFILE'</input> instead


Sigmund

User avatar
sunburnt
Posts: 5090
Joined: Wed 08 Jun 2005, 23:11
Location: Arizona, U.S.A.

#4 Post by sunburnt »

Nope, my previous example used "echo $OUTFILE".

My code writes to the vob-avi.encode file:

Code: Select all

outFILE() {
	SEL=`Xdialog --stdout --title " Output File" --fselect $OUTPATH 0 0`
	if [ $? -eq 0 ];then SEL=`basename $SEL`
		echo "$ENC" | sed "s%^OUTFILE.*$%OUTFILE=\"$SEL\"%" > $appDIR/vob-avi.encode
	fi
}
Now I have it writing separate files and it works...

Code: Select all

outFILE() {
	SEL=`Xdialog --stdout --title " Output File" --fselect $OUTPATH 0 0`
	[ $? -eq 0 ] && basename $SEL > $appDIR/output.file
}
But I`m sure Barry has tried to get gtkdialog to refresh it`s own controls with no luck.
And many of his GUIs kill and rerun to accomplish a refresh.
The radio boxes on my GUI work just fine, they change themselves.

It`s amazing that gtkdialog won`t use it`s own control assignment output code internally.

Here`s the GUI for setting the /paths/files, and video & audio encoding.

### I need to get codecs that ffmpeg has installed so the GUI shows them.
Attachments
0_vob-avi_Encode.png
Fairly simple to understand...
(36.86 KiB) Downloaded 622 times

User avatar
zigbert
Posts: 6621
Joined: Wed 29 Mar 2006, 18:13
Location: Valåmoen, Norway
Contact:

#5 Post by zigbert »

But I`m sure Barry has tried to get gtkdialog to refresh it`s own controls with no luck.
And many of his GUIs kill and rerun to accomplish a refresh.
He didn't try hard enough :lol:

There is no problem refreshing most of the widgets in a gtkdialog gui, but you're right. - it has to be done the gtkdialog way. Troublesome widgets that comes to my mind are the <pixmap>, <button>, <combobox>, <menuitem> and <menu> widgets, which has no or very limited possibility to refresh them self without a rerun.


Sigmund

User avatar
sunburnt
Posts: 5090
Joined: Wed 08 Jun 2005, 23:11
Location: Arizona, U.S.A.

#6 Post by sunburnt »

Not to mention externally refreshing them with code from the script.

Why not something like this?

Code: Select all

gtkdialog (process or id) (control`s variable)
It`s important to be able to at least refresh the whole GUI from code.

Not being able to change the text on a button is not good.
But not being able to change the text in a text box is really not good.

User avatar
zigbert
Posts: 6621
Joined: Wed 29 Mar 2006, 18:13
Location: Valåmoen, Norway
Contact:

#7 Post by zigbert »

Code: Select all

#!/bin/bash
echo Yes > /tmp/text
export script='
<vbox>
  <text><variable>TXT</variable><input>cat /tmp/text</input></text>
  <button no><action>echo No > /tmp/text</action><action>refresh:TXT</action></button>
</vbox>'
gtkdialog3 -p script

Post Reply