XP is just a number | |
PerlMonks |
Re: Clearing & Redrawing a Wx Windowby rcseege (Pilgrim) |
on Sep 26, 2006 at 06:39 UTC ( [id://574864]=note: print w/replies, xml ) | Need Help?? |
Updated: changed references to unpack, unplace, ungrid to packForget, placeForget, and gridForget respectively. That was what I intended, but brain must have misfired. Also, corrected a typo in the code example. I agree with Zentara that your application shouldn' t be trying to recreate itself, when it could recreate just the desired Panel. Better still, the application could create one instance of each screen and hide/show the appropriate screen on demand.... First, by way of comparison, in Perl/Tk this sort of thing can be accomplished a lot of different ways but it usually amounts to variations of the following:
Of the two approaches, number 2 sounds closer to what you're trying to do. When using Wx, it's good to get familiar with the methods and Classes that have to do with Layout and display as quickly as possible.I recommend that you read up on the various Sizer implementations that provide Layout Management. These are slightly lower-level than what you might be used to using Tk, and closer to what's available in Java, Qt, and probably Gtk. Some other critical methods to learn are Show(boolan), which will toggle visibility for a widget. Show is perhaps the closest equivalent to pack/packForget. Also, Layout, Update, and Refresh are useful. Here's an example of one way to go about it -- there are plenty of other approaches. I think in your example, you were running afoul of a Layout issue.
Some general advice: use Sizers over absolute positioning, go ahead and let Wx generate the id by supplying -1 as the Id (so long as you keep a reference to the widget). It doesn't take much to expand that example and take it further. I think one avenue I would have pursued would be to create a Panel subclass for each screen, create each one once, and then only Show the one that was needed. You might consider taking a look at: wxWizardPage (and wxWizard). Rob
In Section
Seekers of Perl Wisdom
|
|