wxBasicscript-Help

noframes
Example: using a gauge (Progress-bar)
The gauge wants to get its values sent via Shellscript-echo-commands.
So I create those commands in wxbasicScript, and send them through a pipe(|) to the gauge.
You could add any commands, for example check the size of a large zip (50 MB) you create.
The example shows, that the gauge is really reacting to events.
First I define the commands.
Then I run xcalc in Background.
Now I launch the progressbar (gauge).
It is feeded from the shell-commands, that check with help of "ps", if xcalc still is running.
If not, the gauge is closed (exit).
If yes, the value in increased in 20%-steps, until 100% is reached.
If 100% is reached, xcalc is killed and the script ends.
So run it, and close xcalc, when the gauge reaches 40%, you will see the gauge stops.

    #!/usr/bin/wxbasicscript
    include "/usr/lib/wxbasicscript/basefunctions.inc"

    GAUGE = "("&
    "echo \"20\" ; sleep 5;"&
    " if [ ! \"`ps |grep xcalc`\" ];then exit;fi;  echo \"40\" ; sleep 5;"&
    " if [ ! \"`ps |grep xcalc`\" ];then exit;fi;  echo \"60\" ; sleep 5;"&
    " if [ ! \"`ps |grep xcalc`\" ];then exit;fi;  echo \"80\" ; sleep 5;"&
    " if [ ! \"`ps |grep xcalc`\" ];then exit;fi;  echo \"100\" ; sleep 5;"&
    ")"

    shell ("xcalc&")
    xwin_exec( GAUGE & "|Xdialog --title \"Gauge\" --gauge \"test\" 8 30" )
    shell ("killall xcalc")