Python wx.EVT_TIMER Examples

The following are 30 code examples of wx.EVT_TIMER(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module wx , or try the search function .
Example #1
Source File: gui.py    From OpenCV-Computer-Vision-Projects-with-Python with MIT License 6 votes vote down vote up
def _init_base_layout(self):
        """Initialize parameters

            This method performs initializations that are common to all GUIs,
            such as the setting up of a timer.

            It then calls an abstract method self.init_custom_layout() that
            allows for additional, application-specific initializations.
        """
        # set up periodic screen capture
        self.timer = wx.Timer(self)
        self.timer.Start(1000./self.fps)
        self.Bind(wx.EVT_TIMER, self._on_next_frame)
        self.Bind(wx.EVT_PAINT, self._on_paint)

        # allow for custom modifications
        self._init_custom_layout() 
Example #2
Source File: gui.py    From opencv-python-blueprints with GNU General Public License v3.0 6 votes vote down vote up
def _init_base_layout(self):
        """Initialize parameters

            This method performs initializations that are common to all GUIs,
            such as the setting up of a timer.

            It then calls an abstract method self.init_custom_layout() that
            allows for additional, application-specific initializations.
        """
        # set up periodic screen capture
        self.timer = wx.Timer(self)
        self.timer.Start(1000. / self.fps)
        self.Bind(wx.EVT_TIMER, self._on_next_frame)

        # allow for custom modifications
        self._init_custom_layout() 
Example #3
Source File: live_demo.py    From mr_saliency with GNU General Public License v2.0 6 votes vote down vote up
def __init__(self, parent, capture, fps=24):
        wx.Panel.__init__(self, parent)

        self.SetDoubleBuffered(True)
        
        self.capture = capture
        ret, frame = self.capture.read()
        
        height, width = frame.shape[:2]
        parent.SetSize((width, height))
        frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
        self.bmp = wx.BitmapFromBuffer(width, height, frame)

        self.timer = wx.Timer(self)
        self.timer.Start(1000./fps)

        self.Bind(wx.EVT_PAINT, self.OnPaint)
        self.Bind(wx.EVT_TIMER, self.NextFrame) 
Example #4
Source File: live_demo.py    From mr_saliency with GNU General Public License v2.0 6 votes vote down vote up
def __init__(self, parent, capture, fps=24):
        wx.Panel.__init__(self, parent)
                
        self.capture = capture2
        ret, frame = self.capture.read()


        sal = mr_sal.saliency(frame)
        sal = cv2.resize(sal,(320,240)).astype(sp.uint8)
        sal = cv2.normalize(sal, None, 0, 255, cv2.NORM_MINMAX)
        outsal = cv2.applyColorMap(sal,cv2.COLORMAP_HSV)
        self.bmp = wx.BitmapFromBuffer(320,240, outsal.astype(sp.uint8))

        self.timer = wx.Timer(self)
        self.timer.Start(1000./fps)

        self.Bind(wx.EVT_PAINT, self.OnPaint)
        self.Bind(wx.EVT_TIMER, self.NextFrame) 
Example #5
Source File: flow.py    From iqiyi-parser with MIT License 6 votes vote down vote up
def checkNode():
        dlm = nbdler.Manager()
        if not os.path.exists('node.exe') or os.path.exists('node.exe.nbdler'):
            dlg = wx.MessageDialog(None, u'该程序需要Nodejs.exe才能完成工作,是否要下载?', u'提示', wx.YES_NO | wx.ICON_INFORMATION)
            if dlg.ShowModal() != wx.ID_YES:
                return False
            dl = nbdler.open(urls=[TOOL_REQ_URL['node']],
                             max_conn=16, filename='node.exe')
            dlm.addHandler(dl)
            dlg = gui.DialogGetTool(gui.frame_downloader, u'正在下载 Nodejs v10.15.3', dl.getFileSize(), dlm)

            dlg.Bind(wx.EVT_TIMER, GetTool._process, dlg.timer)
            dlg.timer.Start(50, oneShot=False)
            dlm.run()
            msg = dlg.ShowModal()
            dlm.shutdown()
            dlg.Destroy()
            if msg == wx.ID_OK:
                return True
            else:
                return False
        else:
            return True 
Example #6
Source File: TreeCtrl.py    From EventGhost with GNU General Public License v2.0 6 votes vote down vote up
def __init__(self, treeCtrl):
        wx.PyDropTarget.__init__(self)
        self.treeCtrl = treeCtrl
        self.srcNode = eg.EventItem
        # specify the type of data we will accept
        textData = wx.TextDataObject()
        self.customData = wx.CustomDataObject(wx.CustomDataFormat("DragItem"))
        self.customData.SetData("")
        compositeData = wx.DataObjectComposite()
        compositeData.Add(textData)
        compositeData.Add(self.customData)
        self.SetDataObject(compositeData)
        self.lastHighlighted = None
        self.isExternalDrag = True
        self.whereToDrop = None
        self.lastDropTime = clock()
        self.lastTargetItemId = None
        timerId = wx.NewId()
        self.autoScrollTimer = wx.Timer(self.treeCtrl, timerId)
        self.treeCtrl.Bind(wx.EVT_TIMER, self.OnDragTimerEvent, id=timerId) 
Example #7
Source File: AnimatedWindow.py    From EventGhost with GNU General Public License v2.0 6 votes vote down vote up
def __init__(self, parent):
        wx.PyWindow.__init__(self, parent)
        self.font = wx.Font(
            40, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_ITALIC, wx.FONTWEIGHT_BOLD
        )
        self.SetBackgroundColour((255, 255, 255))
        self.logo1 = GetInternalBitmap("opensource-55x48")
        self.logo2 = GetInternalBitmap("python-powered")
        self.logo3 = GetInternalBitmap("logo2")
        self.image = GetInternalImage("logo")
        self.bmpWidth = self.image.GetWidth()
        self.bmpHeight = self.image.GetHeight()
        self.time = clock()
        self.count = 0
        self.Bind(wx.EVT_SIZE, self.OnSize)
        self.Bind(wx.EVT_TIMER, self.UpdateDrawing)
        self.OnSize(None)
        self.timer = wx.Timer(self)
        self.timer.Start(10) 
Example #8
Source File: TextViewer.py    From OpenPLC_Editor with GNU General Public License v3.0 6 votes vote down vote up
def __init__(self, parent, tagname, window, controler, debug=False, instancepath=""):
        if tagname != "" and controler is not None:
            self.VARIABLE_PANEL_TYPE = controler.GetPouType(tagname.split("::")[1])

        EditorPanel.__init__(self, parent, tagname, window, controler, debug)

        self.Keywords = []
        self.Variables = {}
        self.Functions = {}
        self.TypeNames = []
        self.Jumps = []
        self.EnumeratedValues = []
        self.DisableEvents = True
        self.TextSyntax = None
        self.CurrentAction = None

        self.InstancePath = instancepath
        self.ContextStack = []
        self.CallStack = []

        self.ResetSearchResults()

        self.RefreshHighlightsTimer = wx.Timer(self, -1)
        self.Bind(wx.EVT_TIMER, self.OnRefreshHighlightsTimer, self.RefreshHighlightsTimer) 
Example #9
Source File: chapter2.py    From OpenCV-Computer-Vision-Projects-with-Python with MIT License 6 votes vote down vote up
def __init__(self, parent, id, title, capture, fps=15):
        # initialize screen capture
        self.capture = capture

        # determine window size and init wx.Frame
        frame,_ = freenect.sync_get_depth()
        self.imgHeight,self.imgWidth = frame.shape[:2]
        buffer = np.zeros((self.imgWidth,self.imgHeight,3),np.uint8)
        self.bmp = wx.BitmapFromBuffer(self.imgWidth, self.imgHeight, buffer)
        wx.Frame.__init__(self, parent, id, title, size=(self.imgWidth, self.imgHeight))

        # set up periodic screen capture
        self.timer = wx.Timer(self)
        self.timer.Start(1000./fps)
        self.Bind(wx.EVT_TIMER, self.NextFrame)
        
        # counteract flicker
        def disable_event(*pargs,**kwargs):
            pass
        self.Bind(wx.EVT_ERASE_BACKGROUND, disable_event)

        # create the layout, which draws all buttons and
        # connects events to class methods
        self.CreateLayout() 
Example #10
Source File: DiscoveryPanel.py    From OpenPLC_Editor with GNU General Public License v3.0 6 votes vote down vote up
def __init__(self, parent):
        wx.Panel.__init__(self, parent)

        self.parent = parent

        self._init_list_ctrl()
        listmix.ColumnSorterMixin.__init__(self, 4)

        self._init_ctrls(parent)

        self.itemDataMap = {}
        self.nextItemId = 0

        self.URI = None
        self.Browser = None
        self.ZeroConfInstance = None

        self.RefreshList()
        self.LatestSelection = None

        self.IfacesMonitorState = None
        self.IfacesMonitorTimer = wx.Timer(self)
        self.IfacesMonitorTimer.Start(2000)
        self.Bind(wx.EVT_TIMER, self.IfacesMonitor, self.IfacesMonitorTimer) 
Example #11
Source File: __init__.py    From iqiyi-parser with MIT License 5 votes vote down vote up
def setTimerHandler(handler):
    if frame_downloader.timer.IsRunning():
        frame_downloader.timer.Stop()
    frame_downloader.Bind(wx.EVT_TIMER, handler, frame_downloader.timer) 
Example #12
Source File: main.py    From wxGlade with MIT License 5 votes vote down vote up
def create_statusbar(self):
        self.CreateStatusBar(1)
        # ALB 2004-10-15  statusbar timer: delete user message after some time
        self.clear_sb_timer = wx.Timer(self, -1)
        self.Bind(wx.EVT_TIMER, self.on_clear_sb_timer, self.clear_sb_timer) 
Example #13
Source File: wx_mpl_dynamic_graph.py    From code-for-blog with The Unlicense 5 votes vote down vote up
def __init__(self):
        wx.Frame.__init__(self, None, -1, self.title)
        
        self.datagen = DataGen()
        self.data = [self.datagen.next()]
        self.paused = False
        
        self.create_menu()
        self.create_status_bar()
        self.create_main_panel()
        
        self.redraw_timer = wx.Timer(self)
        self.Bind(wx.EVT_TIMER, self.on_redraw_timer, self.redraw_timer)        
        self.redraw_timer.Start(100) 
Example #14
Source File: backend_wx.py    From twitter-stock-recommendation with MIT License 5 votes vote down vote up
def start_event_loop(self, timeout=0):
        """
        Start an event loop.  This is used to start a blocking event
        loop so that interactive functions, such as ginput and
        waitforbuttonpress, can wait for events.  This should not be
        confused with the main GUI event loop, which is always running
        and has nothing to do with this.

        This call blocks until a callback function triggers
        stop_event_loop() or *timeout* is reached.  If *timeout* is
        <=0, never timeout.

        Raises RuntimeError if event loop is already running.
        """
        if hasattr(self, '_event_loop'):
            raise RuntimeError("Event loop already running")
        id = wx.NewId()
        timer = wx.Timer(self, id=id)
        if timeout > 0:
            timer.Start(timeout * 1000, oneShot=True)
            self.Bind(wx.EVT_TIMER, self.stop_event_loop, id=id)

        # Event loop handler for start/stop event loop
        self._event_loop = wxc.EventLoop()
        self._event_loop.Run()
        timer.Stop() 
Example #15
Source File: wx_mpl_dynamic_graph.py    From code-for-blog with The Unlicense 5 votes vote down vote up
def flash_status_message(self, msg, flash_len_ms=1500):
        self.statusbar.SetStatusText(msg)
        self.timeroff = wx.Timer(self)
        self.Bind(
            wx.EVT_TIMER, 
            self.on_flash_status_off, 
            self.timeroff)
        self.timeroff.Start(flash_len_ms, oneShot=True) 
Example #16
Source File: wx_mpl_bars.py    From code-for-blog with The Unlicense 5 votes vote down vote up
def flash_status_message(self, msg, flash_len_ms=1500):
        self.statusbar.SetStatusText(msg)
        self.timeroff = wx.Timer(self)
        self.Bind(
            wx.EVT_TIMER, 
            self.on_flash_status_off, 
            self.timeroff)
        self.timeroff.Start(flash_len_ms, oneShot=True) 
Example #17
Source File: backend_wx.py    From twitter-stock-recommendation with MIT License 5 votes vote down vote up
def __init__(self, parent, *args, **kwargs):
        TimerBase.__init__(self, *args, **kwargs)

        # Create a new timer and connect the timer event to our handler.
        # For WX, the events have to use a widget for binding.
        self.parent = parent
        self._timer = wx.Timer(self.parent, wx.NewId())
        self.parent.Bind(wx.EVT_TIMER, self._on_timer, self._timer)

     # Unbinding causes Wx to stop for some reason. Disabling for now.
#    def __del__(self):
#        TimerBase.__del__(self)
#        self.parent.Bind(wx.EVT_TIMER, None, self._timer) 
Example #18
Source File: flow.py    From iqiyi-parser with MIT License 5 votes vote down vote up
def checkFfmpeg():
        dlm = nbdler.Manager()
        if (not os.path.exists('ffmpeg.exe') or os.path.exists('ffmpeg.exe.nbdler')) and not os.path.exists(cv.FFMPEG_PATH):
            dlg = wx.MessageDialog(None, u'该程序需要ffmpeg.exe才能完成工作,是否要下载?', u'提示', wx.YES_NO | wx.ICON_INFORMATION)
            if dlg.ShowModal() != wx.ID_YES:
                return False

            dl = nbdler.open(urls=[TOOL_REQ_URL['ffmpeg']],
                             max_conn=16, filename='ffmpeg.zip')
            dlm.addHandler(dl)
            dlg = gui.DialogGetTool(gui.frame_downloader, u'正在下载 Ffmpeg 3.2.zip', dl.getFileSize(), dlm)

            dlg.Bind(wx.EVT_TIMER, GetTool._process, dlg.timer)
            dlg.timer.Start(50, oneShot=False)
            dlm.run()
            msg = dlg.ShowModal()
            if not dlm.isEnd():
                dlm.shutdown()
                dlg.Destroy()
                return False
            GetTool.unzip_ffmpeg('ffmpeg.zip')
            if msg == wx.ID_OK:
                return True
            else:
                return False
        else:
            return True 
Example #19
Source File: relay_board_gui.py    From R421A08-rs485-8ch-relay-board with MIT License 5 votes vote down vote up
def OnBtnRelayPulse(self, event=None):
        relay = event.GetId()
        delay = self.m_spnDelay[relay - 1].GetValue()
        self.OnBtnRelayOnClick(event)
        self.m_timer[relay - 1].StartOnce(delay * 1000)
        self.Bind(wx.EVT_TIMER, self.notify, self.m_timer[relay - 1]) 
Example #20
Source File: flow.py    From iqiyi-parser with MIT License 5 votes vote down vote up
def do(parser_info):
            avl = list(parser_info.keys())
            dlg = wx.MultiChoiceDialog(gui.frame_parse, u'以下核心可以更新', u'更新核心', avl)
            if dlg.ShowModal() != wx.ID_OK:
                dlg.Destroy()
                return False
            sel = dlg.GetSelections()
            for i in sel:

                # for i, j in parser_info.items():
                dlm = nbdler.Manager()
                dl = nbdler.open(urls=[urljoin(cv.REPO, avl[i])], max_conn=3, filename=avl[i] + '.gzip', block_size=1,
                                 filepath=cv.PARSER_PATH)
                dlm.addHandler(dl)
                dlg = gui.DialogGetTool(gui.frame_parse, u'正在下载 %s.gzip' % avl[i], dl.getFileSize(), dlm)

                dlg.Bind(wx.EVT_TIMER, GetTool._process, dlg.timer)
                dlg.timer.Start(50, oneShot=False)
                dlm.run()
                msg = dlg.ShowModal()
                if msg != wx.ID_OK:
                    return False
                else:
                    try:
                        with open(os.path.join(cv.PARSER_PATH, avl[i]), 'w') as f:
                            f.write(gzip.open(os.path.join(cv.PARSER_PATH, avl[i] + '.gzip')).read().decode('utf-8'))
                        os.remove(os.path.join(cv.PARSER_PATH, avl[i] + '.gzip'))
                    except:
                        dlg = wx.MessageDialog(gui.frame_parse, traceback.format_exc(), avl[i], wx.OK | wx.ICON_ERROR)
                        dlg.ShowModal()
                        dlg.Destroy()

            dlg.Destroy()
            dlg = wx.MessageDialog(gui.frame_parse, '核心更新完成!', '提示', wx.OK | wx.ICON_INFORMATION)
            dlg.ShowModal()
            dlg.Destroy()

            LoadParserCore.handle() 
Example #21
Source File: backend_wx.py    From coffeegrindsize with MIT License 5 votes vote down vote up
def start_event_loop(self, timeout=0):
        """
        Start an event loop.  This is used to start a blocking event
        loop so that interactive functions, such as ginput and
        waitforbuttonpress, can wait for events.  This should not be
        confused with the main GUI event loop, which is always running
        and has nothing to do with this.

        This call blocks until a callback function triggers
        stop_event_loop() or *timeout* is reached.  If *timeout* is
        <=0, never timeout.

        Raises RuntimeError if event loop is already running.
        """
        if hasattr(self, '_event_loop'):
            raise RuntimeError("Event loop already running")
        id = wx.NewId()
        timer = wx.Timer(self, id=id)
        if timeout > 0:
            timer.Start(timeout * 1000, oneShot=True)
            self.Bind(wx.EVT_TIMER, self.stop_event_loop, id=id)

        # Event loop handler for start/stop event loop
        self._event_loop = wx.GUIEventLoop()
        self._event_loop.Run()
        timer.Stop() 
Example #22
Source File: backend_wx.py    From CogAlg with MIT License 5 votes vote down vote up
def start_event_loop(self, timeout=0):
        # docstring inherited
        if hasattr(self, '_event_loop'):
            raise RuntimeError("Event loop already running")
        timer = wx.Timer(self, id=wx.ID_ANY)
        if timeout > 0:
            timer.Start(timeout * 1000, oneShot=True)
            self.Bind(wx.EVT_TIMER, self.stop_event_loop, id=timer.GetId())
        # Event loop handler for start/stop event loop
        self._event_loop = wx.GUIEventLoop()
        self._event_loop.Run()
        timer.Stop() 
Example #23
Source File: main.py    From python-examples with MIT License 5 votes vote down vote up
def __init__(self, parent, camera, fps=15, flip=False):
        wx.Window.__init__(self, parent)

        # remember arguments
        self.camera = camera
        self.fps = fps
        self.flip = flip

        # get frame size
        ret_value, frame = self.camera.read()
        height, width = frame.shape[:2]

        # resize panel with camera image
        self.SetSize( (width, height) )
        #self.SetMinSize( (width, height) )
        
        # resize main window
        self.GetParent().GetParent().SetSize( (width, height+37) ) # wymaga poprawki aby nie trzeba bylo dawac +37
        #self.GetGrandParent().SetSize( (width, height+25) )
        #self.GetTopLevelParent().SetSize( (width, height+25) ) # wrong parent
        
        frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
        
        if self.flip:
            frame = cv2.flip(frame, 1)

        # create bitmap with frame
        self.bmp = wx.BitmapFromBuffer(width, height, frame)

        # timer to refresh frames
        self.timer = wx.Timer(self)
        self.timer.Start(1000./fps)

        # add functions to events 
        self.Bind(wx.EVT_PAINT, self.OnPaint)   # run when it is needed
        self.Bind(wx.EVT_TIMER, self.NextFrame) # run by timer 
Example #24
Source File: local_display.py    From Pigrow with GNU General Public License v3.0 5 votes vote down vote up
def __init__( self, parent ):
        wx.Panel.__init__ ( self, parent, id = wx.ID_ANY, style = wx.TAB_TRAVERSAL )
        # timer
        self.timer = wx.Timer(self)
        self.Bind(wx.EVT_TIMER, self.update, self.timer)
        # Tab Title
        title_l = wx.StaticText(self,  label='Live Display', size=(-1,40))
        title_l.SetBackgroundColour((50,250,250))
        title_l.SetFont(shared_data.title_font)
        self.toggleBtn = wx.Button(self, wx.ID_ANY, "Start")
        self.toggleBtn.Bind(wx.EVT_BUTTON, self.onToggle)
        bitmap = wx.Bitmap(1, 1)
        #bitmap.LoadFile(pic_one, wx.BITMAP_TYPE_ANY)
        size = bitmap.GetSize()
        self.img_bmp_box = wx.StaticBitmap(self, -1, bitmap, size=(size[0], size[1]))


        # sizers
        self.image_sizer = wx.BoxSizer(wx.VERTICAL)
        self.image_sizer.Add(self.img_bmp_box, 0, wx.EXPAND, 3)

        main_sizer = wx.BoxSizer(wx.VERTICAL)
        main_sizer.Add(title_l, 0, wx.ALIGN_CENTER_HORIZONTAL, 3)
        main_sizer.Add(self.toggleBtn, 0, wx.ALIGN_CENTER_HORIZONTAL, 3)
        main_sizer.Add(self.image_sizer, 0, wx.ALL|wx.ALIGN_CENTER_HORIZONTAL, 3)
        self.SetSizer(main_sizer) 
Example #25
Source File: TreeCtrl.py    From EventGhost with GNU General Public License v2.0 5 votes vote down vote up
def OnDragTimerEvent(self, dummyEvent):
        """
        Handles wx.EVT_TIMER, while a drag operation is in progress. It is
        responsible for the automatic scrolling if the mouse gets on the
        upper or lower bounds of the control.
        """
        tree = self.treeCtrl
        x, y = wx.GetMousePosition()
        treeRect = tree.GetScreenRect()
        if treeRect.x <= x <= treeRect.GetRight():
            if y < treeRect.y + 20:
                tree.ScrollLines(-1)
            elif y > treeRect.GetBottom() - 20:
                tree.ScrollLines(1) 
Example #26
Source File: ProjectController.py    From OpenPLC_Editor with GNU General Public License v3.0 5 votes vote down vote up
def ResetAppFrame(self, logger):
        if self.AppFrame is not None:
            self.AppFrame.Unbind(wx.EVT_TIMER, self.StatusTimer)
            self.StatusTimer = None
            self.AppFrame = None
            self.KillDebugThread()
        self.logger = logger 
Example #27
Source File: Gui.py    From Crypter with GNU General Public License v3.0 5 votes vote down vote up
def set_events(self):
        '''
        @summary: Create button and timer events for GUI
        '''

        # Create and bind timer event
        self.key_destruction_timer = wx.Timer()
        self.key_destruction_timer.SetOwner(self, wx.ID_ANY)
        self.key_destruction_timer.Start(500)
        self.Bind(wx.EVT_TIMER, self.blink, self.key_destruction_timer)

        # Create button events
        self.Bind(wx.EVT_BUTTON, self.show_encrypted_files, self.ViewEncryptedFilesButton)
        self.Bind(wx.EVT_BUTTON, self.show_decryption_dialog, self.EnterDecryptionKeyButton)
        self.Bind(wx.EVT_BUTTON, self.open_url, self.BitcoinButton) 
Example #28
Source File: ToolTipProducer.py    From OpenPLC_Editor with GNU General Public License v3.0 5 votes vote down vote up
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) 
Example #29
Source File: ProjectController.py    From OpenPLC_Editor with GNU General Public License v3.0 5 votes vote down vote up
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() 
Example #30
Source File: backend_wx.py    From neural-network-animation with MIT License 5 votes vote down vote up
def start_event_loop(self, timeout=0):
        """
        Start an event loop.  This is used to start a blocking event
        loop so that interactive functions, such as ginput and
        waitforbuttonpress, can wait for events.  This should not be
        confused with the main GUI event loop, which is always running
        and has nothing to do with this.

        Call signature::

        start_event_loop(self,timeout=0)

        This call blocks until a callback function triggers
        stop_event_loop() or *timeout* is reached.  If *timeout* is
        <=0, never timeout.

        Raises RuntimeError if event loop is already running.
        """
        if hasattr(self, '_event_loop'):
            raise RuntimeError("Event loop already running")
        id = wx.NewId()
        timer = wx.Timer(self, id=id)
        if timeout > 0:
            timer.Start(timeout*1000, oneShot=True)
            bind(self, wx.EVT_TIMER, self.stop_event_loop, id=id)

        # Event loop handler for start/stop event loop
        self._event_loop = wx.EventLoop()
        self._event_loop.Run()
        timer.Stop()