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 Thu 31 Jul 2014, 05:29
All times are UTC - 4
 Forum index » Off-Topic Area » Programming
GtkDialog - tips
Post new topic   Reply to topic View previous topic :: View next topic
Page 56 of 63 [942 Posts]   Goto page: Previous 1, 2, 3, ..., 54, 55, 56, 57, 58, ..., 61, 62, 63 Next
Author Message
recobayu


Joined: 15 Sep 2010
Posts: 112
Location: indonesia

PostPosted: Fri 30 Aug 2013, 22:06    Post subject: notebook trick  

I learn something very usefull with notebook from here:
/usr/share/doc/gtkdialog/examples/notebook/notebook_advanced
I uncomment the dump line and I know some trick, there is in the inputfile:
0 --> tab0
1 --> tab1
...
here is my code:
Code:
#!/bin/bash
cek(){
   if [[ $E = "" ]]; then
      #echo kosong
      echo 0 > inputfile
   else
      #echo ada
      echo 1 > inputfile
   fi
}
export -f cek
Width=`xwininfo -root | grep Width | awk '{ print $2 }'`
Height=`xwininfo -root | grep Height | awk '{ print $2 }'`
export aku='
<window title="nbkNotebook" width-request="'$Width'" height-request="'$Height'">
  <vbox>
      <entry>
         <variable>E</variable>
         <action>cek</action>
         <action>refresh:nbk0</action>
      </entry>
      <notebook show-tabs="false" show-border="false">
         <vbox border-width="20">
            <text label="this is the main start metro"></text>
         </vbox>
         <vbox border-width="20">
            <text label="and this is the search window"></text>
         </vbox>
         <variable>nbk0</variable>
         <input file>inputfile</input>
      </notebook>
  </vbox>
</window>'
gtkdialog --program=aku

if we type in the entry box, we can see the window get different face, and when we clear the entrybox, the window back to the our first face.
Nice gtkdialog Very Happy
I Like it
Back to top
View user's profile Send private message 
don570


Joined: 10 Mar 2010
Posts: 3220
Location: Ontario

PostPosted: Sat 31 Aug 2013, 13:47    Post subject:  

Here's a simple example to show how the refresh button works.

Just enter text in Entry box and click 'REFRESH'.

The entry goes to the
head of a text file that in displayed in comboboxtext widget

The refresh button code looks like this. Add another action tag line and
the refresh button could do some useful function.

Code:
    <button>
               <label>refresh</label>
               <action>list_refresh</action>
               <action>refresh:LIST_ENTRY</action>
          </button>



Script-refresh.gz
Description  remove fake gz extension
gz

 Download 
Filename  Script-refresh.gz 
Filesize  1.37 KB 
Downloaded  176 Time(s) 
Back to top
View user's profile Send private message 
don570


Joined: 10 Mar 2010
Posts: 3220
Location: Ontario

PostPosted: Tue 03 Sep 2013, 20:07    Post subject: example of refreshing  

More examples of practical refreshing...

This example(suggested by Nathan F) shows the contents of a dot file in /root.
The user then selects a file on the list and then
a function can be run by clicking button.

To make the comboboxtext items a command was used

Code:
find $HOME -maxdepth 1 -mindepth 1 -type d -name ".*"


Script-tree.gz
Description  remove fake gz extension
gz

 Download 
Filename  Script-tree.gz 
Filesize  1.51 KB 
Downloaded  156 Time(s) 
Back to top
View user's profile Send private message 
don570


Joined: 10 Mar 2010
Posts: 3220
Location: Ontario

PostPosted: Tue 03 Sep 2013, 20:14    Post subject:  

Here is another refresh example using comboboxtext.
The letters of alphabet are the items. Choosing a letter will
refresh the righthand side list of applications found installed.
Note the first letter of application.

Then a selection of the list can be further used by a function.
(Click on button 'refresh' to see what is possible with selection)



____________________________________________________
Script-app.gz
Description  Remove fake extension
gz

 Download 
Filename  Script-app.gz 
Filesize  2.09 KB 
Downloaded  149 Time(s) 

Last edited by don570 on Tue 03 Sep 2013, 20:25; edited 1 time in total
Back to top
View user's profile Send private message 
don570


Joined: 10 Mar 2010
Posts: 3220
Location: Ontario

PostPosted: Tue 03 Sep 2013, 20:20    Post subject:  

Here is the same example as before but instead of a comboboxtext widget
a list widget is used. It then refreshes a tree .
A selection of the tree can then be further processed by
clicking on the button.



Script-list.gz
Description  remove fake gz extension
gz

 Download 
Filename  Script-list.gz 
Filesize  1.64 KB 
Downloaded  151 Time(s) 
Back to top
View user's profile Send private message 
recobayu


Joined: 15 Sep 2010
Posts: 112
Location: indonesia

PostPosted: Sat 07 Sep 2013, 11:50    Post subject:  

Hi don570, I am very interested about refresh. How to refresh the label of button? Until this time, i use input file, and then i make an svg file to change the button's label. something like this:
Code:
#!/bin/sh

changei(){
   if [ -f /tmp/i ];then
      i=`cat /tmp/i`
   else
      i=1
   fi
   i=$(($i+1))
   echo $i >/tmp/i
   echo '<svg><text x="0" y="9"><tspan>'$i'</tspan></text></svg>'>/tmp/angkaku.svg
}
export -f changei
j=0  #i add this value. but still same, the label doesn't want to walk
ln -sf /root/puppy-reference/midi-icons/edit48.png /tmp/gbku.png
echo '<svg><text x="0" y="9"><tspan>1</tspan></text></svg>'>/tmp/angkaku.svg
export gantiBil='
<window>
   <hbox>
         <button width-request="48" height-request="48">
            <variable>a</variable>
            <label>"'$j'"</label>
            <action>j=$(($j+1))</action>
            <action>refresh:a</action>
         </button>
         <entry visible="false">
            <variable>E</variable>
         </entry>
         <button>
            <variable>b</variable>
            <width>48</width>
            <height>48</height>
            <input file>/tmp/gbku.png</input>
            <action>fileselect:E</action>
            <action>ln -sf $E /tmp/gbku.png</action>
            <action>refresh:b</action>
         </button>
         <button width-request="48" height-request="48">
            <variable>c</variable>
            <input file>/tmp/angkaku.svg</input>
            <action>changei</action>
            <action>refresh:c</action>
         </button>
   </hbox>
</window>'
gtkdialog --program=gantiBil

rm /tmp/gbku.png
rm /tmp/angkaku.svg
rm /tmp/i
exit


Edit:
I have 3 buttons. I think this is better than toggle button, because toggle button just have two condition (yes or no), and I think the button is more flexible.
The first, I want to change the label, but not work.
The second, we can change the picture by clicking that button, and select picture file (.jpg, .png, or .svg).
The third, this is my tricky method. I use svg, that can seen as label.
Is possible to change the label button? (in my example, the first button).
Thank You.

Now, I know that gtkdialog still can't refresh button.
I hope in the future, gtkdialog can refresh button, or maybe the vbox and hbox. So we can change everything inside the vbox or hbox without close the gtkdialog. I very like this gtkdialog and I start to enjoy this programming language.
Very Happy

Last edited by recobayu on Tue 10 Sep 2013, 07:53; edited 1 time in total
Back to top
View user's profile Send private message 
Nathan F


Joined: 08 Jun 2005
Posts: 1760
Location: Wadsworth, OH (occasionally home)

PostPosted: Sat 07 Sep 2013, 14:57    Post subject:  

A simple method would be to make two buttons and use show/hide actions to hide the first and show the second, or vice versa. I've used it on a few other widgets and it works pretty flawlessly.

The only drawback comes in with large groups of widgets, where there will be a speed and startup penalty due to the sheer size of it all. Not a problem for just one or two widgets.

_________________
Bring on the locusts ...
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger 
don570


Joined: 10 Mar 2010
Posts: 3220
Location: Ontario

PostPosted: Mon 09 Sep 2013, 14:30    Post subject: toggle button example  

to recobayu : You should have given j an initial value so that
something would have shown in that button... but
apparently gtkdialog has no method to change a script variable
used by a widget Crying or Very sad

___________________________________________________

I looked at Thunor's examples and I spotted a toggle button example.

One button sends a signal to another button to show and hide.

I have simplified the code as much as possible. Look at the
code to see if it is useful. Togglebutton official page

toggle_example.gz
Description  remove fake gz extension
gz

 Download 
Filename  toggle_example.gz 
Filesize  612 Bytes 
Downloaded  156 Time(s) 

Last edited by don570 on Mon 09 Sep 2013, 16:13; edited 2 times in total
Back to top
View user's profile Send private message 
don570


Joined: 10 Mar 2010
Posts: 3220
Location: Ontario

PostPosted: Mon 09 Sep 2013, 14:39    Post subject: odd number toggle  

I thought up this wacky example by combining a Toggle button with
a svg image and another button that is refreshed.

By clicking on the right hand icon the number on the left hand button
increases by two. This means that only an odd number will show.





______________________

______________________
odd-number.sh.gz
Description  remove fake gz extension
gz

 Download 
Filename  odd-number.sh.gz 
Filesize  1.2 KB 
Downloaded  158 Time(s) 
Back to top
View user's profile Send private message 
don570


Joined: 10 Mar 2010
Posts: 3220
Location: Ontario

PostPosted: Wed 11 Sep 2013, 20:15    Post subject:  

This example restricts the size of buttons so the text appears
normal sized.


odd-number2.sh.gz
Description  remove fake gz extension
gz

 Download 
Filename  odd-number2.sh.gz 
Filesize  1.54 KB 
Downloaded  146 Time(s) 
Back to top
View user's profile Send private message 
recobayu


Joined: 15 Sep 2010
Posts: 112
Location: indonesia

PostPosted: Wed 11 Sep 2013, 23:00    Post subject:  

To appear the text in normal size, we can use group in svg. this is my example Very Happy
Code:
#!/bin/sh
echo '<svg><g><rect style="fill-opacity:0" width="1" height="10"/><text x="0" y="9">0</text></g></svg>'>/tmp/angkaku.svg
changei(){
   if [ -f /tmp/i ];then
      i=`cat /tmp/i`
   else
      i=0
   fi
   i=$(($i+1))
   echo $i >/tmp/i
   echo '<svg><g><rect style="fill-opacity:0" width="1" height="10"/><text x="0" y="9">'$i'</text></g></svg>'>/tmp/angkaku.svg
}
export -f changei

export gantiBil='
<window>
   <hbox>
      <button>
         <variable>c</variable>
         <width>110</width>
         <input file>/tmp/angkaku.svg</input>
         <action>changei</action>
         <action>refresh:c</action>
      </button>
   </hbox>
</window>'
gtkdialog --program=gantiBil -c --space-expand=true --space-fill=true

rm /tmp/angkaku.svg
rm /tmp/i
exit
Back to top
View user's profile Send private message 
sunburnt


Joined: 08 Jun 2005
Posts: 5010
Location: Arizona, U.S.A.

PostPosted: Tue 01 Oct 2013, 01:08    Post subject:  

Hi guys; So much info. and no way to access it all.!

I`m writing a GtkDialog script for the first time in a very long while.
I don`t like it much, but it does work with all of the Puppy variations.

# I can`t remember how to get a button to close the dialog with an: <action>
EXIT doesn`t seem to work, nether does most examples I have.
Code:
#!/bin/sh
BTNs=$(echo "$PKGs" |while read PKG
do
   echo "
     <button>
      <label>$PKG</label>
      <action>$PKG</action>
      <action>EXIT</action>
     </button>"
done)

export MENU_DLG='
<window title=" Libs.">
 <vbox>
  <text>
    <label>Select a Package.</label>
  </text>
'$BTNs'
  <hbox>
   <button ok></button>
   <button cancel></button>
  </hbox>
 </vbox>
</window>
'
gtkdialog --program=MENU_DLG

### Many thanks!
.
Back to top
View user's profile Send private message 
SFR


Joined: 26 Oct 2011
Posts: 1044

PostPosted: Tue 01 Oct 2013, 07:15    Post subject:  

To close the dialog right after pressing a button, right?
Code:
<action>$PKG &</action>
<action>EXIT:exit</action>

exit is kind of return code, so might be anything really...

Greetings!

_________________
[O]bdurate [R]ules [D]estroy [E]nthusiastic [R]ebels => [C]reative [H]umans [A]lways [O]pen [S]ource
Omnia mea mecum porto.
Back to top
View user's profile Send private message 
sunburnt


Joined: 08 Jun 2005
Posts: 5010
Location: Arizona, U.S.A.

PostPosted: Tue 01 Oct 2013, 18:25    Post subject:  

And Greetings to you SFR; I thank you kindly for your help.
I now recall this bit of GtkDialog code thanks to you. I have the menu gui working great.

The menu will be usable for downloading binary or source packages and setting them up.

Last edited by sunburnt on Fri 04 Oct 2013, 04:17; edited 1 time in total
Back to top
View user's profile Send private message 
don570


Joined: 10 Mar 2010
Posts: 3220
Location: Ontario

PostPosted: Thu 03 Oct 2013, 19:11    Post subject:  

I have a page devoted to the exit variable in the
Gtkdialog Tutorial Manual

http://murga-linux.com/puppy/viewtopic.php?t=89045

_____________________________________
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 56 of 63 [942 Posts]   Goto page: Previous 1, 2, 3, ..., 54, 55, 56, 57, 58, ..., 61, 62, 63 Next
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.1318s ][ Queries: 13 (0.0208s) ][ GZIP on ]