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 20 Apr 2014, 20:06
All times are UTC - 4
 Forum index » Off-Topic Area » Programming
Togglebutton examples
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 1 [2 Posts]  
Author Message
don570


Joined: 10 Mar 2010
Posts: 3078
Location: Ontario

PostPosted: Thu 06 Feb 2014, 15:18    Post subject:  Togglebutton examples  

script-toggle3 --->

I have tried to avoid using SVG image buttons by using the
togglebutton widget.

The toggle button emits a signal for buttons to hide or show.

If I had used an SVG image instead of togglebutton widget
then the label and color of button could have
been changed when I switched from American cities to Canadian cities.

Warning!! I've used a non-ASCII character in this example(the bullet symbol).
It's not a good practice since gettext checks for non-ASCII characters.




___________________________________________________________

In script-toggle2 script I change a list with a togglebutton widget sending the signal.


___________________________________________
script-toggle3.gz
Description  remove fake extension --- buttons are changed by togglebutton
gz

 Download 
Filename  script-toggle3.gz 
Filesize  2.46 KB 
Downloaded  36 Time(s) 
script-toggle2.gz
Description  remove fake gz extension---- list is changed by togglebutton
gz

 Download 
Filename  script-toggle2.gz 
Filesize  1.71 KB 
Downloaded  37 Time(s) 

Last edited by don570 on Sat 08 Feb 2014, 16:52; edited 1 time in total
Back to top
View user's profile Send private message 
don570


Joined: 10 Mar 2010
Posts: 3078
Location: Ontario

PostPosted: Sat 08 Feb 2014, 16:47    Post subject:  

I've thought about the problem and I've found that the easiest
method of toggling is with two radiobutton widgets.
One is active and contains the action directives.
Because the widget is active , the action directives will be done
when the window is first formed on screen. That is why only three
buttons will form on screen at first launch.

Code:
<radiobutton active="true">


The code is simple so I'll list it.



Code:

#!/bin/bash

export MAIN_DIALOG='
<window title="Toggle text" resizable="false" border-width="20">
   <vbox>   
            <button>
                  <label>New York</label>
                  <variable>Button1</variable>
                  <action>xmessage "Button clicked"</action>
            </button>
            <button>
                  <label>Washington</label>
                  <variable>Button2</variable>
                  <action>xmessage "Button clicked"</action>
            </button>
            <button>
                  <label>Los Angeles</label>
                  <variable>Button3</variable>
                  <action>xmessage "Button clicked"</action>
            </button>
            <button>
                  <label>Toronto</label>
                  <variable>Button4</variable>
                  <action>xmessage "Button clicked"</action>
            </button>
            <button>
                  <label>Montreal</label>
                  <variable>Button5</variable>
                  <action>xmessage "Button clicked"</action>
            </button>
            <button>
                  <label>Vancouver</label>
                  <variable>Button6</variable>
                  <action>xmessage "Button clicked"</action>
            </button>
            <text><label>""</label></text>
<hseparator></hseparator>
                  
         
                <radiobutton>               
                  <label>Canadian cities</label>                  
            </radiobutton>            
            
            
             <radiobutton active="true">               
                   <label>American cities</label>                  
                   <action>if true show:Button1</action>
                   <action>if false hide:Button1</action>
                        <action>if true show:Button2</action>
                  <action>if false hide:Button2</action>
                  <action>if true show:Button3</action>
                  <action>if false hide:Button3</action>
                  <action>if true hide:Button4</action>
                  <action>if false show:Button4</action>
                        <action>if true hide:Button5</action>
                  <action>if false show:Button5</action>
                   <action>if true hide:Button6</action>
                  <action>if false show:Button6</action>
            </radiobutton>   
      
   </vbox>   
</window>'

gtkdialog --program=MAIN_DIALOG

Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 1 of 1 [2 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.0552s ][ Queries: 12 (0.0049s) ][ GZIP on ]