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 Wed 19 Feb 2020, 02:44
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 99 of 99 [1482 Posts]   Goto page: Previous 1, 2, 3, ..., 97, 98, 99
Author Message
MochiMoppel


Joined: 26 Jan 2011
Posts: 1975
Location: Japan

PostPosted: Mon 12 Aug 2019, 22:50    Post subject:  

misko_2083 wrote:
I would try next: Smile
Code:
 step=$(( 100 / cnt )).$(( (100 * 100 / cnt) % 100 ))

1.78
I wouldn't Laughing
Remember that you would still have to add these values up. In bash? Good luck!

I find my approach much easier. Besides: The progressbar doesn't seem to care about fractions. Non-numeric characters after an integer are ignored. It doesn't matter if you echo a value of 1 or 1.99999 or even 1blabla, the bar will always show exactly 1% .
Back to top
View user's profile Send private message 
TwoPuppies


Joined: 29 Dec 2010
Posts: 77
Location: Melbourne, Australia

PostPosted: Tue 13 Aug 2019, 00:46    Post subject:  

MochiMoppel wrote:
Change step=$((100/cnt)) to step=$((100000/cnt))
and
echo $bar to echo $((bar/1000))

This worked as expected. The Progress Bar continued all the way to the end before the window closed. Thanks MochiMoppel.

misko_2083 wrote:
I would try next: Smile
Code:
step=$(( 100 / cnt )).$(( (100 * 100 / cnt) % 100 ))

This caused the Progress Bar to freeze after only one Package was installed. No more Packages installed after that.

_________________
What you really need is two puppies:
Puppy Linux, and the sort with four legs and a tail.

Back to top
View user's profile Send private message 
MochiMoppel


Joined: 26 Jan 2011
Posts: 1975
Location: Japan

PostPosted: Tue 13 Aug 2019, 03:53    Post subject:  

TwoPuppies wrote:
This worked as expected.

Back to top
View user's profile Send private message 
misko_2083


Joined: 08 Nov 2016
Posts: 101

PostPosted: Tue 13 Aug 2019, 04:48    Post subject:  

MochiMoppel wrote:
misko_2083 wrote:
I would try next: Smile
Code:
 step=$(( 100 / cnt )).$(( (100 * 100 / cnt) % 100 ))

1.78
I wouldn't Laughing
Remember that you would still have to add these values up. In bash? Good luck!

I find my approach much easier. Besides: The progressbar doesn't seem to care about fractions. Non-numeric characters after an integer are ignored. It doesn't matter if you echo a value of 1 or 1.99999 or even 1blabla, the bar will always show exactly 1% .

I know, just forgot to mention that I used the pure bash calculator.
I saved && made executable this script https://github.com/bluebat/.bash/blob/master/bashbc.sh
Code:

    IFS=$'\n'
    array=($PACKAGELIST)
    cnt=${#array[@]}

    step=$(( 100 / cnt )).$(( (100 * 100 / cnt) % 100 ))
    bar=$step
    for ((c=0;c<$cnt;c++));do
        file=${array[$c]}
        echo $bar                #progress indicator (MUST be number)
        echo $file               #text within progress bar (MUST NOT start with number)
       # set the path to bashbc.sh here !
        bar=$(scale=2 bashbc.sh $bar+$step)        #increase progress indicator
    done;
    echo 100 


The calculator script works like this
Code:
bashbc.sh 2.555+6.335
8.89
scale=2 bashbc.sh 2*(3/7)
0.84

Maybe not so precise but good enough for a progress bar.
Back to top
View user's profile Send private message 
recobayu


Joined: 15 Sep 2010
Posts: 381
Location: indonesia

PostPosted: Sat 14 Sep 2019, 13:34    Post subject:  

I have 20 button inside of scrollable vbox. When I use down arrow keyboard to move from one button to another button below that, after some button, the button not appear. Butwhen I usemoise to scroll down, it is select on that button. How to make the button always seen when we use down arrow keyboard? Just like tree. Is it possible? Thank you.
Back to top
View user's profile Send private message 
MochiMoppel


Joined: 26 Jan 2011
Posts: 1975
Location: Japan

PostPosted: Sun 29 Sep 2019, 02:35    Post subject:  

recobayu wrote:
How to make the button always seen when we use down arrow keyboard? Just like tree. Is it possible?
No.
Back to top
View user's profile Send private message 
recobayu


Joined: 15 Sep 2010
Posts: 381
Location: indonesia

PostPosted: Thu 05 Dec 2019, 04:10    Post subject:  

I have an exploration about bolding a text that use-markup. We must call a function outside of gtkdialog code. Like this:
Code:
#!/bin/sh
touch tebalku
tebal(){
   printf "<b>$e</b>" > tebalku
}
export -f tebal

echo '
<window>
   <vbox>
      <entry>
         <action>tebal</action>
         <action>refresh:tt</action>
         <variable>e</variable>
      </entry>
      <text xalign="1" use-markup="true">
         <input file>tebalku</input>
         <variable>tt</variable>
      </text>
   </vbox>
</window>'|gtkdialog -s


I try to add printf "<b>"$e"</b>" in action of entry. But it fail. So I must call it from outside function.
Screenshot.png
 Description   bold text automatically
 Filesize   3.16 KB
 Viewed   260 Time(s)

Screenshot.png

Back to top
View user's profile Send private message 
MochiMoppel


Joined: 26 Jan 2011
Posts: 1975
Location: Japan

PostPosted: Thu 05 Dec 2019, 05:47    Post subject:  

recobayu wrote:
I try to add printf "<b>"$e"</b>" in action of entry. But it fail.
...not when you escape the pango tags:
Code:
#!/bin/bash
echo '
<window>
<vbox>
   <entry>
      <action>refresh:tt</action>
      <variable>e</variable>
   </entry>
   <text xalign="1" use-markup="true">
      <input>printf \<b\>"$e"\</b\></input>
      <variable>tt</variable>
   </text>
</vbox>
</window>'|gtkdialog -s
Back to top
View user's profile Send private message 
d4rkn1ght


Joined: 19 Jan 2010
Posts: 36

PostPosted: Wed 25 Dec 2019, 11:57    Post subject:  Button Delay
Subject description: Pause before closing
 

First of all, I’m a beginner. All I’ve done so far is pasted code from other sources and molded to the direction I want to go. I still don’t know how to actually make something like you guys. Razz

Anyway, I’ve been trying to have a button that pauses for a few seconds before it closes the button window.

This is what I have so far. Is this right? It works in Tahrpup.

Code:

<button>
  <label>Connect</label>
  <input file icon="gtk-yes"></input>
  <action>/usr/bin/start-gtkdialog-script.sh &</action>
  <action>sleep 8;</action>
  <action>Exit:exit &</action>
</button>
Back to top
View user's profile Send private message Visit poster's website 
Moose On The Loose


Joined: 24 Feb 2011
Posts: 883

PostPosted: Wed 25 Dec 2019, 14:26    Post subject: Re: Button Delay
Subject description: Pause before closing
 

d4rkn1ght wrote:
First of all, I’m a beginner. All I’ve done so far is pasted code from other sources and molded to the direction I want to go. I still don’t know how to actually make something like you guys. Razz

Anyway, I’ve been trying to have a button that pauses for a few seconds before it closes the button window.

This is what I have so far. Is this right? It works in Tahrpup.

Code:

<button>
  <label>Connect</label>
  <input file icon="gtk-yes"></input>
  <action>/usr/bin/start-gtkdialog-script.sh &</action>
  <action>sleep 8;</action>
  <action>Exit:exit &</action>
</button>


Yes, that looks about right. I tend to make only one action per button but what you have should work. I do question the "&" in the last action. I suspect that it just gets ignored.
Back to top
View user's profile Send private message 
d4rkn1ght


Joined: 19 Jan 2010
Posts: 36

PostPosted: Wed 25 Dec 2019, 16:14    Post subject: Re: Button Delay
Subject description: Pause before closing
 

Moose On The Loose wrote:
d4rkn1ght wrote:
First of all, I’m a beginner. All I’ve done so far is pasted code from other sources and molded to the direction I want to go. I still don’t know how to actually make something like you guys. Razz

Anyway, I’ve been trying to have a button that pauses for a few seconds before it closes the button window.

This is what I have so far. Is this right? It works in Tahrpup.

Code:

<button>
  <label>Connect</label>
  <input file icon="gtk-yes"></input>
  <action>/usr/bin/start-gtkdialog-script.sh &</action>
  <action>sleep 8;</action>
  <action>Exit:exit &</action>
</button>


Yes, that looks about right. I tend to make only one action per button but what you have should work. I do question the "&" in the last action. I suspect that it just gets ignored.


Thank you! Cool
Back to top
View user's profile Send private message Visit poster's website 
don570


Joined: 10 Mar 2010
Posts: 5482
Location: Ontario

PostPosted: Thu 30 Jan 2020, 18:05    Post subject: a script to explain the refresh action  

For beginners here is a script to explain the refresh action when it is given to a entry widget by another widget.
Explanation: Choosing a folder starts the estimate function.
Estimate function will return a number above zero
(This is the time estimate of the compression. The formula is based on SIZE)
Variable TIME is updated i.e. refreshed
Code:
<action>refresh:TIME</action>


This can be done over and over.

Code:

#!/bin/bash
# example to show refresh

export TEXTDOMAIN=refresh.sh
export OUTPUT_CHARSET=UTF-8

TEXT="$(gettext 'Select a folder')"

###############################################
#                                             #
#                 ESTIMATE                    #
#                                             #
###############################################
estimate(){

SIZE=`du -s "$DIR"  | awk '{print $1}'`
let "TIME_ESTIMATE = $SIZE * 40 / 1029000"
if  [   "$TIME_ESTIMATE" -le 0  ];then
TIME_ESTIMATE=1
fi
echo $TIME_ESTIMATE > /tmp/compression_estimate
}
export -f estimate

###############################################
#                                             #
#                 MAIN GUI                    #
#                                             #
###############################################

export EXAMPLE='
<window title="Example"  resizable="false">
<vbox   width-request="500">

        <text height-request="10"><label>""</label></text>
        <text><label>"'$TEXT'"</label></text>
 
<hbox>       
        <entry accept="directory"  activates_default="true">       
        <input>cat  /tmp/compression_path</input>
        <variable>DIR</variable>
        </entry>
        <button  tooltip-text="'$(gettext 'Select a directory')'">
        <input file stock="gtk-open"></input>
        <action type="fileselect">DIR</action>
        <action>estimate</action> 
        <action>refresh:TIME</action>               
       </button>   
</hbox>
<text height-request="20"><label>""</label></text>
<hseparator></hseparator>
<hbox  homogeneous="true">
      <text>
      <label>'$(gettext 'Time for Compression')'</label>
       </text></hbox>
<hbox  homogeneous="true">
<hbox width-request="130">           
      <entry editable="false">   
      <variable>TIME</variable>
      <input>cat /tmp/compression_estimate</input>
      </entry>
      <text>
      <label>'$(gettext 'second(s)')'</label>
      </text>
</hbox>     
</hbox>   
 
 <hbox>
 <button>
        <input file stock="gtk-cancel"></input>
        <label>'$(gettext 'Quit')'</label>
        <action type="exit">CLOSE</action>
</button>   
</hbox>
</vbox>
</window>'

gtkdialog --center -p EXAMPLE

rm -f  /tmp/compression_*



More advanced examples http://murga-linux.com/puppy/viewtopic.php?p=648151#648151
refresh.sh.gz
Description  remove fake extension
gz

 Download 
Filename  refresh.sh.gz 
Filesize  2.19 KB 
Downloaded  7 Time(s) 
screenshot-example.png
 Description   
 Filesize   9.9 KB
 Viewed   111 Time(s)

screenshot-example.png

Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 99 of 99 [1482 Posts]   Goto page: Previous 1, 2, 3, ..., 97, 98, 99
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.1261s ][ Queries: 12 (0.0369s) ][ GZIP on ]