On Mon, Nov 2, 2009 at 5:12 PM, Mateusz Czaplinski <czapko...@gmail.com> wrote:
> Hi,
> I'm having troubles with the following reduced sample program. When I
> set TEST=2, everything is OK, but with TEST=1, the "foo bar" text does
> not display (strangely, the frame size is calculated properly). I have
> also tried with a wxTextCtrl, with the same results.
>
> ---- BEGIN
> require "wx"
>
> frame = wx.wxFrame(wx.NULL, wx.wxID_ANY, "Example frame")

Top level windows such as wxFrames and wxDialogs do not require a
parent, but ALL child windows absolutely must have a parent window at
creation in order to set up the window hierarchy even if you plan to
reparent it. This is a requirement of wxWidgets. Some windows allow
for a two-step creation where you call the default constructor,
wxWindow(), and then call myWindow:Create(parent, id...), but this is
not particularly useful in a scripting language.

> TEST=1
> if TEST==1 then
>    text = wx.wxStaticText(wx.NULL, wx.wxID_ANY, "foo bar")
>    text:Reparent(frame)
> elseif TEST==2 then
>    text = wx.wxStaticText(frame, wx.wxID_ANY, "foo bar")
> end
...
>
> I'm in strong need to use Reparent(), as I'd like to create widgets
> first, and add them to the layout & proper parent later. In more

The creation of windows is pretty fast and I would not bother to try
to create windows ahead of time, but rather store the layout and
creation code in a Lua table and call it as appropriate. Don't forget
to use wxWindow::Destroy() to delete the topmost old one and it will
take care of its children. On the other hand if you are creating
wxListCtrls with many items, that might be slowish and in that case I
would create the window and immediately call Show(false) to hide it.
Finally, you cannot reparent between top level windows if I remember
correctly.

> general terms, I'm setting up some classes and methods which would
> make it easier to use wxLua, in an IUP-like way. I intend to share

Sounds interesting, I don't know much about IUP, but I would be
hesitant to try to force wxWidgets to behave like another toolkit.
It's much easier to swim with a stream than against it.

Regards,
    John

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
wxlua-users mailing list
wxlua-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wxlua-users

Reply via email to