我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用wx.Timer()。
def OnTimer(self,e): self.bplay.SetBitmapLabel(self.bstopicon) try: logging.exception("selected is --> " + str(self.selected.GetName()) ) filepath = os.path.join(self.imgdir,self.framlist[self.blick][1]) img = self.MakeThumbnail(filepath, self.screenWidth/2)#640 self.PaintCanvas(img) self.blick = self.blick + 1 logging.exception(self.blick) except: logging.exception('Timer Fail') self.timer.Stop() self.bplay.SetBitmapLabel(self.bplayicon) self.blick = 0 self.player.play() self.brec.SetBitmapLabel(self.brecicon) self.panel2.Refresh()
def __init__(self, size=(300, 300), pos=(100, 100)): wx.Frame.__init__(self, None, title="Am I transparent?", style=wx.SIMPLE_BORDER | wx.STAY_ON_TOP | wx.FRAME_NO_TASKBAR) self.SetClientSize(size) self.SetPosition(pos) self.alphaValue = 220 self.alphaIncrement = -4 pnl = wx.Panel(self) # self.changeAlpha_timer = wx.Timer(self) # self.changeAlpha_timer.Start(50) # self.Bind(wx.EVT_TIMER, self.ChangeAlpha) self.MakeTransparent(self.alphaValue) self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)
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)
def __init__(self): wx.Frame.__init__(self, None, title="Timer Tutorial 2") panel = wx.Panel(self, wx.ID_ANY) self.timer = wx.Timer(self, id=TIMER_ID1) self.Bind(wx.EVT_TIMER, self.update, self.timer) self.timer2 = wx.Timer(self, id=TIMER_ID2) self.Bind(wx.EVT_TIMER, self.update, self.timer2) self.toggleBtn = wx.Button(panel, wx.ID_ANY, "Start Timer 1") self.toggleBtn.Bind(wx.EVT_BUTTON, self.onStartTimerOne) self.toggleBtn2 = wx.Button(panel, wx.ID_ANY, "Start Timer 2") self.toggleBtn2.Bind(wx.EVT_BUTTON, self.onStartTimerOne) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(self.toggleBtn, 0, wx.ALL|wx.CENTER, 5) sizer.Add(self.toggleBtn2, 0, wx.ALL|wx.CENTER, 5) panel.SetSizer(sizer)
def __init__(self): wx.Frame.__init__(self, None, title="Timer Tutorial 2") panel = wx.Panel(self, wx.ID_ANY) self.timer = wx.Timer(self, wx.ID_ANY) self.Bind(wx.EVT_TIMER, self.update, self.timer) self.timer2 = wx.Timer(self, wx.ID_ANY) self.Bind(wx.EVT_TIMER, self.update, self.timer2) self.toggleBtn = wx.Button(panel, wx.ID_ANY, "Start Timer 1") self.toggleBtn.Bind(wx.EVT_BUTTON, self.onStartTimer) self.toggleBtn2 = wx.Button(panel, wx.ID_ANY, "Start Timer 2") self.toggleBtn2.Bind(wx.EVT_BUTTON, self.onStartTimer) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(self.toggleBtn, 0, wx.ALL|wx.CENTER, 5) sizer.Add(self.toggleBtn2, 0, wx.ALL|wx.CENTER, 5) panel.SetSizer(sizer) # Each value in the following dict is formatted as follows: # (timerNum, timerObj, secs between timer events) self.objDict = {self.toggleBtn: (1, self.timer, 1000), self.toggleBtn2: (2, self.timer2, 3000)}
def __init__(self): """Constructor""" wx.wizard.Wizard.__init__(self, None, title="Disable Next") self.SetPageSize((500, 350)) mypage1 = self.create_page1() forward_btn = self.FindWindowById(wx.ID_FORWARD) forward_btn.Disable() self.timer = wx.Timer(self) self.Bind(wx.EVT_TIMER, self.onUpdate, self.timer) self.timer.Start(1) self.RunWizard(mypage1)
def __init__(self): """Constructor""" Wizard.__init__(self, None, title="Disable Next") self.SetPageSize((500, 350)) mypage1 = self.create_page1() forward_btn = self.FindWindowById(wx.ID_FORWARD) forward_btn.Disable() self.timer = wx.Timer(self) self.Bind(wx.EVT_TIMER, self.onUpdate, self.timer) self.timer.Start(1) self.RunWizard(mypage1)
def __init__(self): wx.Frame.__init__(self, None, title=self.title, size=(660,330)) # Init controller self.controller = XboxController() # Create GUI self.create_main_panel() # Timer self.timer = wx.Timer(self) self.Bind(wx.EVT_TIMER, self.on_timer, self.timer) self.rate = SAMPLE_RATE self.idle_rate = IDLE_SAMPLE_RATE self.timer.Start(self.idle_rate) self.recording = False self.t = 0
def __init__(self, timelen, services): wx.Frame.__init__(self, parent=None, title=C_APP_NAME) self.timelen = timelen * 1000 self.services = services self.Show(False) self.Bind(wx.EVT_TIMER, self.OnTimerEvent) self.Bind(wx.EVT_CLOSE, self.OnExitEvent) self.timer = wx.Timer(self) self.timer.Start(self.timelen)
def SetIconTimer(self): self.icon_timer = wx.Timer(self, ID_ICON_TIMER) wx.EVT_TIMER(self, ID_ICON_TIMER, self.BlinkIcon) self.icon_timer.Start(100) ## # \brief blinks the icon and updates self.l and self.r #
def reset(self): self.Bind(wx.EVT_TIMER, self.OnTimer1, self.timer1) self.text.SetLabel('Done!') self.count = 0 self.count2 = 0 self.count3 = 0 self.nametc.Clear() self.tc.Clear() self.timer1 = wx.Timer(self, 1) self.timer2 = wx.Timer(self, 1) self.timer3 = wx.Timer(self, 1)
def __init__(self, parent=None, id=-1, title=None): wx.Frame.__init__(self, parent, id, title) self.MainPanel = wx.Panel(self, size=(640, 480)) self.MainPanel.SetBackgroundColour('WHITE') self.panel = wx.Panel(self.MainPanel, size = (640,480)) self.panel.SetBackgroundColour('WHITE') mainSizer = wx.BoxSizer(wx.VERTICAL) mainSizer.Add(self.panel) self.SetSizer(mainSizer) self.Fit() self.Bind(wx.EVT_CLOSE, self.CloseWindow) self.World = None self.cdc = wx.ClientDC(self.panel) w, h = self.panel.GetSize() self.bmp = wx.EmptyBitmap(w,h) self.timer = wx.Timer(self) self.Bind(wx.EVT_TIMER, self.OnTimer) self.timer.Start(20)
def __init__(self): super(SignalKScope, self).__init__(None) self.plot = SignalKPlot() self.glContext = wx.glcanvas.GLContext(self.glArea) self.client = SignalKClientFromArgs(sys.argv[:2], True, self.on_con) self.host_port = self.client.host_port self.client.autoreconnect = False self.value_list = self.client.list_values() self.plot.init(self.value_list) self.watches = {} watches = sys.argv[2:] for name in sorted(self.value_list): if self.value_list[name]['type'] != 'SensorValue': continue i = self.clValues.Append(name) self.watches[name] = False for arg in watches: if arg == name: self.clValues.Check(i, True) self.watches[name] = True watches.remove(name) for arg in watches: print 'value not found:', arg self.on_con(self.client) self.timer = wx.Timer(self, wx.ID_ANY) self.Bind(wx.EVT_TIMER, self.receive_messages, id=wx.ID_ANY) self.timer.Start(100) self.sTime.SetValue(self.plot.disptime) self.plot_reshape = False
def __init__(self): super(CalibrationDialog, self).__init__(None) self.host = '' if len(sys.argv) > 1: self.host = sys.argv[1] self.client = False self.compass_calibration_plot = compass_calibration_plot.CompassCalibrationPlot() self.compass_calibration_glContext = wx.glcanvas.GLContext(self.CompassCalibration) self.boat_plot = boatplot.BoatPlot() self.boat_plot_glContext = wx.glcanvas.GLContext(self.BoatPlot) self.dsServoMaxCurrent.SetIncrement(.1) self.dsServoMaxCurrent.SetDigits(1) self.dsServoMaxCurrent.Bind( wx.EVT_SPINCTRLDOUBLE, self.onMaxCurrent ) self.lastmouse = False self.alignment_count = 0 self.timer = wx.Timer(self, self.ID_MESSAGES) self.timer.Start(50) self.Bind(wx.EVT_TIMER, self.receive_messages, id=self.ID_MESSAGES) self.servo_timer = wx.Timer(self, self.ID_CALIBRATE_SERVO) self.Bind(wx.EVT_TIMER, self.calibrate_servo_timer, id=self.ID_CALIBRATE_SERVO) self.servoprocess = False self.alignmentQ = [1, 0, 0, 0] self.fusionQPose = [1, 0, 0, 0]
def __init__(self, parent): wx.Dialog.__init__(self, parent, title="FestEngine Log", style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER) main_sizer = wx.BoxSizer(wx.VERTICAL) self.text_ctrl = wx.TextCtrl(self, style=wx.TE_READONLY | wx.TE_MULTILINE) main_sizer.Add(self.text_ctrl, 1, wx.EXPAND) self.pending_messages = list() self.timer = wx.Timer() self.timer.Bind(wx.EVT_TIMER, self.append_pending_messages) self.timer.Start(500) self.SetSizer(main_sizer)
def __init__(self, parent, run, api): """Initialize the RunPanel. Args: parent: The parent Window for this panel. run: The sequencing run that should be displayed. api: An initialized instance of an API for interacting with IRIDA. """ ScrolledPanel.__init__(self, parent, style=wx.SUNKEN_BORDER) box = wx.StaticBox(self, label=run.sample_sheet_name) self._timer = wx.Timer(self) self._run = run self._progress_value = 0 self._last_progress = 0 self._last_timer_progress = 0 self._sample_panels = {} # the current overall progress for the run is calculated as a percentage # of the total file size of all samples in the run. self._progress_max = sum(sample.get_files_size() for sample in run.samples_to_upload) logging.info("Total file size for run is {}".format(self._progress_max)) self._sizer = wx.StaticBoxSizer(box, wx.VERTICAL) pub.subscribe(self._upload_started, run.upload_started_topic) pub.subscribe(self._handle_progress, run.upload_progress_topic) pub.subscribe(self._upload_complete, run.upload_completed_topic) pub.subscribe(self._upload_failed, run.upload_failed_topic) for sample in run.sample_list: self._sample_panels[sample.get_id()] = SamplePanel(self, sample, run, api) self._sizer.Add(self._sample_panels[sample.get_id()], flag=wx.EXPAND | wx.LEFT | wx.RIGHT, border=5) self.SetSizer(self._sizer) self.Bind(wx.EVT_TIMER, self._update_progress_timer, self._timer) self.Layout() self.SetupScrolling()
def __init__(self, parent, *args, **kwargs): wx.StaticText.__init__(self, parent, *args, **kwargs) self._timer = wx.Timer(self) self._current_char = 0 # this is the only font face on windows that actually renders the clock faces correctly. self.SetFont(wx.Font(pointSize=wx.DEFAULT, family=wx.FONTFAMILY_DEFAULT, style=wx.NORMAL, weight=wx.FONTWEIGHT_NORMAL, face="Segoe UI Symbol")) self.Bind(wx.EVT_TIMER, self._update_progress_text, self._timer) self.Restart()
def __init__(self, func): self.func = func wx.Timer.__init__(self)
def initTextStim(self): self.stimArea = widgets.TextStim(self, stimText='', stimColor=self.stimColor, stimFont=self.stimFont) self.stimTimer = wx.Timer(self) self.Bind(wx.EVT_TIMER, self.changeStim, self.stimTimer)
def __init__(self, *args, **kwargs): self.paused = False # pause the plot without stopping data acquisition self.refreshDelay = 50.0 # milliseconds between plot updates, does not include draw time self.recordingTime = None # start time for EEG recording, None indicates not started StandardPage.__init__(self, *args, **kwargs) # wx timer for updating the monitor plot self.updateTimer = wx.Timer(self) self.Bind(wx.EVT_TIMER, self.runUpdatePlot, self.updateTimer)
def initStatusBar(self): """Initialize main status bar. """ nFields = 5 self.statusBar = self.CreateStatusBar() self.statusBar.SetFieldsCount(nFields) self.statusBar.SetStatusStyles([wx.SB_FLAT]*nFields) # update status bar at least once per second self.updateStatusTimer = wx.Timer(self) self.Bind(wx.EVT_TIMER, self.updateStatusBar, id=self.updateStatusTimer.GetId()) self.updateStatusTimer.Start(1000*1)
def initCollect(self): self.collecting = False self.rawView = True self.collectRefreshDelay = 0.025 self.collectTimer = wx.Timer(self) self.Bind(wx.EVT_TIMER, self.updateTrace, self.collectTimer)
def initRefreshTimer(self): self.refreshTimer = wx.Timer(self) # timer to update game state self.Bind(wx.EVT_TIMER, self.update, self.refreshTimer) # handle timer events self.bindKeyboard() self.refreshTimer.Start(30.0)
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)
def __init__(self, parent): wx.Panel.__init__(self, parent) self.ancestor = parent self.filename = "" self.dirname = '.' self.vbox = wx.BoxSizer(wx.VERTICAL) self.log= wx.TextCtrl(self, style=wx.TE_MULTILINE | wx.TE_READONLY | wx.HSCROLL) self.vbox.Add(self.log, 1, wx.EXPAND | wx.ALL, 2) self.vbox.AddSpacer(2) self.hbox_ent = wx.BoxSizer(wx.HORIZONTAL) self.hbox_ent.AddSpacer(20) self.font = self.ancestor.GetParent().font self.label = wx.StaticText(self, -1,"Log Entry:", style=wx.ALIGN_CENTRE_HORIZONTAL, size=(160,-1) ) self.label.SetFont(self.font) self.hbox_ent.Add( self.label, 0, wx.EXPAND | wx.LEFT | wx.RIGHT, 2) self.entry = wx.TextCtrl(self, -1, style=wx.TE_PROCESS_ENTER) self.entry.SetFont(self.font) self.entry.SetValue("") if IsNotWX4(): self.entry.SetToolTipString("Enter comments into the log here.") else: self.entry.SetToolTip("Enter comments into the log here.") self.entry.Bind(wx.EVT_TEXT_ENTER, self.OnEnterComments) self.hbox_ent.Add( self.entry, 1, wx.EXPAND | wx.LEFT | wx.RIGHT) self.vbox.Add(self.hbox_ent, 0, wx.EXPAND) self.hbox_btn = wx.BoxSizer(wx.HORIZONTAL) self.hbox_btn.AddSpacer(20) self.button_save =wx.Button(self, label="Save Log") self.Bind(wx.EVT_BUTTON, self.OnClickSaveButton, self.button_save) self.hbox_btn.Add(self.button_save) self.button_clear =wx.Button(self, label="Clear Log") self.Bind(wx.EVT_BUTTON, self.OnClickClearButton, self.button_clear) self.hbox_btn.Add(self.button_clear) self.vbox.Add(self.hbox_btn, 0, wx.EXPAND) self.SetSizerAndFit(self.vbox) self.redir=RedirectText(self.log) sys.stdout=self.redir self.data_poll_timer = wx.Timer(self) self.Bind(wx.EVT_TIMER, self.UpdateLog, self.data_poll_timer)
def __init__(self, parent): wx.Panel.__init__(self, parent) self.ancestor = parent self.fontpointsize=wx.SystemSettings.GetFont(wx.SYS_SYSTEM_FONT).GetPointSize() self.colour = wx.Colour(30,70,115, alpha=wx.ALPHA_OPAQUE) self.canvas = PlotCanvas(self) if IsNotWX4(): self.canvas.SetInitialSize(size=self.GetClientSize()) self.canvas.SetShowScrollbars(True) self.canvas.SetEnableZoom(False) self.canvas.SetFontSizeAxis(point=12) self.canvas.SetFontSizeTitle(point=12) self.canvas.SetGridColour(wx.Colour(0, 0, 0)) self.canvas.SetForegroundColour(wx.Colour(0, 0, 0)) self.canvas.SetBackgroundColour(wx.Colour(255, 255, 255)) else: self.canvas.axesPen = wx.Pen(self.colour, width=1, style=wx.PENSTYLE_SOLID) self.canvas.SetForegroundColour(wx.Colour(0, 0, 0)) self.canvas.SetBackgroundColour(wx.Colour(255, 255, 255)) self.canvas.enableGrid = (True,True) self.canvas.fontSizeAxis = self.fontpointsize self.canvas.fontSizeTitle = self.fontpointsize self.vbox = wx.BoxSizer(wx.VERTICAL) self.vbox.Add(self.canvas, 1, flag=wx.LEFT | wx.TOP | wx.GROW) self.paused = False self.hbox_btn = wx.BoxSizer(wx.HORIZONTAL) self.hbox_btn.AddSpacer(20) self.button_pause =wx.Button(self, label="Pause Graph") self.Bind(wx.EVT_BUTTON, self.OnClickPauseButton, self.button_pause) self.hbox_btn.Add(self.button_pause) self.button_save =wx.Button(self, label="Save Data") self.Bind(wx.EVT_BUTTON, self.OnClickSaveButton, self.button_save) self.hbox_btn.Add(self.button_save) self.vbox.Add(self.hbox_btn, 0, wx.EXPAND) self.SetSizer(self.vbox) self.Fit() self.Show() self.data_poll_timer = wx.Timer(self) self.Bind(wx.EVT_TIMER, self.UpdateGraph, self.data_poll_timer)
def __init__(self, parent, id=wx.ID_ANY, style=wx.ALIGN_LEFT, size=(-1,-1), spinfunc=None): wx.Panel.__init__(self, parent) self.hbox = wx.BoxSizer(wx.HORIZONTAL) self.buttonP = wx.Button(self, -1, label="+", size=size) self.buttonM = wx.Button(self, -1, label="-", size=size) self.buttonP.Bind(wx.EVT_BUTTON, self.OnP) self.buttonM.Bind(wx.EVT_BUTTON, self.OnM) self.repeatTimerP = wx.Timer(self) self.repeatTimerM = wx.Timer(self) self.Bind(wx.EVT_TIMER, self.RepeatValueP, self.repeatTimerP) self.Bind(wx.EVT_TIMER, self.RepeatValueM, self.repeatTimerM) self.buttonP.Bind(wx.EVT_LEFT_DOWN, self.OnButPDown) self.buttonM.Bind(wx.EVT_LEFT_DOWN, self.OnButMDown) self.buttonP.Bind(wx.EVT_LEFT_UP, self.OnButPUp) self.buttonM.Bind(wx.EVT_LEFT_UP, self.OnButMUp) self.hbox.Add(self.buttonM, 0) self.hbox.Add(self.buttonP, 0) self.SetSizer(self.hbox) self.Fit() self.Layout() self.Show() self.max = 0 self.min = 0 self.range = 0 self.value = 0 self.SpinFunc = spinfunc self.n = 1 self.t1 = time() self.t2 = time()
def __init__(self, iren): wx.Timer.__init__(self) self.iren = iren
def __init__(self): wx.Frame.__init__(self, None, title=u"????",pos=(545,200),size=(420,150)) self.panelOne = PanelOne(self) self.time2die = 5 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)
def __init__(self, func): self.func = func wx.Timer.__init__(self) # @UndefinedVariable
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()
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()
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()
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)
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)
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
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 )
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.
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)
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
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()
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)
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)
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)
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)
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)