Forum: Ruby-Gnome 2 Best way of dealing with progressbars

Posted by Nikolai Weibull (Guest)
on 2011-10-26 15:42
(Received via mailing list)
Hi!

What’s the best way of dealing with progressbars?  I am currently
using a Gtk.idle_add function for updating a progressbar from a
different thread.  It doesn’t run very well.  I was wondering if
anyone has a better solution to this.
Posted by Simon Arnaud (sarnaud)
on 2011-10-26 16:18
Nikolai Weibull wrote in post #1028602:
> Hi!
>
> What’s the best way of dealing with progressbars?  I am currently
> using a Gtk.idle_add function for updating a progressbar from a
> different thread.  It doesn’t run very well.  I was wondering if
> anyone has a better solution to this.

AFAIK, it's the best way.

Do you have an example to take a look at ?

Simon
Posted by Nikolai Weibull (Guest)
on 2011-10-27 10:00
(Received via mailing list)
On Wed, Oct 26, 2011 at 16:18, Simon Arnaud
<ruby-forum-incoming@andreas-s.net> wrote:
> Nikolai Weibull wrote in post #1028602:

>> What’s the best way of dealing with progressbars?  I am currently
>> using a Gtk.idle_add function for updating a progressbar from a
>> different thread.  It doesn’t run very well.  I was wondering if
>> anyone has a better solution to this.

> AFAIK, it's the best way.
>
> Do you have an example to take a look at ?

No, not really.  It’s an internal thing.  My problem is that the
progress tends not to be reported very well.  Oh, well, fuck it.
Posted by Simon Arnaud (sarnaud)
on 2011-10-27 11:22
Attachment: progressbar.rb (362 Bytes)
Nikolai Weibull wrote in post #1028759:
>
> No, not really.  It’s an internal thing.  My problem is that the
> progress tends not to be reported very well.  Oh, well, fuck it.

I tested the attached program on 1.8.7 and 1.9.2, and it works without 
problem.

Do you call external commands in your thread ?

Simon
Posted by Nikolai Weibull (Guest)
on 2011-10-27 11:29
(Received via mailing list)
On Thu, Oct 27, 2011 at 11:22, Simon Arnaud
<ruby-forum-incoming@andreas-s.net> wrote:
> Nikolai Weibull wrote in post #1028759:
>>
>> No, not really.  It’s an internal thing.  My problem is that the
>> progress tends not to be reported very well.  Oh, well, fuck it.
>
> I tested the attached program on 1.8.7 and 1.9.2, and it works without
> problem.
>
> Do you call external commands in your thread ?

I don’t mean that it doesn’t work, I just mean that it’s slow.  The
progress being monitored is mostly other Ruby code, that is slightly
computation intense, but also COM activity through WIN32OLE.
Posted by Geoff Youngs (Guest)
on 2011-10-27 12:24
(Received via mailing list)
On 26 October 2011 14:41, Nikolai Weibull <now@bitwi.se> wrote:
> Hi!
>
> What’s the best way of dealing with progressbars?  I am currently
> using a Gtk.idle_add function for updating a progressbar from a
> different thread.  It doesn’t run very well.  I was wondering if
> anyone has a better solution to this.

I tend to prefer either a timeout in the main thread that polls, or an
IO source that listens for events (either via a pipe or socket from an
external process).  It makes it easier to throttle progress events if
there are too many & helps maintain a separation between the
processing code and UI implementation.

(But I also generally prefer to do all my heavy lifting in helper
scripts, rather than the GUI)

When you say it doesn't run well, do you mean that the process is
generally unresponsive or that there's a lag between the progressbar
update being scheduled and being drawn?
--
Random Musing - http://www.frafferz.com/
Geek Blog - http://geoffyoungs.github.com/
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.