# Displaying a progress dialog

**URL:** <https://www.ruby-forum.com/t/displaying-a-progress-dialog/157612>\
**Category:** wxRuby\
**Created:** [January 13, 2009, 6:53pm UTC](https://www.ruby-forum.com/t/displaying-a-progress-dialog/157612 "2009-01-13T18:53:47Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![softf5ajivanet](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/9f8e36/32.png) [@softf5ajivanet](https://www.ruby-forum.com/u/softf5ajivanet)\
**Post date:** [January 13, 2009, 6:53pm UTC](https://www.ruby-forum.com/t/displaying-a-progress-dialog/157612/1 "2009-01-13T18:53:47Z")

</div>

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)

---

<div class="post-metadata">

**Author:** ![softf5ajivanet](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/9f8e36/32.png) [@softf5ajivanet](https://www.ruby-forum.com/u/softf5ajivanet)\
**Post date:** [January 13, 2009, 7:51pm UTC](https://www.ruby-forum.com/t/displaying-a-progress-dialog/157612/2 "2009-01-13T19:51:00Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![softf5ajivanet](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/9f8e36/32.png) [@softf5ajivanet](https://www.ruby-forum.com/u/softf5ajivanet)\
**Post date:** [January 13, 2009, 10:16pm UTC](https://www.ruby-forum.com/t/displaying-a-progress-dialog/157612/3 "2009-01-13T22:16:38Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![softf5ajivanet](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/9f8e36/32.png) [@softf5ajivanet](https://www.ruby-forum.com/u/softf5ajivanet)\
**Post date:** [January 14, 2009, 7:31am UTC](https://www.ruby-forum.com/t/displaying-a-progress-dialog/157612/4 "2009-01-14T07:31:59Z")

</div>

Excuse me for interrupting this, but how often is ‘refresh’ on a window  
called, and what are it’s two arguments?

---

<div class="post-metadata">

**Author:** ![softf5ajivanet](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/9f8e36/32.png) [@softf5ajivanet](https://www.ruby-forum.com/u/softf5ajivanet)\
**Post date:** [January 14, 2009, 9:12am UTC](https://www.ruby-forum.com/t/displaying-a-progress-dialog/157612/5 "2009-01-14T09:12:09Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![softf5ajivanet](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/9f8e36/32.png) [@softf5ajivanet](https://www.ruby-forum.com/u/softf5ajivanet)\
**Post date:** [January 14, 2009, 9:39am UTC](https://www.ruby-forum.com/t/displaying-a-progress-dialog/157612/6 "2009-01-14T09:39:13Z")

</div>

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](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

---

<div class="post-metadata">

**Author:** ![softf5ajivanet](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/9f8e36/32.png) [@softf5ajivanet](https://www.ruby-forum.com/u/softf5ajivanet)\
**Post date:** [January 15, 2009, 2:32pm UTC](https://www.ruby-forum.com/t/displaying-a-progress-dialog/157612/7 "2009-01-15T14:32:36Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![softf5ajivanet](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/9f8e36/32.png) [@softf5ajivanet](https://www.ruby-forum.com/u/softf5ajivanet)\
**Post date:** [January 15, 2009, 2:33pm UTC](https://www.ruby-forum.com/t/displaying-a-progress-dialog/157612/8 "2009-01-15T14:33:35Z")

</div>

and then update the dialog (for 5%, 10%, etc…)

progress.update(count, "Processing: "+row[1].to\_s)
