# How do i refresh a window

**URL:** <https://www.ruby-forum.com/t/how-do-i-refresh-a-window/154787>\
**Category:** wxRuby\
**Created:** [December 3, 2008, 10:52pm UTC](https://www.ruby-forum.com/t/how-do-i-refresh-a-window/154787 "2008-12-03T22:52:55Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ramo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/f17d59/32.png) [@ramo](https://www.ruby-forum.com/u/ramo)\
**Post date:** [December 3, 2008, 10:52pm UTC](https://www.ruby-forum.com/t/how-do-i-refresh-a-window/154787/1 "2008-12-03T22:52:55Z")

</div>

wel, I’m back with another newbee question.

the problem i’m having and that i coldn’t find it on the internet is how  
to refresh a window, but someting more explained, maybe a tutorial or  
some doc?

when i put muy window behind another one the contents is ‘deleted’,  
still there but not visible until i click again (for example in a  
textbox), in most cases.

ok, first i’ll explain what I’m Doing (wrong)

first i call class Minimalapp

Minumalapp calls a Frame class

Within the frame class, on process initialize, I declare the menus, tool  
bars, panels, and a book. After the book i call both update() and  
refresh() (in that order), but when i run the program and put the window  
behind another one it doesn’t update.

the code (abstract) is this:

-class Aframe\< WX::Frame  
–def initialize  
—menu bars and toolbars  
—NoteBook  
----panel  
----textbox  
----combobox  
----etc  
—update()  
—refresh()  
–end  
-end

-class Minimalapp\< wx::App  
– on\_init #calls Aframe  
-end

#call minimallapp.main\_loop

any help for this newbee would be good.  
thanks

---

<div class="post-metadata">

**Author:** ![ramo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/f17d59/32.png) [@ramo](https://www.ruby-forum.com/u/ramo)\
**Post date:** [December 4, 2008, 7:15am UTC](https://www.ruby-forum.com/t/how-do-i-refresh-a-window/154787/2 "2008-12-04T07:15:05Z")

</div>

Hello Omar,

On Wed, Dec 3, 2008 at 3:52 PM, Omar H. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> wel, I’m back with another newbee question.

Not a problem

the problem i’m having and that i coldn’t find it on the internet is how

> –def initialize  
> —menu bars and toolbars  
> —NoteBook  
> ----panel  
> ----textbox  
> ----combobox  
> ----etc  
> —update()  
> —refresh()  
> –end  
> -end

First off, update() and refresh() is only executed once, when you  
initialize  
your Frame. It doesn’t do any subsiquent repainting, as initialize is  
never  
executed again in the lifetime of your Frame that you just created. To  
put  
it into simpler terms, you do this:

myframe = Aframe.new

myframe will call the initialize method on Aframe to get everything  
setup.  
Where your update() and refresh() are. After this point, initialize is  
never called again, nor should it be, least your creating a new instance  
of  
Aframe.

Secondly, the frame should be doing it’s own updates and refreshes,  
unless  
you are intercepting a evt\_paint() on the frame itself. If your doing  
that,  
then it will not repaint the frame itself, till you pass along the ok  
for  
wxRuby to repaint the window itself.

Unless your doing some specialized graphics, you shouldn’t need to  
intercept  
the evt\_paint(), and even then, if your doing specialized graphics, in a  
certian area of your frame, I would strongly suggest that you create an  
instance of panel, to do all of your drawing.

-class Minimalapp\< wx::App

> wxruby-users mailing list  
> [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> [http://rubyforge.org/mailman/listinfo/wxruby-users](http://rubyforge.org/mailman/listinfo/wxruby-users)

If you could, post an absolute minimal example of the app replicating  
this  
problem, full code, we can look at why this is occuring. Also, could  
you  
please state if your on Mac, Windows, or Linux?

Thanks

---

<div class="post-metadata">

**Author:** ![ramo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/f17d59/32.png) [@ramo](https://www.ruby-forum.com/u/ramo)\
**Post date:** [December 11, 2008, 8:51pm UTC](https://www.ruby-forum.com/t/how-do-i-refresh-a-window/154787/3 "2008-12-11T20:51:28Z")

</div>

Hello

well the time came when i have to fix this problem, I’ll thank you for  
all your help.

Mario S. wrote:

> … the frame should be doing it’s own updates and refreshes,  
> unless  
> you are intercepting a evt\_paint() on the frame itself.  
> …  
> Unless your doing some specialized graphics, you shouldn’t need to  
> intercept

I’m not doing specialized graphics, or I think so.

> If you could, post an absolute minimal example of the app replicating  
> this  
> problem, full code, we can look at why this is occuring. Also, could  
> you

I’m attaching a minimal example. The problems I found in my computer  
(windows)are:

- The line is not drawn.
- In report\>person menu, If you select the combo, it errases a part of  
the grid (the part that was covered by the options)
- In configuration\> states menu, the TextCtrl has no borders.
- When i minimize, restore, or cover the window with another window (the  
console window for example)the painting goes crazy, sometimes it  
dissapears, or the borders (when they had appeared) dissapear again.

> please state if your on Mac, Windows, or Linux?

We have tested it in two windows xp (media center and SP Professional)  
computers and is the same error.  
But in Mac it seems to be working fine.

If you are trying to find the error, try anything you thing on the  
window (cover it, minimize, restore, etc.) so you can see what I mean

Thanks for your help.

---

<div class="post-metadata">

**Author:** ![ramo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/f17d59/32.png) [@ramo](https://www.ruby-forum.com/u/ramo)\
**Post date:** [December 11, 2008, 11:44pm UTC](https://www.ruby-forum.com/t/how-do-i-refresh-a-window/154787/4 "2008-12-11T23:44:56Z")

</div>

Alex F. wrote:

> Pages within Notebooks must be children of the Notebook. So everywhere  
> you have Panel.new(self) you should have Panel.new(@book). With that  
> changed, and adding some labels to the notebook tabs, things look to be  
> working fine.

yes, it’s working!!

I guess it was a noob error.

thank you very much

---

<div class="post-metadata">

**Author:** ![ramo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/f17d59/32.png) [@ramo](https://www.ruby-forum.com/u/ramo)\
**Post date:** [December 11, 2008, 9:19pm UTC](https://www.ruby-forum.com/t/how-do-i-refresh-a-window/154787/5 "2008-12-11T21:19:10Z")

</div>

Omar H. wrote:

> I’m attaching a minimal example. The problems I found in my computer  
> (windows)are:

Pages within Notebooks must be children of the Notebook. So everywhere  
you have Panel.new(self) you should have Panel.new(@book). With that  
changed, and adding some labels to the notebook tabs, things look to be  
working fine.

I’ve only tested on OS X but I’d be pretty sure that having the wrong  
parent would explain problems like:

> - The line is not drawn.
> - In report\>person menu, If you select the combo, it errases a part of  
> the grid (the part that was covered by the options)
> - In configuration\> states menu, the TextCtrl has no borders.
> - When i minimize, restore, or cover the window with another window (the  
> console window for example)the painting goes crazy, sometimes it  
> dissapears, or the borders (when they had appeared) dissapear again.

hth  
a
