Machsupport Forum

Mach Discussion => Mach4 General Discussion => Mach4 Videos => Topic started by: DazTheGas on May 19, 2016, 05:24:50 PM

Title: Mach4 Quicky #3 Using wxTimer
Post by: DazTheGas on May 19, 2016, 05:24:50 PM
Ever needed a timer in mach4 that wasnt in a loop like a = a +1 etc then try wxTimer


https://youtu.be/nkCx2xdoPEw (https://youtu.be/nkCx2xdoPEw)

The Code

Code: [Select]
TimerPanel = wx.wxPanel (wx.NULL, wx.wxID_ANY, wx.wxDefaultPosition, wx.wxDefaultSize )

timer = wx.wxTimer(TimerPanel)

TimerPanel:Connect(wx.wxEVT_TIMER,
    function (event)

    -- Whatever code or function you need here

timer:Stop()
end) 


timer:Start(10000)

DazTheGas
Title: Re: Mach4 Quicky #3 Using wxTimer
Post by: dah79 on May 19, 2016, 10:19:53 PM
Thanks Daz for the great explanation and video!
Title: Re: Mach4 Quicky #3 Using wxTimer
Post by: Chaoticone on May 21, 2016, 05:05:13 PM
That is a good one Daz! Very useful. Thanks!  :)
Title: Re: Mach4 Quicky #3 Using wxTimer
Post by: DazTheGas on May 26, 2016, 04:35:32 AM
There seems to be a bug somewhere, not sure where? as you can see from the video I dont get an error when running. but an error does exist if I run in script debug mode?

If you do get an error then change the first line to TimerPanel = wx.wxPanel (wx.NULL, wx.wxID_ANY, wx.wxDefaultPosition, wx.wxSize( 500,300 )) - Thanks Brett for the fix.


DazTheGas