force update of radiobutton in gtkdialog

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
sc0ttman
Posts: 2812
Joined: Wed 16 Sep 2009, 05:44
Location: UK

force update of radiobutton in gtkdialog

#1 Post by sc0ttman »

i'd like to force update of a radiobutton in gtkdialog from within the gui itself.. i can't seem to make it work..

EDIT... SOLVED: see my next post.

Basically, when I click a button somewhere, I want the selected values of a couple of radiobuttons elsewhere (another tab in a <notebook>) to be changed to match the new values of their vars ($PKGSCOPE1 and $PKGSCOPE2)....

i have something like (just an example, but basically right):

Code: Select all

the_func(){
if [ "$PKGSCOPE1" = true ];then
  PKGSCOPE1=false
else
  PKGSCOPE1=true
fi
if [ "$PKGSCOPE2" = true ];then
  PKGSCOPE2=false
else
  PKGSCOPE2=true
fi
export PKGSCOPE1
export PKGSCOPE2
}

GUI='<window><frame>
<button>
<action>the_func</action>
<action>refresh:PKGSEARCH1</action>
<action>refresh:PKGSEARCH2</action>
</button>

<hbox>
<radiobutton>
<variable>PKGSEARCH1</variable>
<default>"'$PKGSEARCH1'"</default>
</radiobutton>
<radiobutton>
<variable>PKGSEARCH2</variable>
<default>"'$PKGSEARCH2'"</default>
</radiobutton>
</hbox>

</frame>
</window>'
(i'm using bash not ash to run the script..)

EDIT: Likewise, I want the same button to update the pre-selected value of a <combobox>, which is in yet another tab of the <notebook>..
Last edited by sc0ttman on Mon 12 Aug 2013, 20:40, edited 1 time in total.
[b][url=https://bit.ly/2KjtxoD]Pkg[/url], [url=https://bit.ly/2U6dzxV]mdsh[/url], [url=https://bit.ly/2G49OE8]Woofy[/url], [url=http://goo.gl/bzBU1]Akita[/url], [url=http://goo.gl/SO5ug]VLC-GTK[/url], [url=https://tiny.cc/c2hnfz]Search[/url][/b]

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

#2 Post by sunburnt »

Hi sc0ttman; If you notice, Puppy`s pmount dies then restarts to refresh the GUI.

But I think there`s a way to do it in code since GtkDialog is active again.

The dev. page:
http://www.murga-linux.com/puppy/viewtopic.php?t=69188

And zigbert`s tips:
http://www.murga-linux.com/puppy/viewtopic.php?t=38608

User avatar
sc0ttman
Posts: 2812
Joined: Wed 16 Sep 2009, 05:44
Location: UK

#3 Post by sc0ttman »

Sorted:

added

Code: Select all

<radiobutton auto-refresh="true">
<variable>PKGSCOPEONE</variable>
<input file>/tmp/PKGSCOPEONE</input>
...
</radiobutton>
and can toggle with these commands:

Code: Select all

echo -n false > /tmp/PKGSCOPEONE; echo -n true > /tmp/PKGSCOPEALL;

Code: Select all

echo -n true > /tmp/PKGSCOPEONE; echo -n false > /tmp/PKGSCOPEALL;
[b][url=https://bit.ly/2KjtxoD]Pkg[/url], [url=https://bit.ly/2U6dzxV]mdsh[/url], [url=https://bit.ly/2G49OE8]Woofy[/url], [url=http://goo.gl/bzBU1]Akita[/url], [url=http://goo.gl/SO5ug]VLC-GTK[/url], [url=https://tiny.cc/c2hnfz]Search[/url][/b]

User avatar
don570
Posts: 5528
Joined: Wed 10 Mar 2010, 19:58
Location: Ontario

#4 Post by don570 »

When I was writtingpuppy-rsync I found it impossible to transfer the
values of the radiobutton variable to a function.


I was able to solve the problem by putting

Code: Select all

set -a 


near beginning of program. This transfers widget gtkdialog variables
in a useful way. The user clicks on a button in window and the
true/false values of radio buttons are transfered to a function that
does a launch.

That is how I transfer the folder number ( one to five)
___________________________________________________

User avatar
don570
Posts: 5528
Joined: Wed 10 Mar 2010, 19:58
Location: Ontario

#5 Post by don570 »

I have been testing Scottman's idea in my program
puppy-rsync. I included a button 'Test' in the window to test
if I could manipulate the radio buttons false/true state.

I found that I could but I had to use set -a as well.

The radiobutton widget was modified like this

Code: Select all

 <radiobutton auto-refresh="true">
<input file>/root/FILE</input> 
 ...
 
..and the button widget was ..

Code: Select all

 <button>
       <input file stock="gtk-ok"></input>
      <label>'$(gettext 'Test')'</label>
      <action>echo -n true > /root/FILE;</action>
</button>

I found I could do some useful things :wink:

Image
_________________________________

Post Reply