Hello Guest it is March 28, 2024, 10:21:53 AM

Author Topic: Help with opening up a new screen from wxFormBuilder New to all this.  (Read 3855 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()
end

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

*
  •  778 778
  • DazTheGas
    • View Profile
This should help you on your way 

 http://www.machsupport.com/forum/index.php/topic,35007.0.html

DazTheGas
New For 2022 - Instagram: dazthegas
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()
--require("wx")

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

end


function mcTouchOff.SetSigState (sig, state) 

    local hSig = mc.mcSignalGetHandle(inst,sig)
    mc.mcSignalSetState(hSig,state)
end]]


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)
end

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!!

UI.frameMain:Show(true)

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 ;)
Hi,

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