我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用wx.EVT_TIMER。
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): """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 convert(self): self.Bind(wx.EVT_TIMER, self.OnTimer2, self.timer2) self.dltext.SetLabel(self.query) self.panel.Layout() imageFile = 'Files\image.jpg' data = open(imageFile, "rb").read() # convert to a data stream stream = cStringIO.StringIO(data) # convert to a bitmap bmp = wx.BitmapFromImage( wx.ImageFromStream( stream )) # show the bitmap, (5, 5) are upper left corner coordinates thumb = wx.StaticBitmap(self, -1, bmp, (90,255)) self.Hide() self.Show() self.text.SetLabel('Converting...') if self.rb1.GetValue() == True: self.timer2.Start(1000) worker1 = threading.Thread(target=lambda: self.getfile.get_file('http://www.youtube.com/%s'%self.vidurl, '320')) worker1.start() elif self.rb2.GetValue() == True: self.timer2.Start(600) worker1 = threading.Thread(target=lambda: self.getfile.get_file('http://www.youtube.com/%s'%self.vidurl, '128')) worker1.start()
def download(self): self.Bind(wx.EVT_TIMER, self.OnTimer3, self.timer3) self.timer3.Start(1600) self.text.SetLabel('Downloading...') self.filename = self.nametc.GetValue() file_name = self.new_path + self.filename try: worker2 = threading.Thread(target=lambda: self.getfile.download_file(self.getfile.convhtml, file_name )) worker2.start() except: self.Error("Error on conversion! Please retry") self.reset()
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 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): 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, 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 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
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 __init__(self): wx.Frame.__init__(self, None, title="Focus Finder") panel = wx.Panel(self, wx.ID_ANY) panel.Bind(wx.EVT_SET_FOCUS, self.onFocus) txt = wx.StaticText( panel, label="This label cannot receive focus") self.timer = wx.Timer(self) self.Bind(wx.EVT_TIMER, self.onTimer) self.timer.Start(1000)
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)
def __init__(self, parent=None, id=-1, title=None): wx.Frame.__init__(self, parent, id, title) self.panel = wx.Panel(self, size=(640, 480)) self.panel.SetBackgroundColour('WHITE') self.Fit() self.A = Agent(self.panel, 150, 100 ) self.greenB = [Ball(rnd.randint(40, 600),rnd.randint(40, 440), wx.Colour(112,173,71), property = 1) for i in range(0, 15)] self.redB = [Ball(rnd.randint(40, 600),rnd.randint(40, 440), wx.Colour(237,125,49), property = 2) for i in range(0, 10)] # OutrBox self.Box = Walls(640, 480, 0, 480) self.Box.addPoint(0,0) self.Box.addPoint(640,0) self.Box.addPoint(640,480) # Wall in the world self.WallA = Walls(96, 90, 256, 90) self.WallA.addPoint(256, 390) self.WallA.addPoint(96,390) self.Bind(wx.EVT_CLOSE, self.CloseWindow) 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, parent, id, title, style, clargs): if _plat.startswith('win'): HANDLER = logging.handlers.WatchedFileHandler(os.environ.get("LOGFILE", os.path.join(os.path.expanduser('~'), 'stopgo.log'))) else: HANDLER = logging.handlers.WatchedFileHandler(os.environ.get("LOGFILE", os.path.join('/','tmp','stopgo.log'))) FORMATTER = logging.Formatter(logging.BASIC_FORMAT) HANDLER.setFormatter(FORMATTER) if not clargs.has_key('verbose'): root = logging.getLogger() root.setLevel(os.environ.get("LOGLEVEL", "INFO")) root.addHandler(HANDLER) logging.exception("Debugging on.") #First retrieve the screen size of the device self.screenSize = wx.DisplaySize() self.framlog = 0 self.thumbsize = 180 self.camset = 0 self.prefdate = 0 prefstr = pref.PrefProbe().PrefGet() logging.exception(prefstr) logging.exception(type(prefstr)) self.myprefs = prefstr #self.myprefs = json.dumps(prefstr, sort_keys=True) #self.screenSize = [ 786, 768 ] self.screenWidth = int(self.screenSize[0]) self.screenHeight = int(self.screenSize[1]) #self.screenWidth = int(self.screenSize[0] / 3) #self.screenHeight = int(self.screenSize[1] / 1.5) self.hasSelected = False self.previous = 0 #fontsy = wx.SystemSettings.GetFont(wx.SYS_SYSTEM_FONT).GetPixelSize() wx.Frame.__init__(self, parent, id, title, size=(self.screenWidth, self.screenHeight), style=wx.DEFAULT_FRAME_STYLE) self.timer = wx.Timer(self, ID_TIMER) self.blick = 0 self.Bind(wx.EVT_TIMER, self.OnTimer, id=ID_TIMER) self.Bind(wx.EVT_CHAR_HOOK, lambda event, args=(True, ):self.OnKeyDown(event, args)) self.clargs = clargs logging.exception(prefstr) self.InitUI()
def __init__(self, parent, sample, run, api): """Initialize the SamplePanel. Args: parent: the parent Window for this panel. sample: the sample that should be displayed. run: the run that this sample belongs to. api: an initialized instance of an API for interacting with IRIDA. """ wx.Panel.__init__(self, parent) self._sample = sample self._timer = wx.Timer(self) self._progress_value = 0 self._last_timer_progress = 0 self._progress = None self._progress_max = sample.get_files_size() self._sizer = wx.BoxSizer(wx.HORIZONTAL) self._label = wx.StaticText(self, label=self._sample.get_id()) self._sizer.Add(self._label, proportion=2) self._status_label = wx.StaticText(self, label="Validating...") self._sizer.Add(self._status_label) self.SetSizer(self._sizer) self.Bind(wx.EVT_TIMER, self._update_progress_timer, self._timer) self.Layout() pub.subscribe(self._upload_completed, sample.upload_completed_topic) pub.subscribe(self._upload_progress, sample.upload_progress_topic) if not sample.already_uploaded: pub.subscribe(self._validation_results, sample.online_validation_topic) pub.subscribe(self._upload_started, sample.upload_started_topic) pub.subscribe(self._upload_failed, sample.upload_failed_topic) threading.Thread(target=project_exists, kwargs={"api": api, "project_id": sample.get_project_id(), "message_id": sample.online_validation_topic}).start() else: # this sample is already uploaded, so inform the run panel to move # it down to the bottom of the list. send_message(sample.upload_completed_topic, sample=sample) self._status_label.Destroy() self._upload_completed()
def __init__(self, trayicon, tooltip): super(TaskBarIcon, self).__init__() self.show_no_updates = False # Set trayicon and tooltip icon = wx.Icon(wx.Bitmap(trayicon)) self.SetIcon(icon, tooltip) self.Bind(wx.adv.EVT_TASKBAR_LEFT_DCLICK, self.on_upgrade) self.Bind(wx.adv.EVT_TASKBAR_BALLOON_CLICK, self.on_bubble) self.upd_error_count = 0 self.checking_updates = False self.updates_available = False self.shutdown_scheduled = False self.reboot_scheduled = False self.bootup_time = getBootUp() if update_interval and update_method: self.timer = wx.Timer(self) self.Bind(wx.EVT_TIMER, self.on_timer, self.timer) self.timer.Start(update_interval) if update_startup: self.on_timer(None) if check_bootup_log: last_check = check_file_date(xml_file) now = datetime.datetime.now() if (self.bootup_time + datetime.timedelta(hours=1) > now) and \ (self.bootup_time + datetime.timedelta(minutes=30) > last_check): log, errorlog, reboot = check_eventlog(self.bootup_time) if errorlog: error_str = _(u"Update error detected\n" u"during system start up.") self.ShowBalloon(title=_(u'WPKG Error'), text=error_str, msec=20*1000, flags=wx.ICON_ERROR) title = _(u"System start error") dlg = ViewLogDialog(title=title,log=errorlog) dlg.ShowModal() if check_last_upgrade: # Check if the last changes to the local wpkg.xml are older than a specific time # Inform USER that he should upgrade the System last_check = check_file_date(xml_file) if last_check < (datetime.datetime.now() - datetime.timedelta(days=last_upgrade_interval)): dlg_str = _(u"System should be updated!\n\n" u"System wasn't updated in over {} days.").format(str(last_upgrade_interval)) dlg = wx.MessageDialog(None, dlg_str, _(u"Attention!"), wx.OK | wx.ICON_EXCLAMATION) dlg.ShowModal() self.on_upgrade(None)
def __init__(self, trayicon, tooltip): super(TaskBarIcon, self).__init__() self.show_no_updates = False # Set trayicon and tooltip icon = wx.IconFromBitmap(wx.Bitmap(trayicon)) self.SetIcon(icon, tooltip) self.Bind(wx.EVT_TASKBAR_LEFT_DCLICK, self.on_upgrade) self.Bind(wx.EVT_TASKBAR_BALLOON_CLICK, self.on_bubble) self.upd_error_count = 0 self.checking_updates = False self.updates_available = False self.shutdown_scheduled = False self.reboot_scheduled = False self.bootup_time = getBootUp() if update_interval and update_method: self.timer = wx.Timer(self) self.Bind(wx.EVT_TIMER, self.on_timer, self.timer) self.timer.Start(update_interval) if update_startup: self.on_timer(None) if check_bootup_log: last_check = ReadLastSyncTime() now = datetime.datetime.now() if (self.bootup_time + datetime.timedelta(hours=1) > now) and \ (self.bootup_time + datetime.timedelta(minutes=30) > last_check): log, errorlog, reboot = check_eventlog(self.bootup_time) if errorlog: error_str = _(u"Update error detected\n" u"during system start up.") self.ShowBalloon(title=_(u'WPKG Error'), text=error_str, msec=20*1000, flags=wx.ICON_ERROR) title = _(u"System start error") dlg = ViewLogDialog(title=title,log=errorlog) dlg.ShowModal() if check_last_upgrade: # Check when WPKG-GP sucessfully synced the last time # Inform USER that he should upgrade the System last_sync = ReadLastSyncTime() if last_sync: if last_sync < (datetime.datetime.now() - datetime.timedelta(days=last_upgrade_interval)): dlg_str = _(u"System should be updated!\n\n" u"System wasn't updated in over {} days.").format(str(last_upgrade_interval)) dlg = wx.MessageDialog(None, dlg_str, _(u"Attention!"), wx.OK | wx.ICON_EXCLAMATION) dlg.ShowModal() self.on_upgrade(None)
def __init__(self, parent=None, id=-1, title=None): wx.Frame.__init__(self, parent, id, title) self.MainPanel = wx.Panel(self, size=(640, 640)) self.MainPanel.SetBackgroundColour('WHITE') self.panel = wx.Panel(self.MainPanel, size = (640,480)) self.panel.SetBackgroundColour('WHITE') self.plotter = plot.PlotCanvas(self.MainPanel, size =(640, 640-480)) self.plotter.SetEnableZoom(False) self.plotter.SetEnableLegend(True) self.plotter.SetFontSizeLegend(10.5) mainSizer = wx.BoxSizer(wx.VERTICAL) mainSizer.Add(self.panel) mainSizer.Add(self.plotter) self.SetSizer(mainSizer) self.Fit() self.A = Agent(self.panel, 240, 49 ) self.B = Agent(self.panel, 240, 49) self.B.B_color = wx.Colour(112,173,71) # OutrBox self.Box = Walls(640, 479, 0, 479) self.Box.addPoint(0,0) self.Box.addPoint(640,0) self.Box.addPoint(640,479) # Oval Course Rad = 190.0 Poly = 16 self.Course = Walls(240, 50, 640-(50+Rad),50) for i in range(1, Poly): self.Course.addPoint(Rad*math.cos(-np.pi/2.0 + np.pi*i/Poly)+640-(50+Rad), Rad*math.sin(-np.pi/2.0 + np.pi*i/Poly)+50+Rad) self.Course.addPoint(240, 50+Rad*2) for i in range(1, Poly): self.Course.addPoint(Rad*math.cos(np.pi/2.0 + np.pi*i/Poly)+(50+Rad), Rad*math.sin(np.pi/2.0 + np.pi*i/Poly)+50+Rad) self.Course.addPoint(240,50) self.Bind(wx.EVT_CLOSE, self.CloseWindow) 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) self.i = 0 self.tmp_sum = 0.0 self.data = []
def __init__(self, parent=None, id=-1, title=None): wx.Frame.__init__(self, parent, id, title) self.MainPanel = wx.Panel(self, size=(640, 640)) self.MainPanel.SetBackgroundColour('WHITE') self.panel = wx.Panel(self.MainPanel, size = (640,480)) self.panel.SetBackgroundColour('WHITE') self.plotter = plot.PlotCanvas(self.MainPanel, size =(640, 640-480)) self.plotter.SetEnableZoom(False) self.plotter.SetEnableLegend(True) self.plotter.SetFontSizeLegend(10.5) mainSizer = wx.BoxSizer(wx.VERTICAL) mainSizer.Add(self.panel) mainSizer.Add(self.plotter) self.SetSizer(mainSizer) self.Fit() self.A = Agent(self.panel, 150, 100 ) self.B = Agent(self.panel, 400, 300, model = self.A.model) self.C = Agent(self.panel, 400, 150, model = self.A.model) self.D = Agent(self.panel, 320, 240, model = self.A.model) self.greenB = [Ball(rnd.randint(40, 600),rnd.randint(40, 440), wx.Colour(112,173,71), property = 1) for i in range(0, 15)] self.redB = [Ball(rnd.randint(40, 600),rnd.randint(40, 440), wx.Colour(237,125,49), property = 2) for i in range(0, 10)] # OutrBox self.Box = Walls(640, 480, 0, 480) self.Box.addPoint(0,0) self.Box.addPoint(640,0) self.Box.addPoint(640,480) # Wall in the world self.WallA = Walls(96, 90, 256, 90) self.WallA.addPoint(256, 390) self.WallA.addPoint(96,390) self.Bind(wx.EVT_CLOSE, self.CloseWindow) 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) self.i = 0 self.tmp_sum = 0.0 self.data = []