Hi.
I have a list in a gui to choose exclusive selections by radio buttons.
But I would like to have something like toggle button, as this can have an icon, which looks much nicer.
I tried to use toggle button combined with
<input file>PathToFileContainingStoredOption<input>
plus
<input file icon="myicon"><input>
though, this doesn't work.
I don't get the stored option from the file that way. Even the use of
file-monitor="true" auto-refresh="true"
doesn't change anything. It still refuses to work.
So, my question: is it possible to have radio buttons showing an icon and being auto refreshed from option stored into a file?
Just hope my problem's explained clear enough to understand...
gtkdialog problem
Ok.
At least
<default>'$(cat $APPDIR/data/useqtractoropt)'</default>
will give the stored option to the toggle button.
So, I think I can solve this temporarily by adding this line to all the toggle buttons.
Then: if a toggle button is selected (true) echoing "false" to the options-files of all the rest of the toggle buttons.
<action>if true echo "false" > $APPDIR/data/userosegardenopt</action>
Then: refreshing all the toggle buttons
<action>refresh:THEBUTTON</action>
However: still would be cool to have radio buttons with icons.
At least
<default>'$(cat $APPDIR/data/useqtractoropt)'</default>
will give the stored option to the toggle button.
So, I think I can solve this temporarily by adding this line to all the toggle buttons.
Then: if a toggle button is selected (true) echoing "false" to the options-files of all the rest of the toggle buttons.
<action>if true echo "false" > $APPDIR/data/userosegardenopt</action>
Then: refreshing all the toggle buttons
<action>refresh:THEBUTTON</action>
However: still would be cool to have radio buttons with icons.
I haven't as yet tried this (or looked at the relevant gtkdialog source code for this to see what's there), but wonder if <input> construct rather than <default> is what you are meaning in what your wish?ITSMERSH wrote: <default>'$(cat $APPDIR/data/useqtractoropt)'</default>
will give the stored option to the toggle button.
<input>'$(cat $APPDIR/data/useqtractoropt)'</input>
EDIT: or maybe just
<input>cat $APPDIR/data/useqtractoropt</input>
Hoping REFRESH toggle button will re-input as above (but maybe it doesn't?...). Since you seem to have tried many things, I guess you've already tried that and it doesn't work as you intend. I can only suggest you provide an actual complete small program to show what you want and see if someone knows off the top of their head.
wiak
No,
<input>'$(cat $APPDIR/data/useqtractoropt)'</input>
doesn't get the stored option from file (note: it's only true or false stored in such file) as <input> from file needs <input file> or for an (gtk cached) icon <input file icon="qtractor"> or even for the stock icons <input file stock="gtk-edit">.
For the toggle button <input file> seems to be reserved for the icon only, as the icon disappears when echoing true or false into that option file.
I will write a small program with two toggle buttons to show what I want to achieve.
<input>'$(cat $APPDIR/data/useqtractoropt)'</input>
doesn't get the stored option from file (note: it's only true or false stored in such file) as <input> from file needs <input file> or for an (gtk cached) icon <input file icon="qtractor"> or even for the stock icons <input file stock="gtk-edit">.
For the toggle button <input file> seems to be reserved for the icon only, as the icon disappears when echoing true or false into that option file.
I will write a small program with two toggle buttons to show what I want to achieve.
Ok,
here it is.
When clicking a button (e.g. Program 3 exclusive) the other buttons (e.g Program 1 exclusive, Program 2 exclusive) should un-select automatically - just like the radio buttons do.
The options are stored properly, though the GUI refuses to refresh.
EDIT:
Sorry, there was a typo --> if fatruelse <-- fixed.
here it is.
Code: Select all
#!/bin/sh
#------------------------------------------------------------------------------
[ ! -f $HOME/useprog1opt ] && echo "true" > $HOME/useprog1opt
[ ! -f $HOME/useprog2opt ] && echo "false" > $HOME/useprog2opt
[ ! -f $HOME/useprog3opt ] && echo "false" > $HOME/useprog3opt
# Simple GUI
ESCAPEGUIPART='<action signal="key-press-event" condition="command_is_true( [ $KEY_SYM = Escape ] && echo true )">exit:QUIT</action>'
TOGGLEBTNGUI='<window title="Toggle Button Test" icon-name="'$ICONONLY'" height-request="'$MIN_WINHGT'" default-height="'$WIN_HGT'" width-request="'$MIN_WINWTH'" default-width="'$WIN_WTH'">
<vbox>
'"$GUIHEAD"'
<vbox space-fill="true" space-expand="true">
<togglebutton tooltip-text=" When clicking this button (Program 1 exclusive) the other buttons (Program 2 exclusive, Program 3 exclusive) should un-select automatically - just like the radio buttons do. The options are stored properly, though the GUI does not refresh.">
<label>"Program 1 exclusive "</label>
<input file icon="www48"></input>
<default>'$(cat $HOME/useprog1opt)'</default>
<variable>RUNPROG1OPT</variable>
<action>if true echo "true" >'$HOME'/useprog1opt</action>
<action>if false echo "false" >'$HOME'/useprog1opt</action>
<action>if true echo "false" >'$HOME'/useprog2opt</action>
<action>if true echo "false" >'$HOME'/useprog3opt</action>
<action>refresh:RUNPROG1OPT</action>
<action>refresh:RUNPROG2OPT</action>
<action>refresh:RUNPROG3OPT</action>
</togglebutton>
<togglebutton tooltip-text=" When clicking this button (Program 2 exclusive) the other button (Program 1 exclusive, Program 3 exclusive) should un-select automatically - just like the radio buttons do. The options are stored properly, though the GUI does not refresh.">
<label>"Program 2 exclusive "</label>
<input file icon="edit48"></input>
<default>'$(cat $HOME/useprog2opt)'</default>
<variable>RUNPROG2OPT</variable>
<action>if true echo "false" >'$HOME'/useprog1opt</action>
<action>if true echo "true" >'$HOME'/useprog2opt</action>
<action>if false echo "false" >'$HOME'/useprog2opt</action>
<action>if true echo "false" >'$HOME'/useprog3opt</action>
<action>refresh:RUNPROG1OPT</action>
<action>refresh:RUNPROG2OPT</action>
<action>refresh:RUNPROG3OPT</action>
</togglebutton>
<togglebutton tooltip-text=" When clicking this button (Program 3 exclusive) the other button (Program 1 exclusive, Program 2 exclusive) should un-select automatically - just like the radio buttons do. The options are stored properly, though the GUI does not refresh.">
<label>"Program 3 exclusive "</label>
<input file icon="archive48"></input>
<default>'$(cat $HOME/useprog3opt)'</default>
<variable>RUNPROG2OPT</variable>
<action>if true echo "false" >'$HOME'/useprog1opt</action>
<action>if true echo "false" >'$HOME'/useprog2opt</action>
<action>if true echo "true" >'$HOME'/useprog3opt</action>
<action>if false echo "false" >'$HOME'/useprog3opt</action>
<action>refresh:RUNPROG1OPT</action>
<action>refresh:RUNPROG2OPT</action>
<action>refresh:RUNPROG3OPT</action>
</togglebutton>
</vbox>
</vbox>
'$ESCAPEGUIPART'
</window>'
export TOGGLEBTNGUI=$(echo "$TOGGLEBTNGUI" | sed 's/#[#~].*$//') # Strip comments
gtkdialog4 --class=TOGGLEBTNGUI -p TOGGLEBTNGUI --center >/dev/null
unset TOGGLEBTNGUI
The options are stored properly, though the GUI refuses to refresh.
EDIT:
Sorry, there was a typo --> if fatruelse <-- fixed.
Is this not what you want? (though I guess you can have a <default> start up value as well but below starts up with previous results anyway; I'm actually using XenialDog with gtkwialog, but should be the same in Pup with gtkdialog I expect).
Code: Select all
#!/bin/sh
#------------------------------------------------------------------------------
[ ! -f $HOME/useprog1opt ] && echo "true" > $HOME/useprog1opt
[ ! -f $HOME/useprog2opt ] && echo "false" > $HOME/useprog2opt
[ ! -f $HOME/useprog3opt ] && echo "false" > $HOME/useprog3opt
# Simple GUI
ESCAPEGUIPART='<action signal="key-press-event" condition="command_is_true( [ $KEY_SYM = Escape ] && echo true )">exit:QUIT</action>'
TOGGLEBTNGUI='<window title="Toggle Button Test" icon-name="'$ICONONLY'" height-request="'$MIN_WINHGT'" default-height="'$WIN_HGT'" width-request="'$MIN_WINWTH'" default-width="'$WIN_WTH'">
<vbox>
'"$GUIHEAD"'
<vbox space-fill="true" space-expand="true">
<togglebutton tooltip-text=" When clicking this button (Program 1 exclusive) the other buttons (Program 2 exclusive, Program 3 exclusive) should un-select automatically - just like the radio buttons do. The options are stored properly, though the GUI does not refresh.">
<label>"Program 1 exclusive "</label>
<input file icon="www48"></input>
<input>cat $HOME/useprog1opt</input>
<variable>RUNPROG1OPT</variable>
<action>if true echo "true" >'$HOME'/useprog1opt</action>
<action>if false echo "false" >'$HOME'/useprog1opt</action>
<action>if true echo "false" >'$HOME'/useprog2opt</action>
<action>if true echo "false" >'$HOME'/useprog3opt</action>
<action>refresh:RUNPROG1OPT</action>
<action>refresh:RUNPROG2OPT</action>
<action>refresh:RUNPROG3OPT</action>
</togglebutton>
<togglebutton tooltip-text=" When clicking this button (Program 2 exclusive) the other button (Program 1 exclusive, Program 3 exclusive) should un-select automatically - just like the radio buttons do. The options are stored properly, though the GUI does not refresh.">
<label>"Program 2 exclusive "</label>
<input file icon="edit48"></input>
<input>cat $HOME/useprog2opt</input>
<variable>RUNPROG2OPT</variable>
<action>if true echo "false" >'$HOME'/useprog1opt</action>
<action>if true echo "true" >'$HOME'/useprog2opt</action>
<action>if false echo "false" >'$HOME'/useprog2opt</action>
<action>if true echo "false" >'$HOME'/useprog3opt</action>
<action>refresh:RUNPROG1OPT</action>
<action>refresh:RUNPROG2OPT</action>
<action>refresh:RUNPROG3OPT</action>
</togglebutton>
<togglebutton tooltip-text=" When clicking this button (Program 3 exclusive) the other button (Program 1 exclusive, Program 2 exclusive) should un-select automatically - just like the radio buttons do. The options are stored properly, though the GUI does not refresh.">
<label>"Program 3 exclusive "</label>
<input file icon="archive48"></input>
<input>cat $HOME/useprog3opt</input>
<variable>RUNPROG3OPT</variable>
<action>if true echo "false" >'$HOME'/useprog1opt</action>
<action>if true echo "false" >'$HOME'/useprog2opt</action>
<action>if true echo "true" >'$HOME'/useprog3opt</action>
<action>if false echo "false" >'$HOME'/useprog3opt</action>
<action>refresh:RUNPROG1OPT</action>
<action>refresh:RUNPROG2OPT</action>
<action>refresh:RUNPROG3OPT</action>
</togglebutton>
</vbox>
</vbox>
'$ESCAPEGUIPART'
</window>'
export TOGGLEBTNGUI=$(echo "$TOGGLEBTNGUI" | sed 's/#[#~].*$//') # Strip comments
gtkdialog4 --class=TOGGLEBTNGUI -p TOGGLEBTNGUI --center >/dev/null
unset TOGGLEBTNGUI
What a difference...
a day makes...
This <input>cat $HOME/useprog2opt</input> seems to work as expected!
Thanks!
Edit:
Applied to my Program and all works as expected and wanted out of the box!
Thanks again!
Code: Select all
<input>cat $HOME/useprog2opt</input>
Code: Select all
<input>'$(cat $HOME/useprog2opt)</input>
Thanks!
Edit:
Applied to my Program and all works as expected and wanted out of the box!
Thanks again!