Clear questions and runnable code get the best and fastest answer |
|
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
Hi,
I took a swing at it. Probably you should really post to the wxperl-users list, see wxperl.sf.net. I took two tacks. First let me say this is exactly not how I use wxperl stylistically, and it kind of matters here. I use one module per file, don't do much in new(), override Wx modules to make my own, and (so far but this will change quickly) don't build panels on the fly. With the exception of a Wx::Gauge I added today which I Show and hide when done with it. I put my use statements all at the top and use Wx 0.15 qw[:everything]. Basically taking the time to eat through parts of the demo and reading wxwidgets docs and tutorials will be required. Okay. My theory was that it was working but there was nothing in the panel so you couldn't see it. When I added a text control I got Show to work (not really adding the panel at the last moment). Also added sizers which is standard way to add panels. (sizer in top frame, then panel in sizer in panel..) Finally I decided to just add one sizer to the frame, and build everything else at the last moment. This works, but I didn't get removal working (so I scrapped it). Also it will crash if you try to add the same one again. Anyway, the following should work. Caveat, I have done most Wx on windows recently but this I did on Linux. (Wx 0.15, wxWidgets 2.4.2). Note I also find App->Yield useful (not so important this time). Post to the list if you have more questions. So the key was to add something to see in the panel. Incidentally if you just use anonymous subs in new you can't do some things that require the object to exist first. So better to save all objects attached to the frame, and do it in separate subroutines. It really seemed flaky this way (things wouldn't erase or draw well, Show's boolean value seemed backwards, etc. When I tried to Destroy I would get segfaults, etc.). This was a big surprise because the past few weeks building a Wx app on Win98 has been quite pleasant and speedy, for example I got printing of a chart drawing done in just a day, etc. This tells me what you are going is not the way to do it. Basically I think you want XRC and I worked on this partly because I am going to do XRC soon. Recommend you check it out for building on the fly interfaces, tearing them up and presumably down (I couldn't tear down cleanly my first swing). But limited tear up using the below method should work I think. Also look at the demo, many modules are used. Just instantiate a module for an entire window when you need it. Anyway, here is the direct answer to what you requested, it just creates a panel with sizer and control in it, and adds the panel to the top sizer. Anybody with more experience at Wxperl please jump in! You can diff to see changes from your original. Good luck!
In reply to Re: Wx::Panel not rendering
by mattr
|
|