1. Timer Handler Exxample
| virtual |
(Re)starts the timer.
If milliseconds parameter is -1 (value by default), the previous value is used. Returns false if the timer could not be started, true otherwise (in MS Windows timers are a limited resource).
If oneShot is false (the default), the Notify() function will be called repeatedly until the timer is stopped. If true, it will be called only once and the timer will stop automatically.
To make your code more readable you may also use the following symbolic constants:
- wxTIMER_CONTINUOUS: Start a normal, continuously running, timer
- wxTIMER_ONE_SHOT: Start a one shot timer Alternatively, use StartOnce().
If the timer was already running, it will be stopped by this method before restarting it.
If milisonds is zero, then the timer handler will be called without delay.
---------------------------------------------------------------------------- -- Lua code generated with wxFormBuilder (version Oct 26 2018) -- http://www.wxformbuilder.org/ ---------------------------------------------------------------------------- -- Load the wxLua module, does nothing if running from wxLua, wxLuaFreeze, or wxLuaEdit package.cpath = package.cpath..";./?.dll;./?.so;../lib/?.so;../lib/vc_dll/?.dll;../lib/bcc_dll/?.dll;../lib/mingw_dll/?.dll;" require("wx") function TimerHandler (event) UI.m_statusBar:SetStatusText( string.format("Value = %d", statusValue )) statusValue = statusValue + 1 end wxID_MENU_EXIT = 1000 wxID_STATUS = 1001 wxID_TIMER = 1002 UI = {} -- create wxDemo UI.wxDemo = wx.wxFrame (wx.NULL, wx.wxID_ANY, "", wx.wxDefaultPosition, wx.wxSize( 500,300 ), wx.wxDEFAULT_FRAME_STYLE+wx.wxTAB_TRAVERSAL ) UI.wxDemo:SetSizeHints( wx.wxDefaultSize, wx.wxDefaultSize ) UI.m_menubar1 = wx.wxMenuBar( 0 ) UI.m_menuFile = wx.wxMenu() UI.m_menuItemExit = wx.wxMenuItem( UI.m_menuFile, wxID_MENU_EXIT, "Exit", "", wx.wxITEM_NORMAL ) UI.m_menuFile:Append( UI.m_menuItemExit ) UI.m_menubar1:Append( UI.m_menuFile, "File" ) UI.wxDemo:SetMenuBar( UI.m_menubar1 ) UI.m_statusBar = UI.wxDemo:CreateStatusBar( 1, 0, wxID_STATUS ) UI.m_timer = wx.wxTimer(UI.wxDemo, wxID_TIMER) UI.bSizer1 = wx.wxBoxSizer( wx.wxVERTICAL ) UI.m_panel1 = wx.wxPanel( UI.wxDemo, wx.wxID_ANY, wx.wxDefaultPosition, wx.wxDefaultSize, wx.wxTAB_TRAVERSAL ) UI.bSizer1:Add( UI.m_panel1, 1, wx.wxEXPAND + wx. wxALL, 1 ) UI.wxDemo:SetSizer( UI.bSizer1 ) UI.wxDemo:Layout() UI.m_toolBar2 = UI.wxDemo:CreateToolBar( wx.wxTB_HORIZONTAL, wx.wxID_ANY ) UI.m_toolExit = UI.m_toolBar2:AddTool( wx.wxID_ANY, "Exit", wx.wxNullBitmap, wx.wxNullBitmap, wx.wxITEM_NORMAL, "", "") UI.m_toolBar2:Realize() UI.wxDemo:Centre( wx.wxBOTH ) --start UI.wxDemo:Show() UI.wxDemo:Connect(wx.wxEVT_TIMER,TimerHandler) UI.m_statusBar:SetStatusText( "0" ) UI.m_timer:Start(1000) statusValue = 0 --end wx.wxGetApp():MainLoop()
댓글 없음:
댓글 쓰기