Forum: wxRuby how do i refresh a window

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.
8169bd2772aa4c151c8688dd1b08348e?d=identicon&s=25 Omar Hernandez (ramo)
on 2008-12-03 22:52
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
3396e4a3df8a840faec520af8555a400?d=identicon&s=25 Mario Steele (Guest)
on 2008-12-04 07:15
(Received via mailing list)
Hello Omar,

On Wed, Dec 3, 2008 at 3:52 PM, Omar Hernandez <lists@ruby-forum.com>
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
> wxruby-users@rubyforge.org
> 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
8169bd2772aa4c151c8688dd1b08348e?d=identicon&s=25 Omar Hernandez (ramo)
on 2008-12-11 20:51
Attachment: badpainting.rb (3 KB)
Hello

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

Mario Steele 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.
06f6780c99d4a8dd71f2b474082ea9ce?d=identicon&s=25 Alex Fenton (Guest)
on 2008-12-11 21:19
(Received via mailing list)
Omar Hernandez 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
8169bd2772aa4c151c8688dd1b08348e?d=identicon&s=25 Omar Hernandez (ramo)
on 2008-12-11 23:44
Alex Fenton 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
This topic is locked and can not be replied to.