This is strange indeed. You do two things in your C++ program that aren't necessary and may/should cause problems.
This statement should not even compile as wxLuaState::Create() returns a bool. m_wxlState = m_wxlState.Create(this); This is not necessary as wxLua does this already, but it may be harmless. luaL_openlibs(L); You should do some simple debugging like printing the position and size of the wxButton to make sure that it really was created and does not have a zero size. Finally, please look at the wxLuaFreeze app which is the simplest incarnation of initializing wxLua in a C++ app. Regards, John On Thu, Nov 19, 2009 at 8:25 AM, Mark Rushakoff <mrushak...@lafayetteinstrument.com> wrote: > I already asked this question on StackOverflow > (http://stackoverflow.com/questions/1759366/embedded-wxlua-not-displaying-most-controls-but-still-does-layout-correctly), > so I'm pretty much doing a copy-paste of it here. Feel free to duplicate > any answers there if you've got an account. > > I am having trouble getting embedded wxLua to work with my application -- it > works fine when I use the wxLua DLLs, but I'm trying to use the static > libraries so I can distribute a single, standalone executable with no > external dependencies. > > First, the symptoms: Most controls (such as wxButtons, wxGauges, wxTextCtrls) > do not display; at the very least, wxStaticTexts display, and I can > successfully use menus to show an about menu and to quit. > > Here's a simple test script: > > require("wx") > frame = wx.wxFrame(wx.NULL, wx.wxID_ANY, "Frame") > panel = wx.wxPanel(frame, wx.wxID_ANY) > hbox = wx.wxBoxSizer(wx.wxHORIZONTAL) > hbox:Add(wx.wxButton(panel, wx.wxID_ANY, "I'm a button")) > hbox:Add(wx.wxStaticText(panel, wx.wxID_ANY, "Hello")) > panel:SetSizerAndFit(hbox) > frame:Show(true) > wx.wxGetApp():MainLoop() > > The top window in this screen shot shows a raw `lua file.lua` that calls the > wx library, and the bottom one shows the result when run from my embedded > wxLua: > > http://img337.imageshack.us/img337/8425/wxluaissue.png > > As you can see, the widgets that do show up get placed correctly, but the > widgets that don't show up, neither get rendered nor process events. > > Here's the offending (minimalized) C++: > > extern "C" { > #include "lua.h" > #include "lualib.h" > #include "lauxlib.h" > } > #include "wx/app.h" > #include "wx/image.h" > > // disable some of the libraries we're didn't want > #define wxLUA_USEBINDING_WXHTML 0 > #define wxLUA_USEBINDING_WXNET 0 > #define wxLUA_USEBINDING_WXLUASOCKET 0 > #define wxLUA_USEBINDING_WXSTC 0 > #include "wxbind/include/wxbinddefs.h" > #include "wx/msgdlg.h" > > WXLUA_DECLARE_BIND_ALL; > > class MyApp : public wxApp > { > public: > virtual bool OnInit(); > virtual int OnExit(); > void OnLua(wxLuaEvent &e); > wxLuaState m_wxlState; > private: > DECLARE_EVENT_TABLE(); > }; > > IMPLEMENT_APP(MyApp) > > BEGIN_EVENT_TABLE(MyApp, wxApp) > EVT_LUA_ERROR (wxID_ANY, MyApp::OnLua) > END_EVENT_TABLE() > > bool MyApp::OnInit() > { > WXLUA_IMPLEMENT_BIND_ALL > > wxInitAllImageHandlers(); > wxLuaState::sm_wxAppMainLoop_will_run = true; > m_wxlState = m_wxlState.Create(this); > lua_State *L = m_wxlState.GetLuaState(); > > luaL_openlibs(L); > int res = luaL_dofile(L, "C:\\file.lua"); > if (res != 0) > { > wxMessageBox(wxString::FromAscii(lua_tostring(L, -1)), wxT("Error > running script")); > return false; > } > > return true; > } > > int MyApp::OnExit() > { > wxMessageBox(wxT("Goodbye!")); > m_wxlState.CloseLuaState(true); > m_wxlState.Destroy(); > return wxApp::OnExit(); > } > > void MyApp::OnLua(wxLuaEvent &e) > { > wxMessageBox(e.GetString(), wxT("wxLua")); > } > > I have stripped down both wxWidgets and wxLua using their setup.h and > wxluasetup.h files; I can succcessfully render buttons if I use wxWidgets in > pure C++, so I think the issue is with either how I compiled wxLua, or how > I'm configuring the wxLuaState. > > I think I've configured the wxLuaState correctly, but I haven't been able to > find an example where all of the work is done in a luaL_dofile -- all the > other examples have custom wx-derived classes, except for wxlua.cpp, which is > a little different since it's for the wx.dll that Lua uses. I've spent > several hours trying to figure out what I'm doing wrong, and I'm completely > out of ideas at this point. > > Has anyone seen this issue before, or can anyone confirm or deny that I'm > setting up the wxLuaState correctly? > > Mark > ------------------------------------------------------------------------------ > Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day > trial. Simplify your report design, integration and deployment - and focus on > what you do best, core application coding. Discover what's new with > Crystal Reports now. http://p.sf.net/sfu/bobj-july > _______________________________________________ > wxlua-users mailing list > wxlua-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/wxlua-users > ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ wxlua-users mailing list wxlua-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wxlua-users