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 Mon 19 Nov 2018, 09:47
All times are UTC - 4
 Forum index » Off-Topic Area » Programming
gtkdialog problem
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 1 [8 Posts]  
Author Message
ITSMERSH


Joined: 02 May 2018
Posts: 465

PostPosted: Tue 06 Nov 2018, 19:35    Post subject:  gtkdialog problem
Subject description: radiobutton vs togglebutton
 

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...

_________________
RSH
Back to top
View user's profile Send private message 
ITSMERSH


Joined: 02 May 2018
Posts: 465

PostPosted: Tue 06 Nov 2018, 20:06    Post subject:  

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.

_________________
RSH
Back to top
View user's profile Send private message 
ITSMERSH


Joined: 02 May 2018
Posts: 465

PostPosted: Tue 06 Nov 2018, 21:25    Post subject:  

This <action>refresh:THEBUTTON</action> still won't work! Confused

No matter what I've tried. It won't refresh the button...

_________________
RSH
Back to top
View user's profile Send private message 
wiak

Joined: 11 Dec 2007
Posts: 996
Location: not Bulgaria

PostPosted: Tue 06 Nov 2018, 21:28    Post subject:  

ITSMERSH wrote:

<default>'$(cat $APPDIR/data/useqtractoropt)'</default>

will give the stored option to the toggle button.


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?

<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
Back to top
View user's profile Send private message 
ITSMERSH


Joined: 02 May 2018
Posts: 465

PostPosted: Tue 06 Nov 2018, 23:30    Post subject:  

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.

_________________
RSH
Back to top
View user's profile Send private message 
ITSMERSH


Joined: 02 May 2018
Posts: 465

PostPosted: Wed 07 Nov 2018, 00:07    Post subject:  

Ok,

here it is.

Code:
#!/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

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. Rolling Eyes

_________________
RSH
Back to top
View user's profile Send private message 
wiak

Joined: 11 Dec 2007
Posts: 996
Location: not Bulgaria

PostPosted: Wed 07 Nov 2018, 05:07    Post subject:  

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:
#!/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
Back to top
View user's profile Send private message 
ITSMERSH


Joined: 02 May 2018
Posts: 465

PostPosted: Wed 07 Nov 2018, 05:19    Post subject:  

What a difference...

Code:
<input>cat $HOME/useprog2opt</input>


a day makes...

Code:
<input>'$(cat $HOME/useprog2opt)</input>


This <input>cat $HOME/useprog2opt</input> seems to work as expected! Cool

Thanks! Very Happy

Edit:

Applied to my Program and all works as expected and wanted out of the box!

Thanks again!

_________________
RSH
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 1 of 1 [8 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.0638s ][ Queries: 11 (0.0051s) ][ GZIP on ]