pkulchenko / wxlua

wxlua: Lua bindings for wxWidgets cross-platform GUI toolkit; supports Lua 5.1, 5.2, 5.3, 5.4, LuaJIT and wxWidgets 3.x
304 stars 59 forks source link

Main window frame does not work on Win10 #61

Closed decuant closed 4 years ago

decuant commented 4 years ago

I have tried different environments, wxLua 5.2 and wxLua 5.3.5 namely, and version 3.1.4.0 simply makes the application end silently.

Trying running it from ZeroBrane 1.90 or from command line makes no difference. Even debugging quits after the first breakpoint from within ZB.

It is annoying that I have to reset the environment, to point LUA_CPATH to 5.2 or 5.3.5, to test twice and make sure it's not me making mistakes.

The wx.dll I am using to test is a copy from ZeroBrane setup, it reads 3.1.4.0.

Lua's binaries were downloaded from PUC (precompiled).

As said Lua 5.2 works properly.

Code which is not working follows (extract, but it is so simple)

local tWinProp =
{
    {"Main Position",   {20,     20}},
    {"Main Size",       {750,   265}},
}

local dwMainFlags = bit32.bor(wx.wxDEFAULT_FRAME_STYLE, wx.wxCAPTION, wx.wxCLIP_CHILDREN, wx.wxSYSTEM_MENU, wx.wxCLOSE_BOX)

  local pos  = tWinProp[1][2]
  local size = tWinProp[2][2]

  local frame = wx.wxFrame(wx.NULL, wx.wxID_ANY, thisApp.sAppName,
                           wx.wxPoint(pos[1], pos[2]), wx.wxSize(size[1], size[2]),
                           dwMainFlags)

    frame:SetBackgroundColour(colors.clrCadetBlue)
    frame:SetForegroundColour(colors.clrBlack)

    mainFrame.hWindow      = frame

    mainFrame.hWindow:Show(true)

    -- run the main loop
    --
    wx.wxGetApp():MainLoop()

I'm surprised to report this problem!

Thank you for hints.

pkulchenko commented 4 years ago

@decuant, I'm a bit confused by the report. First of all, the code doesn't run, as it doesn't load "wx" library and references undefined variables (thisApp and colors).

Second, you can't use wx.dll included with ZeroBrane Studio with Lua 5.2 or Lua 5.3, as it's compiled against Lua 5.1 interpreter and will fail at run time if used with 5.2 or 5.3 interpreter.

Third, is the report related to the fact that it doesn't work on win10 or to the fact that it doesn't work with these specific flags when creating a frame?

I've updated the code you provided to the following:

require "wx"
local dwMainFlags = bit32.bor(wx.wxDEFAULT_FRAME_STYLE, wx.wxCAPTION, wx.wxCLIP_CHILDREN, wx.wxSYSTEM_MENU, wx.wxCLOSE_BOX)
local frame = wx.wxFrame(wx.NULL, wx.wxID_ANY, "test",
                           wx.wxPoint(20, 20), wx.wxSize(750, 265),
                           dwMainFlags)
frame:Show(true)
wx.wxGetApp():MainLoop()

I don't get any problem with running this code from ZeroBrane Studio.

Trying running it from ZeroBrane 1.90 or from command line makes no difference. Even debugging quits after the first breakpoint from within ZB.

Does the script above work for you when running from ZBS on Win10? If not, does the same script work for you when running from ZBS on non-Win10 machine?

decuant commented 4 years ago

Hello Paul,

thank you for being so prompt.

1> I didn't copy-paste the require "wx" in the provided snippet, but it is there in my code.

2> Your code runs ok both from ZB 1.90 (5.2) and command line (5.2). Version 5.1 would fail on bit32, thus no testing. There is a difference in size and position of the frame, from cmd line the frame is much bigger and positioned almost at the center of the screen. This is an issue I already know, see here (scroll to the very end of readme.md): https://github.com/decuant/wxEncode

3> It does not run in 5.3 configuration, both command line and ZB. Size of wx.dll shipped with ZB is twice the size of wx.dll in wxLua 5.1.5 and wxLua 5.2.0. Is it a debug version? Setting the compatiblity flag (vista sp.3/win7/win8) on zbstudio.exe makes no difference, sorry I have only 1 laptop with Win10 Home. I even run SysInternals' DebugView but it is totally deaf, no trace whatsoever. I notice that my mouse pointer changes to "background operation" (arrow + hourglass). Like hanging for a second.

4> Just to say that I was unwilling to compile wxLua from GitHub with VisualStudio (I have version 14.xx - Pro 2015). This is why I put your wx.dll in wxLua 5.3.5\bin, but know you teach me that it's a useless move.

__ RESET

I removed ZeroBrane from disk and this from system's environment variables

LUA_CPATH C:\wxLua520\bin\?.dll

Rebooted Win10, installed ZeroBrane fresh, no errors and auto-launch at the end of installation.

Trying both selections of 5.2 and 5.3 interpreters, these are the errors.

1> wx.dll can be found only in C:\Program Files (x86)\ZeroBrane\bin\clibs

2> running 5.1 is ok, should not fail on bit32?

Program starting as '"C:\Program Files (x86)\ZeroBrane\bin\lua52.exe" -e "io.stdout:setvbuf('no')" "C:\USR_2\LUA\wxWin355\main.lua"'. Program 'lua52.exe' started in 'C:\USR_2\LUA\wxWin355' (pid: 9048). C:\Program Files (x86)\ZeroBrane\bin\lua52.exe: .\window.lua:7: module 'wx' not found: no field package.preload['wx'] no file 'C:\Program Files (x86)\ZeroBrane\bin\lua\wx.lua' no file 'C:\Program Files (x86)\ZeroBrane\bin\lua\wx\init.lua'

Program starting as '"C:\Program Files (x86)\ZeroBrane\bin\lua53.exe" -e "io.stdout:setvbuf('no')" "C:\USR_2\LUA\wxWin355\main.lua"'. Program 'lua53.exe' started in 'C:\USR_2\LUA\wxWin355' (pid: 9132). C:\Program Files (x86)\ZeroBrane\bin\lua53.exe: .\window.lua:7: module 'wx' not found: no field package.preload['wx'] no file 'C:\Program Files (x86)\ZeroBrane\bin\lua\wx.lua' no file 'C:\Program Files (x86)\ZeroBrane\bin\lua\wx\init.lua'

Enough for tonight, is almost 4 am.

Thank you, hope to sort this out!

decuant commented 4 years ago

is not closed, I can't read buttons' text with Opera night mode, my fault.

pkulchenko commented 4 years ago

__ RESET I removed ZeroBrane from disk and this from system's environment variables Rebooted Win10, installed ZeroBrane fresh, no errors and auto-launch at the end of installation.

@decuant, right, this is the expected result.

Trying both selections of 5.2 and 5.3 interpreters, these are the errors. 1> wx.dll can be found only in C:\Program Files (x86)\ZeroBrane\bin\clibs

Right, so running lua 5.2 or lua 5.3 will fail (as the errors you showed confirm) unless you provide your own wx.dll that is compiled for lua 5.2 or lua 5.3.

2> running 5.1 is ok, should not fail on bit32?

yes, but only because wxlua provides its own bit32 module for 5.1 for compatibility purposes.

Given your example after the reset, I don't see a problem (assuming you get the frame shown when you launch the script with lua 5.1).

decuant commented 4 years ago

Hi Paul,

good news/bad news.

Thank you very much for the explanation, now the whole development setup is clear to me.

I close the issue.

I might try to compile wxLua 5.3.5 with VisualStudio, because I want to have wxWidgets close to the latest release.

Thank you again

decuant commented 4 years ago

These damned buttons don't change colors switching colour mode in Opera, bye!