Background processing with 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
matiasbatero
Posts: 60
Joined: Fri 12 Oct 2012, 01:27
Location: Mar del Plata, Argentina

Background processing with gtkdialog

#1 Post by matiasbatero »

Hi to everyone.

I don't know how to get sub-processes working in background in gtkdialog.

Gtkdialog wait always a command/process finish signal in order to continue rendering the GUI.

I have a example, i want to extract Size, Path and MD5 sum from a file (file-selector widget) and puts results on a TREE widget.

MD5sum is the slow part of this process. Gtkdialog seems paralized until md5sum finish the job.

I want to put results as they are generated.

There is a way to do this??
If not, the only solution is a "waiting splash screen" and wait :S

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

#2 Post by don570 »

Xdialog has logbox option

http://xdialog.free.fr/doc/box.html

which is useful to show results instantaneously.

Several gtkdialog scripts use it.

________________________________

User avatar
zigbert
Posts: 6621
Joined: Wed 29 Mar 2006, 18:13
Location: Valåmoen, Norway
Contact:

Re: Background processing with gtkdialog

#3 Post by zigbert »

matiasbatero wrote:Gtkdialog wait always a command/process finish signal in order to continue rendering the GUI.
Wrong :D
There are (at least) 3 ways to update gui based on external actions.

1.) Add the tag attributes file-monitor="true" auto-refresh="true". See http://code.google.com/p/gtkdialog/wiki/tree

2.) Add an <action> to the <progressbar> widget, and it will execute as the bar reach 100%.

3.) The <timer> widget runs its <action> each sec (or whatever interval set). See http://code.google.com/p/gtkdialog/wiki/timer

A more complex example is found in chapter 4 of Gtkdialog - Tips and tricks
Sigmund

User avatar
matiasbatero
Posts: 60
Joined: Fri 12 Oct 2012, 01:27
Location: Mar del Plata, Argentina

Re: Background processing with gtkdialog

#4 Post by matiasbatero »

zigbert wrote:
matiasbatero wrote:Gtkdialog wait always a command/process finish signal in order to continue rendering the GUI.
Wrong :D
There are (at least) 3 ways to update gui based on external actions.

1.) Add the tag attributes file-monitor="true" auto-refresh="true". See http://code.google.com/p/gtkdialog/wiki/tree

2.) Add an <action> to the <progressbar> widget, and it will execute as the bar reach 100%.

3.) The <timer> widget runs its <action> each sec (or whatever interval set). See http://code.google.com/p/gtkdialog/wiki/timer

A more complex example is found in chapter 4 of Gtkdialog - Tips and tricks
Sigmund
Thanks Zigbert!!! i will do that. Next i'll post my results.

User avatar
matiasbatero
Posts: 60
Joined: Fri 12 Oct 2012, 01:27
Location: Mar del Plata, Argentina

#5 Post by matiasbatero »

don570 wrote:Xdialog has logbox option

http://xdialog.free.fr/doc/box.html

which is useful to show results instantaneously.

Several gtkdialog scripts use it.

________________________________
Thanks!!! Seems that work, but it's not applicable in this case.

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

#6 Post by don570 »

I wrote this short script to better understand Xdialog --logbox
and running a function in background

As an exercise remove the line ...

[ $A -gt 10 ] && break

and see what chaos occurs :wink:

Code: Select all

#!/bin/sh

add_function() {
        rm -f /root/log_file
        A=0
        while true
        do
             let "A=$A+1"
             echo "$A" >> /root/log_file
             [ $A -gt 10  ] && break
             sleep 2
         done
}
export -f add_function


export MAIN_DIALOG='
<vbox border-width="20">
    <button>
    <label>Start</label>
    <action>add_function &</action>
    <action>exit:EXIT</action>
    </button>
</vbox>
'
gtkdialog --program MAIN_DIALOG


export MAIN_DIALOG='
<vbox border-width="20"> 
      <button>
      <label>log box</label>
      <action>Xdialog --date-stamp --no-cancel --logbox   /root/log_file 0 0 &</action>
      </button>
</vbox>
'

gtkdialog --program MAIN_DIALOG
____________________________________________
Last edited by don570 on Thu 07 Nov 2013, 17:14, edited 1 time in total.

User avatar
technosaurus
Posts: 4853
Joined: Mon 19 May 2008, 01:24
Location: Blue Springs, MO
Contact:

#7 Post by technosaurus »

don570 wrote:

Code: Select all

#!/bin/sh
...
             let "A=$A+1"
A=$((A+1))
https://wiki.ubuntu.com/DashAsBinSh#let
Check out my [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].

Post Reply