Forum: wxRuby displaying a progress dialog

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
John G. (Guest)
on 2009-01-13 19:53
Hi, trying to display a progress dialog tied to a Frame using via...

    dlg = Wx::ProgressDialog.new("title", "task", max, self,
Wx::PD_CAN_ABORT | Wx::PD_APP_MODAL)

max and self both have valid values but everytime i try to use this i
get...

progress.rb:233:in `refresh': wrong # of arguments(2 for 0)
(ArgumentError)

any ideas or an example of one that works?

(running this on osx leopard)
Alex F. (Guest)
on 2009-01-13 20:51
(Received via mailing list)
John G. wrote:
> Hi, trying to display a progress dialog tied to a Frame using via...
>
>     dlg = Wx::ProgressDialog.new("title", "task", max, self,
> Wx::PD_CAN_ABORT | Wx::PD_APP_MODAL)
>
> max and self both have valid values but everytime i try to use this i
> get...
>
> progress.rb:233:in `refresh': wrong # of arguments(2 for 0)
> (ArgumentError)
Works fine for me with wxRuby 1.9.9 on Windows, and I've been using
ProgressDialog on OS X recently and not had any problems.

Are you in fact writing your own ProgressDialog subclass, and defining a
method called 'refresh' in it? wxRuby calls 'refresh' upon Windows (with
two arguments) when they need to be redrawn. This allows for custom
handling in Ruby, but it will cause problems if you have a method with
the same name that does something different.

a
John G. (Guest)
on 2009-01-13 23:16
you might be on to something there, i'm trying to finish off someone
else's project so will have a hunt for anything with the same name.

Cheers Alex
Tim M. (Guest)
on 2009-01-14 08:31
(Received via mailing list)
Excuse me for interrupting this, but how often is 'refresh' on a window
called, and what are it's two arguments?
Mario S. (Guest)
on 2009-01-14 10:12
(Received via mailing list)
A refresh can't always be truely tested, cause it falls in the domain of
the
native OS, and under several different conditions in which a refresh
will
occur.

Mainly, a refresh will occur for part of a window, when the OS Detects
that
another window has covered up the window, and needs to repaint the
region.

A full refresh will also occur, if you minimize your app, and then
restore
it, as well as Maximizing and Restoring.

Refreshes of controls occur on a control by control basis, meaning that
if
Control X is updated, but Control Y isn't, Control X will get a refresh,
while Control Y won't.

So, as you can see, there are many variables in which a refresh can
occur,
but it's not always the same, and it's never a "timed" matter.  It's an
On-Demand deal.

hth,

Mario
Alex F. (Guest)
on 2009-01-14 10:39
(Received via mailing list)
Timothy McDowell wrote:
> Excuse me for interrupting this, but how often is 'refresh' on a
> window called, and what are it's two arguments?
It's called when the window needs to be redrawn:

http://wxruby.rubyforge.org/doc/window.html#Window_refresh

I'm not 100% sure it's the best way for it to be called from wxRuby into
user ruby code. It's something that makes sense the wxWidgets C++ way,
but perhaps not the ruby way, where one would expect to stick to using
evt_paint and/or evt_erase_background. In Ruby it can create surprising
errors, as we've seen. It's something that's easy to change in the
wrapping, any way.

a
John G. (Guest)
on 2009-01-15 15:32
sorted, thanks guys...

progress = Wx::ProgressDialog.new("Processing Images",  "Processing
Images...", 100, self, Wx::PD_CAN_ABORT|Wx::PD_APP_MODAL)

works fine under windows and i can compile it to an exe with
rubyscript2exe.
John G. (Guest)
on 2009-01-15 15:33
and then update the dialog (for 5%, 10%, etc...)

progress.update(count, "Processing: "+row[1].to_s)
This topic is locked and can not be replied to.