73
« on: July 16, 2018, 01:56:44 PM »
it is the UI.MainWindow:Destroy() that is causing the problem, heres a more simpler aproach using the wx.wxEVT_CLOSE_WINDOW event
----------------------------------------------------------------------------
-- Lua code generated with wxFormBuilder DTG Version(Jan 2018)
----------------------------------------------------------------------------
UI = {}
-- create MainWindow
UI.MainWindow = wx.wxFrame (wx.NULL, wx.wxID_ANY, "", wx.wxDefaultPosition, wx.wxSize( 500,300 ), wx.wxDEFAULT_FRAME_STYLE+wx.wxTAB_TRAVERSAL )
UI.MainWindow:SetSizeHints( wx.wxDefaultSize, wx.wxDefaultSize )
UI.bSizer1 = wx.wxBoxSizer( wx.wxVERTICAL )
UI.m_button1 = wx.wxButton( UI.MainWindow, wx.wxID_ANY, "MyButton", wx.wxDefaultPosition, wx.wxDefaultSize, 0 )
UI.bSizer1:Add( UI.m_button1, 0, wx.wxALL, 5 )
UI.m_button2 = wx.wxButton( UI.MainWindow, wx.wxID_ANY, "MyButton", wx.wxDefaultPosition, wx.wxDefaultSize, 0 )
UI.bSizer1:Add( UI.m_button2, 0, wx.wxALL, 5 )
UI.MainWindow:SetSizer( UI.bSizer1 )
UI.MainWindow:Layout()
UI.MainWindow:Centre( wx.wxBOTH )
UI.MainWindow:Show()
-- Connect Events
UI.MainWindow:Connect( wx.wxEVT_CLOSE_WINDOW, function(event)
--do exit commands
event:Skip()
end )
There are a couple of ways you can make sure you have only one window
1. add to the MainWindow creation wx.wxSTAY_ON_TOP so its visible at all times so you know one is already open.
2. add a register so before the wizard is created it checks this register to see if its active IE if MainWindow is active then register == 1 and on exit the register == 0
DazTheGas