Thanks for the response. I have tried many ways to get this to work but unfortunately have run out of time to keep exploring. I was using SetBitmap originally with no luck I think I just said SetImage in the OP unintentionally because I wasn't looking at the code when I asked the question. I will eventually come back to this in the future but for now I got to put it away. If I get it to work I'll definitely update the forum with the code.
This is what I originally tried and now it won't even load the initial image. It can't even find the file with the file_exists function.
I lost the original code I was working with but I think it will come back to me later.
local inst = mc.mcGetInstance()
local profile = mc.mcProfileGetName(inst)
local path = mc.mcCntlGetMachDir(inst)
dirPath = path .. "\\GcodeFiles\\img\\"
imgChangeReg = mc.mcRegGetHandle(inst, "gRegs0/ImgChange")
imgNameReg = mc.mcRegGetHandle(inst, "gRegs0/ImgName")
--panel = mcLuaPanelParent
panel = wx.wxPanel(wx.NULL, wx.wxID_ANY, wx.wxDefaultPosition, wx.wxSize(500,300), wx.wxTAB_TRAVERSAL)
gSizer1 = wx.wxGridSizer(0, 0, 0, 0)
mc.mcCntlSetLastError(inst, dirPath)
function file_exists(file)
local f = io.open(file, "rb")
if f then f:close() end
return f ~= nil
end
if not file_exists(dirPath .. "1.png") then
mc.mcCntlSetLastError(inst, "File exists!")
else
mc.mcCntlSetLastError(inst, "File does not exist! " .. dirPath .. "1.png")
end
bitmapObj = wx.wxStaticBitmap(panel, wx.wxID_ANY, wx.wxBitmap(dirPath .. "1.png", wx.wxBITMAP_TYPE_ANY), wx.wxDefaultPosition, wx.wxDefaultSize, 0)
gSizer1:Add(bitmapObj, 0, wx.wxALL + wx.wxEXPAND, 0)
panel:SetSizer(gSizer1)
panel:Layout()
panel:Fit()
panel:Connect(wx.wxEVT_UPDATE_UI, function(event)
local imgChanged = mc.mcRegGetValueLong(imgChangeReg)
--mc.mcCntlSetLastError(inst, tostring(imgChanged))
if imgChanged > 0 then
--mc.mcCntlSetLastError(inst, tostring(imgChanged))
local imgName = mc.mcRegGetValueString(imgNameReg)
mc.mcCntlSetLastError(inst, tostring(imgName))
mc.mcCntlSetLastError(inst, dirPath .. imgName)
--bitmapObj:SetBitmap(wx.wxBitmap(dirPath .. imgName, wx.wxBITMAP_TYPE_ANY))
mc.mcRegSetValueLong(imgChangeReg, 0)
end
--event:Skip()
end)
Thanks Again!