Hello Guest it is June 19, 2019, 03:37:45 AM

Author Topic: Help with opening up a new screen from wxFormBuilder New to all this.  (Read 1586 times)

0 Members and 1 Guest are viewing this topic.

I created a simple screen in wxformBuilder and just trying to get it to open with a new button press I created in Mach4.  I modified the code in the touch button script as follows:

Code: [Select]

inst = mc.mcGetInstance()
local profile = mc.mcProfileGetName(inst)
    local path = mc.mcCntlGetMachDir(inst)
    package.path = path .. "\\Profiles\\" .. profile .. "\\Modules\\?.lua;" .. path .. "\\Modules\\?.lua;"

    package.loaded.yyy = nil
    tou = require "yyy"
    Tframe = tou.Dialog()

I have attached the wxFormbuilder lua code file.  Just cannot figure out what I am doing wrong.  the yyy.lua file is in the modules folder.  Do I need the compiled file there also?

Any assistance would be appreciated.   

Offline DazTheGas

  •  747 747
  • DazTheGas
    • View Profile
This should help you on your way 


Theres always time for a choccy biccy
This video was very useful I followed along and everything worked great.  So now I added a basic screen, using wxFormBuilder and the screen will not show.  In fact when I step through and on the return of the UI I get an error, per attachment. 

Code for the button event is as follows:

Code: [Select]
local inst = mc.mcGetInstance()
local profile = mc.mcProfileGetName(inst)
local path = mc.mcCntlGetMachDir(inst)
package.path = path .. "\\Profiles\\" .. profile .. "\\Modules\\?.lua;" .. path .. "\\Modules\\?.lua;"

--CustFunc Module
package.loaded.mcTouchOff = nil

cf = require "mcTouchOff"
    Tframe = cf.Dialog()

Code for the custom function is as follows:

Code: [Select]
local mcTouchOff = {}   -- start of module   Declare Module table
local inst = mc.mcGetInstance()

--[[function mcTouchOff.GetSigState(sig)   -- adds  function to table
    local hSig = mc.mcSignalGetHandle(inst,sig)
    local state = mc.mcSignalGetState(hSig)  -- get handle
    return hSig


function mcTouchOff.SetSigState (sig, state) 

    local hSig = mc.mcSignalGetHandle(inst,sig)

function mcTouchOff.Dialog()

UI = {}

    UI.frameMain = wx.wxFrame (wx.NULL, wx.wxID_ANY, "TouchOff UI", wx.wxDefaultPosition, wx.wxSize( 900,530 ), wx.wxCAPTION + wx.wxCLOSE_BOX + wx.wxRESIZE_BORDER )
UI.frameMain:SetSizeHints( wx.wxSize( 900,530 ), wx.wxDefaultSize )
UI.frameMain :SetBackgroundColour( wx.wxColour( 255, 255, 255 ) )

return (UI.frameMain)

return mcTouchOff   -- end of module

Your guidance would be appreciated. 
Warm Regards,
Hi Allan,

as far as I understood Steve in this post, your way won't work.

So I think, you would need at least a luapanel in your screen. Place the button that opens the dialog in that panel. It might work then.
To get your luapanel to work, you'll need mcLuaPanelParent.
So when your button in the luapanel appears, you have your new thread, your lua instance. Of cause, the code for the button must be in your lua-module too.

hth Reinhard
solved my problem.   I made a rookie mistake. Forgot 1 line of code!!


Never called Show
So you created a lua dialog from a mach4-screen button?
Duh - didn't know that that would be possible. Good to know ;)

what about your error about unwritable memory? That can't be related to a forgotten Show()
For me that error looked like a threading issue.
How did you solved that error?
The Show resolved the error