python类Timer()的实例源码

inputhookwx.py 文件源码 项目:specto 作者: mrknow 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def __init__(self, func):
        self.func = func
        wx.Timer.__init__(self)  # @UndefinedVariable
waveform.py 文件源码 项目:pyjam 作者: 10se1ucgo 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def __init__(self, parent, file):
        super(WaveformPlot, self).__init__(parent=parent, title="pyjam Waveform Viewer",
                                           style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER)

        self.file = file

        self.plot = plot.PlotCanvas(self)
        self.plot.canvas.Bind(wx.EVT_LEFT_DOWN, self.lmb_down)
        self.plot.canvas.Bind(wx.EVT_LEFT_UP, self.lmb_up)
        self.plot.canvas.Bind(wx.EVT_MOTION, self.mouse_motion)
        self.plot.EnableAxesValues = (True, False, False, False)
        self.plot.EnableGrid = (True, False)
        self.plot.AbsScale = (True, False)
        self.plot.EnableAntiAliasing = True

        self.panel = WaveformPanel(self)

        sizer = wx.BoxSizer(wx.HORIZONTAL)
        sizer.Add(self.plot, 1, wx.EXPAND, 0)
        sizer.Add(self.panel, 0, wx.EXPAND, 0)
        self.SetSizerAndFit(sizer)
        self.SetSize(800, self.GetSize()[1])
        self.SetMinSize(self.GetSize())

        self.player = wx.media.MediaCtrl(parent=self, style=wx.SIMPLE_BORDER)

        self.volume = 25
        self.selected = np.array([0.0, 0.0])
        self.maximum = 0.0
        self.minimum = 0.0
        self.selection_drawn = False
        self.resized = False

        self.timer = wx.Timer(self)

        self.Bind(wx.EVT_SIZE, self.on_size)
        self.Bind(wx.EVT_TIMER, self.on_timer)
        self.Bind(wx.EVT_IDLE, self.on_idle)
        self.Bind(wx.EVT_CLOSE, self.on_exit)

        self.load()
inputhookwx.py 文件源码 项目:Repobot 作者: Desgard 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def __init__(self, func):
        self.func = func
        wx.Timer.__init__(self)
wx.py 文件源码 项目:Repobot 作者: Desgard 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def __init__(self, func):
        self.func = func
        wx.Timer.__init__(self)
ProjectController.py 文件源码 项目:beremiz 作者: nucleron 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def SetAppFrame(self, frame, logger):
        self.AppFrame = frame
        self.logger = logger
        self.StatusTimer = None
        if self.DispatchDebugValuesTimer is not None:
            self.DispatchDebugValuesTimer.Stop()
        self.DispatchDebugValuesTimer = None

        if frame is not None:

            # Timer to pull PLC status
            self.StatusTimer = wx.Timer(self.AppFrame, -1)
            self.AppFrame.Bind(wx.EVT_TIMER,
                               self.PullPLCStatusProc,
                               self.StatusTimer)

            if self._connector is not None:
                frame.LogViewer.SetLogSource(self._connector)
                self.StatusTimer.Start(milliseconds=500, oneShot=False)

            # Timer to dispatch debug values to consumers
            self.DispatchDebugValuesTimer = wx.Timer(self.AppFrame, -1)
            self.AppFrame.Bind(wx.EVT_TIMER,
                               self.DispatchDebugValuesProc,
                               self.DispatchDebugValuesTimer)

            self.RefreshConfNodesBlockLists()
ProjectController.py 文件源码 项目:beremiz 作者: nucleron 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def ReArmDebugRegisterTimer(self):
        if self.DebugTimer is not None:
            self.DebugTimer.cancel()

        # Prevent to call RegisterDebugVarToConnector when PLC is not started
        # If an output location var is forced it's leads to segmentation fault in runtime
        # Links between PLC located variables and real variables are not ready
        if self.IsPLCStarted():
            # Timer to prevent rapid-fire when registering many variables
            # use wx.CallAfter use keep using same thread. TODO : use wx.Timer instead
            self.DebugTimer = Timer(0.5, wx.CallAfter, args=[self.RegisterDebugVarToConnector])
            # Rearm anti-rapid-fire timer
            self.DebugTimer.start()
ProjectController.py 文件源码 项目:beremiz 作者: nucleron 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def _SetConnector(self, connector, update_status=True):
        self._connector = connector
        if self.AppFrame is not None:
            self.AppFrame.LogViewer.SetLogSource(connector)
        if connector is not None:
            if self.StatusTimer is not None:
                # Start the status Timer
                wx.Yield()
                self.StatusTimer.Start(milliseconds=500, oneShot=False)
        else:
            if self.StatusTimer is not None:
                # Stop the status Timer
                self.StatusTimer.Stop()
            if update_status:
                wx.CallAfter(self.UpdateMethodsFromPLCStatus)
ToolTipProducer.py 文件源码 项目:beremiz 作者: nucleron 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def __init__(self, parent):
        """
        Constructor
        @param parent: Parent Viewer
        """
        self.Parent = parent

        self.ToolTip = None
        self.ToolTipPos = None

        # Timer for firing Tool tip display
        self.ToolTipTimer = wx.Timer(self.Parent, -1)
        self.Parent.Bind(wx.EVT_TIMER,
                         self.OnToolTipTimer,
                         self.ToolTipTimer)
MWScoreGUI.py 文件源码 项目:MechWarfareScoring 作者: artanz 项目源码 文件源码 阅读 14 收藏 0 点赞 0 评论 0
def __init__( self ):
        wx.Frame.__init__( self, None, wx.ID_ANY, style=wx.DEFAULT_FRAME_STYLE, name="MWScore Server" )

        # MWScore ScoreServer.
        self.ScoreServer = MWScore.ScoreServer()

        # Menu Bar
        self.MenuBar = wx.MenuBar()
        self.FileMenu = wx.Menu()
        self.TransponderMenu = wx.Menu()
        self.SocketMenu = wx.Menu()
        self.MatchMenu = wx.Menu()

        self.FileMenu.Append( self.ID_QUIT, "Quit" )
        self.Bind( wx.EVT_MENU, self.Quit, id=self.ID_QUIT )

        self.TransponderMenu.Append( self.ID_TRANSPONDERSETUP, "Setup" )
        self.Bind( wx.EVT_MENU, self.TransponderSetup, id=self.ID_TRANSPONDERSETUP )

        self.SocketMenu.Append( self.ID_SOCKETSETUP, "Setup" )
        self.Bind( wx.EVT_MENU, self.SocketSetup, id=self.ID_SOCKETSETUP )

        self.MatchMenu.Append( self.ID_MATCHSETUP, "Setup" )
        self.MatchMenu.Append( self.ID_MATCHSTART, "Start/Resume" )
        self.MatchMenu.Append(self.ID_MATCHPAUSE, "Pause" )
        self.MatchMenu.Append(self.ID_MATCHRESET, "Reset" )
        self.MatchMenu.Append(self.ID_MATCHRESETHP, "Reset HP" )
        self.Bind( wx.EVT_MENU, self.MatchSetup, id=self.ID_MATCHSETUP )
        self.Bind( wx.EVT_MENU, self.MatchStart, id=self.ID_MATCHSTART )
        self.Bind( wx.EVT_MENU, self.MatchPause, id=self.ID_MATCHPAUSE )
        self.Bind( wx.EVT_MENU, self.MatchReset, id=self.ID_MATCHRESET )
        self.Bind( wx.EVT_MENU, self.MatchResetHP, id=self.ID_MATCHRESETHP )

        self.MenuBar.Append( self.FileMenu, "&File" )
        self.MenuBar.Append( self.MatchMenu, "&Match" )
        self.MenuBar.Append( self.TransponderMenu, "&Transponder" )
        self.MenuBar.Append( self.SocketMenu, "&Socket" )

        self.SetMenuBar( self.MenuBar )


        # Panel
        self.Panel = MatchPanel( self, -1 )

        # Frame Update Timer
        self.Timer = wx.Timer( self, self.FRAME_UPDATE_TIMER_ID )
        self.Timer.Start(100)
        wx.EVT_TIMER( self, self.FRAME_UPDATE_TIMER_ID, self.OnTimer )

        self.Show( True )
                self.SetTitle("Mech Warfare Match Score")

    # Updates the frames panel and Broadcasts match data to clients
MWCam.py 文件源码 项目:MechWarfareScoring 作者: artanz 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def __init__( self ):
        wx.Frame.__init__( self, None, wx.ID_ANY, "MWCam", style=wx.DEFAULT_FRAME_STYLE & ~wx.RESIZE_BORDER )

        # Socket Cleint
        self.SocketClient = MWScore.SocketClient( SOCKET_CLIENT_HOST, SOCKET_CLIENT_PORT )
        self.SocketClient.StartThread()

        # IP Camera
        #self.Camera = Trendnet( CAMERA_IP, CAMERA_USERNAME, CAMERA_PASSWORD )
        self.Camera = DLink( CAMERA_IP, CAMERA_USERNAME, CAMERA_PASSWORD )
        self.Camera.Connect()

        # Camera Panel
        self.CameraPanel = CameraPanel( self, self.Camera, self.SocketClient )

        # Frame timer
        self.Timer = wx.Timer( self, self.ID_FRAME_REFRESH )
        self.Timer.Start(10)
        wx.EVT_TIMER( self, self.ID_FRAME_REFRESH, self.Refresh )

        # Frame Sizer
        self.Sizer = None
        self.Size()

        # Show frame
        self.Show( True )
janet.py 文件源码 项目:Janet 作者: nosmokingbandit 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def setup_gamepad(self):
        self.gamepad_connected = False
        self.stick = wx.Joystick()
        self.stick.SetCapture(self)
        self.gamepad_timer = wx.Timer(self)
        self.Bind(wx.EVT_TIMER, self.poll_gamepad, self.gamepad_timer)
        self.gamepad_timer.Start(150)  # 150ms seems to be a good rate, we aren't playing Street Fighter or anything.
janet.py 文件源码 项目:Janet 作者: nosmokingbandit 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def create_timer(self):
        # See also "Making a render loop":
        # http://wiki.wxwidgets.org/Making_a_render_loop
        # Another way would be to use EVT_IDLE in MainFrame.
        self.timer = wx.Timer(self, self.timer_id)
        self.timer.Start(10)  # 10ms timer
        wx.EVT_TIMER(self, self.timer_id, self.on_timer)
app.py 文件源码 项目:bittray 作者: nkuttler 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def set_icon_timer(self):
        """
        Sets the icon timer to kick off the main loop.
        """
        self.icon_timer = wx.Timer(self, ID_ICON_TIMER)
        wx.EVT_TIMER(self, ID_ICON_TIMER, self.do_update)
        self.icon_timer.Start(self.conf.get_int('Behavior', 'timer'))
        self.do_update()  # Fire the first right away
main.py 文件源码 项目:wxpythoncookbookcode 作者: driscollis 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def __init__(self, parent):
        """Constructor"""
        wx.Panel.__init__(self, parent)

        width, height = wx.DisplaySize()
        self.picPaths = []
        self.currentPicture = 0
        self.totalPictures = 0
        self.photoMaxSize = height - 200
        Publisher().subscribe(self.updateImages, ("update images"))

        self.slideTimer = wx.Timer(None)
        self.slideTimer.Bind(wx.EVT_TIMER, self.update)

        self.layout()
flashing_text.py 文件源码 项目:wxpythoncookbookcode 作者: driscollis 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def __init__(self, parent):
        """Constructor"""
        wx.Panel.__init__(self, parent)

        self.font = wx.Font(12, wx.DEFAULT, wx.NORMAL, wx.NORMAL)
        self.label = "I flash a LOT!"
        self.flashingText = wx.StaticText(self, label=self.label)
        self.flashingText.SetFont(self.font)

        self.timer = wx.Timer(self)
        self.Bind(wx.EVT_TIMER, self.update, self.timer)
        self.timer.Start(1000)
changing_text.py 文件源码 项目:wxpythoncookbookcode 作者: driscollis 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def __init__(self, parent):
        """Constructor"""
        wx.Panel.__init__(self, parent)

        self.font = wx.Font(12, wx.DEFAULT, wx.NORMAL, wx.NORMAL)
        self.flashingText = wx.StaticText(self, label="I flash a LOT!")
        self.flashingText.SetFont(self.font)

        self.timer = wx.Timer(self)
        self.Bind(wx.EVT_TIMER, self.update, self.timer)
        self.timer.Start(1000)
simple_timer_2.py 文件源码 项目:wxpythoncookbookcode 作者: driscollis 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def __init__(self):
        wx.Frame.__init__(self, None, title="Timer Tutorial 1",
                          size=(500,500))

        panel = wx.Panel(self, wx.ID_ANY)

        self.timer = wx.Timer(self)
        self.Bind(wx.EVT_TIMER, self.update, self.timer)

        self.toggleBtn = wx.Button(panel, wx.ID_ANY, "Start")
        self.toggleBtn.Bind(wx.EVT_BUTTON, self.onToggle)
multiple_timers_2.py 文件源码 项目:wxpythoncookbookcode 作者: driscollis 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def onStartTimer(self, event):
        btn = event.GetEventObject()
        timerNum, timer, secs = self.objDict[btn]
        if timer.IsRunning():
            timer.Stop()
            btn.SetLabel("Start Timer %s" % timerNum)
            print("timer %s stopped!" % timerNum)
        else:
            print("starting timer %s..." % timerNum)
            timer.Start(secs)
            btn.SetLabel("Stop Timer %s" % timerNum)
simple_timer.py 文件源码 项目:wxpythoncookbookcode 作者: driscollis 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def __init__(self):
        wx.Frame.__init__(self, None, title="Timer Tutorial 1",
                          size=(500,500))

        panel = wx.Panel(self, wx.ID_ANY)

        self.timer = wx.Timer(self)
        self.Bind(wx.EVT_TIMER, self.update, self.timer)

        self.toggleBtn = wx.Button(panel, wx.ID_ANY, "Start")
        self.toggleBtn.Bind(wx.EVT_BUTTON, self.onToggle)
main.py 文件源码 项目:wxpythoncookbookcode 作者: driscollis 项目源码 文件源码 阅读 16 收藏 0 点赞 0 评论 0
def __init__(self):
        """Constructor"""
        wx.Frame.__init__(self, None, title="Panel Smacker")
        self.panelOne = PanelOne(self)
        self.time2die = 10

        self.timer = wx.Timer(self)
        self.Bind(wx.EVT_TIMER, self.update, self.timer)
        self.timer.Start(1000)

        self.sizer = wx.BoxSizer(wx.VERTICAL)
        self.sizer.Add(self.panelOne, 1, wx.EXPAND)
        self.SetSizer(self.sizer)


问题


面经


文章

微信
公众号

扫码关注公众号