Exemplo n.º 1
0
    def __init__(self, parent, task):
        super().__init__(parent)

        self.m_buttonDebugMenu.SetLabel(u'\u22ee')  # 2630
        img.setItemBitmap(self.m_bitmapTick, 'tickmark')
        img.setItemBitmap(self.m_bitmapCross, 'crossmark')

        if settings().debugOptions:
            self.m_buttonDebugMenu.Show()

        self.m_buttonStop.SetFocus()
        self.Fit()
        self.Layout()

        self.errors = error.ErrorsCollector()
        self.pendingErrors = False

        self.task = task

        self.sync = Synchronizer(task.sub, task.ref)
        self.sync.onError = self.onError

        self.running = True
        self.closing = False
        self.runTime = wx.StopWatch()

        self.sleeper = gizmo.Sleeper()
        self.thread = gizmo.Thread(self.syncJob, name='Synchro')
Exemplo n.º 2
0
    def __init__(self):

        wx.Frame.__init__(self, None, title=self.title)

        # Try Arduino
        # try:
        # self.arduino = Arduino(arduino_port, 115200)
        # except:
        # print 'unable to connect to arduino'

        self.Maximize()

        self.plots_panel = Plots_Panel(self)
        self.action_panel = Action_Panel(self)

        #timer for the main loop and watch to record time
        self.timer = wx.Timer(self)
        self.Bind(wx.EVT_TIMER, self.on_timer, self.timer)
        self.sw = wx.StopWatch()
        self.sw.Pause()

        #start/stop button from action_panel
        self.action_panel.toggle.Bind(wx.EVT_TOGGLEBUTTON, self.onToggle)

        #Sizers
        panels = wx.BoxSizer(wx.VERTICAL)

        panels.Add(self.action_panel, 1, wx.GROW)
        panels.Add(self.plots_panel, 1, wx.GROW)

        self.SetSizerAndFit(panels)
        self.Layout()
Exemplo n.º 3
0
    def __init__(self, parent, task):
        super().__init__(parent)

        self.m_buttonDebugMenu.SetLabel(u'\u22ee')  # 2630

        if settings().debugOptions:
            self.m_buttonDebugMenu.Show()

        self.m_buttonStop.SetFocus()

        # workaround for truncated texts
        self.m_textStatus.SetMinSize(
            wx.Size(int(self.m_textStatus.GetSize().width * 1.2), -1))
        self.m_textSync.SetMinSize(
            wx.Size(int(self.m_textSync.GetSize().width * 1.2), -1))

        self.Fit()
        self.Layout()

        self.errors = error.ErrorsCollector()
        self.pendingErrors = False

        self.task = task

        self.sync = Synchronizer(task.sub, task.ref)
        self.sync.onError = self.onError

        self.running = True
        self.closing = False
        self.runTime = wx.StopWatch()

        self.thread = threading.Thread(target=self.syncJob, name='Synchro')
        self.thread.start()
Exemplo n.º 4
0
    def __init__(self, parent, tasks):
        super().__init__(parent)

        self.currentTask = None
        self.selectedTask = None

        self.tasks = [TaskState(task) for task in tasks]

        img.setItemBitmap(self.m_bitmapTick, 'tickmark')
        img.setItemBitmap(self.m_bitmapCross, 'crossmark')
        self.m_gaugeTotalProgress.SetRange(len(self.tasks) * 100)

        self.m_items.SetIconMap({
            'run': img.getBitmap('run'),
            'idle': img.getBitmap('idle'),
            'success': img.getBitmap('tickmark'),
            'fail': img.getBitmap('crossmark'),
            'run-err': img.getBitmap('run'),
            'idle-err': img.getBitmap('idle'),
            'success-err': img.getBitmap('tickmark'),
            'fail-err': img.getBitmap('error'),
        })

        for task in self.tasks:
            name = os.path.basename(task.getOutputPath())
            self.m_items.InsertItem(name, icon='idle', item=task)

        self.running = True
        self.closing = False
        self.runTime = wx.StopWatch()
        self.thread = threading.Thread(target=self.syncJob, name='BatchSync')
        self.thread.start()
Exemplo n.º 5
0
Arquivo: dForm.py Projeto: xfxf/dabo
    def __init__(self, preClass, parent, properties, attProperties, *args,
                 **kwargs):
        self.bizobjs = {}
        self._primaryBizobj = None
        self._dataUpdateDelay = 100
        self._rowNavigationDelay = 0

        # Use this for timing queries and other long-
        # running events
        self.stopWatch = wx.StopWatch()
        self.stopWatch.Pause()

        # Determines if the user is prompted to save changes when the form is closed
        # or a requery is about to happen.
        self._checkForChanges = True

        fm.dFormMixin.__init__(self,
                               preClass,
                               parent,
                               properties=properties,
                               attProperties=attProperties,
                               *args,
                               **kwargs)

        # Used to override some cases where the status
        # text should be displayed despite other processes
        # trying to overwrite it
        self._holdStatusText = ""
        # Holds the dataSource passed to the method
        self.dataSourceParameter = None
Exemplo n.º 6
0
 def __init__(self, title, category="Misc"):
     self.Title = title
     self.Name = title
     self.Category = category
     self._running = False
     self.stopwatch = wx.StopWatch()
     self.stopwatch.Pause()
     self.transient = False
     self.adjustment = 0
Exemplo n.º 7
0
 def _UpdateThread(self):
     "The worker thread to loop through files and flush any changes to the disk."
     sw = wx.StopWatch()
     swStart = sw.Start
     swPause = sw.Pause
     swTimeInMicro = sw.TimeInMicro
     running = self._UpdateTimerRunning.is_set
     wait = self._UpdateTimerDelay.wait
     clear = self._UpdateTimerDelay.clear
     interrupted = self._UpdateTimerDelay.is_set
     UpdateInterval = self._UpdateInterval * 1000000.0
     CheckAny = self.CheckAny
     sendMessage = pub.sendMessage
     acquire = self.FilesLock.acquire
     UpdateAll = self.UpdateAll
     release = self.FilesLock.release
     UpdateState = False
     while running():
         CurrentTime = 0.0
         delta = 1000000.0
         while True:
             if UpdateInterval == 0:
                 wait(None)
                 break
             swStart()
             delta = float(delta) - 1000000.0
             interval = UpdateInterval - CurrentTime
             sendMessage("FileUpdateTick", message=interval)
             if interval >= 1000000.0:
                 WaitTime = 1000000.0 - delta
                 wait(WaitTime / 1000000.0)
                 if interrupted():
                     swPause()
                     break
                 CurrentTime += WaitTime
                 NewUpdateState = CheckAny()
                 if NewUpdateState != UpdateState:
                     UpdateState = NewUpdateState
                     if UpdateState:
                         sendMessage("FileUpdatePending", message=None)
                     else:
                         sendMessage("FileUpdateClear", message=None)
             elif interval > 0:
                 wait((interval - delta) / 1000000.0)
                 swPause()
                 break
             else:
                 swPause()
                 break
             delta = swTimeInMicro()
         acquire()
         UpdateAll()
         release()
         clear()
         sendMessage("FileUpdateClear", message=None)
         UpdateState = False
Exemplo n.º 8
0
    def __init__(self, plot, timemanager):
        self.plot = plot
        self.timemanager = timemanager
        self.counter = wx.StopWatch()

        self.timei = None
        self.timef = None
        self.duration = None
        self.times = []

        self.started = False
        self.paused = False

        self.direction = 1  # 1 or -1
        self.position = 0  # seguinte que toca
Exemplo n.º 9
0
    def __init__(self, plot, timemanager):
        self.plot = plot
        self.timemanager = timemanager
        self.counter = wx.StopWatch()

        self.timei = None
        self.timef = None
        self.duration = None
        self.times = []

        self.started = False
        self.paused = False
        
        self.direction = 1 # 1 or -1
        self.position = None # actual
        self.positionI = 0 # primeiro
        self.positionF = 0 # ultimo
Exemplo n.º 10
0
    def __init__(self, parent, log):
        self.log = log
        wx.Panel.__init__(self, parent, -1)

        self.recordingKeys = False
        self.stopwatchKeys = wx.StopWatch()
        self.uisim = wx.UIActionSimulator()
        
        
        # create widgets and bind events
        keyLabel = wx.StaticText(self, -1, "Key Events")
        keyLabel.SetFont(wx.FFont(18, wx.SWISS, wx.FONTFLAG_BOLD))
        
        self.txt = wx.TextCtrl(self, size=(300,-1))
        self.txt.Bind(wx.EVT_KEY_DOWN, self.OnTxtKeyDown)
        self.txt.Bind(wx.EVT_KEY_UP, self.OnTxtKeyUp)
        
        self.recordBtn = buttons.GenToggleButton(self, -1, "Record")
        self.Bind(wx.EVT_BUTTON, self.OnToggleRecordKeys, self.recordBtn)
        self.recordBtn.SetToolTipString(
            "Click this button and then type some keys in the\n"
            "textctrl.  Click here again when done.")
        
        self.playbackKeysBtn = buttons.GenButton(self, -1, "Playback")
        self.Bind(wx.EVT_BUTTON, self.OnPlaybackKeys, self.playbackKeysBtn)
        self.playbackKeysBtn.SetToolTipString(
            "Record some key events and then click here to\n"
            "replay the recorded events.")
        self.playbackKeysBtn.Disable()
        
        
        # create the layout
        gbs = wx.GridBagSizer(10,10)
        gbs.Add(keyLabel, (0,0), span=(1,2))
        gbs.Add(self.txt, (1,1), span=(1,2))
        btnsizer = wx.BoxSizer(wx.HORIZONTAL)
        btnsizer.Add(self.recordBtn)
        btnsizer.Add((10,10))
        btnsizer.Add(self.playbackKeysBtn)
        gbs.Add(btnsizer, (2,1), span=(1,2))
        
        self.Sizer = wx.BoxSizer()
        self.Sizer.Add(gbs, 1, wx.EXPAND|wx.ALL, 20)
Exemplo n.º 11
0
 def __init__(self, parent):
     super().__init__(parent)
     super().SetBackgroundColour(wx.Colour(230, 230, 230))
     self.init_sizers()
     self.timer = wx.Timer(self)
     self.sw = wx.StopWatch()
     self.Bind(wx.EVT_TIMER, self.update, self.timer)
     self.init_variables()
     self.stopwatch_label_1 = wx.StaticText(self,
                                            label="0:00:00.0",
                                            size=(200, 40))
     self.stopwatch_label_1.SetForegroundColour(wx.BLACK)
     font_1 = wx.Font(30, wx.DEFAULT, wx.NORMAL, wx.FONTWEIGHT_NORMAL)
     self.stopwatch_label_1.SetFont(font_1)
     self.left_sizer.Add(self.stopwatch_label_1, 0, wx.ALL | wx.CENTER, 5)
     self.stopwatch_label_2 = wx.StaticText(self,
                                            label="0:00:00.0",
                                            size=(200, 40))
     self.stopwatch_label_2.SetForegroundColour(wx.Colour(77, 153, 255))
     font_2 = wx.Font(22, wx.DEFAULT, wx.NORMAL, wx.FONTWEIGHT_NORMAL)
     self.stopwatch_label_2.SetFont(font_2)
     self.left_sizer.Add(self.stopwatch_label_2, 0, wx.ALL | wx.CENTER, 5)
     self.set_list_ctrl()
     self.left_sizer.Add(self.lap_list_ctrl, 0, wx.ALL, 5)
     # Right sizer part
     lap_button = self.set_button('Lap', (242, 242, 242), self.on_lap)
     self.right_sub_sizer.Add(lap_button, 0, wx.ALL, 5)
     self.start_stop_button = self.set_button('Start', (77, 153, 255),
                                              self.on_start_stop)
     self.right_sub_sizer.Add(self.start_stop_button, 0, wx.ALL, 5)
     reset_button = self.set_button('Reset', (242, 242, 242), self.on_reset)
     self.right_sub_sizer.Add(reset_button, 0, wx.ALL, 5)
     show_lap = wx.CheckBox(self, label="Show lap time")
     show_lap.SetValue(True)
     show_lap.Bind(wx.EVT_CHECKBOX, self.on_show_lap)
     self.right_sizer.Add(show_lap, 0, wx.ALL | wx.ALIGN_CENTER_HORIZONTAL,
                          0)
Exemplo n.º 12
0
import wx
from srctools.logger import get_logger

stopwatch = wx.StopWatch()


def start():
    # starts the timer
    stopwatch.Start()


def stop():
    # stops the timer
    stopwatch.Pause()


def logTime():
    get_logger().info(
        f'Time taken to start: { stopwatch.Time() // 1000 }.{stopwatch.Time() % 1000}s'
    )
Exemplo n.º 13
0
 def test_stopwatch1(self):
     sw = wx.StopWatch()
     self.waitFor(1000)
     t = sw.Time()
     self.assertTrue(t > 900)
Exemplo n.º 14
0
 def start(self, tasks):
     self.tasks = tasks
     self.running = True
     self.runTime = wx.StopWatch()
     self.thread = threading.Thread(target=self.syncJob, name='BatchSync')
     self.thread.start()
Exemplo n.º 15
0
    def __init__(self):
        wx.Frame.__init__(self, None, wx.ID_ANY, "Time logger")

        self.stopwatch = wx.StopWatch()
        self.stopwatch.Pause()
        self.stop_switch = 0

        # Add a panel so it looks the correct on all platforms
        panel = wx.Panel(self, wx.ID_ANY)
        self.recuring_events_lc = wx.ListCtrl(self,
                                              size=(-1, 600),
                                              style=wx.LC_REPORT
                                              | wx.BORDER_SUNKEN)
        self.recuring_events_lc.Bind(wx.EVT_LIST_ITEM_ACTIVATED,
                                     self.onDoubleClick_recuring)
        #self.recuring_events_lc.Bind(wx.EVT_KEY_DOWN, self.onKeyPress)
        #self.recuring_events_lc.Bind(wx.EVT_KEY_UP, self.onkey_up)
        self.recuring_events_lc.InsertColumn(0, 'Action')
        self.recuring_events_lc.SetColumnWidth(0, 250)
        self.recuring_events_lc.InsertColumn(1, 'button')
        self.recuring_events_lc.InsertColumn(2, 'count')
        self.recuring_events_lc.InsertColumn(3, 'duration')
        self.recuring_events_lc.SetColumnWidth(3, 150)
        # buttons
        self.save_btn = wx.Button(self, label='Save')
        self.save_btn.Bind(wx.EVT_BUTTON, self.save_click)
        self.load_btn = wx.Button(self, label='Load')
        self.load_btn.Bind(wx.EVT_BUTTON, self.load_click)
        self.clear_btn = wx.Button(self, label='Clear')
        self.clear_btn.Bind(wx.EVT_BUTTON, self.clear_click)
        self.graph_btn = wx.Button(self, label='Graph')
        self.graph_btn.Bind(wx.EVT_BUTTON, self.graph_click)
        # timing options
        timing_opts = ['seconds', 'date']
        self.tiimg_style_cb = wx.ComboBox(self,
                                          choices=timing_opts,
                                          value="seconds",
                                          size=(200, 40))
        # timing icon
        timer_stopped_path = os.path.join(cwd, "timer_stop.png")
        timer_paused_path = os.path.join(cwd, "timer_pause.png")
        timer_running_path = os.path.join(cwd, "timer_start.png")
        self.timer_icon_stop = wx.Image(timer_stopped_path,
                                        wx.BITMAP_TYPE_ANY).ConvertToBitmap()
        self.timer_icon_pause = wx.Image(timer_paused_path,
                                         wx.BITMAP_TYPE_ANY).ConvertToBitmap()
        self.timer_icon_run = wx.Image(timer_running_path,
                                       wx.BITMAP_TYPE_ANY).ConvertToBitmap()
        self.timing_icon = wx.BitmapButton(self,
                                           -1,
                                           self.timer_icon_stop,
                                           size=(40, 40))
        self.timing_icon.Bind(wx.EVT_BUTTON, self.timing_icon_click)
        # graphs
        self.graph_space = wx.BitmapButton(self, -1, size=(600, 600))

        buttons_sizer = wx.BoxSizer(wx.HORIZONTAL)
        buttons_sizer.Add(self.save_btn, 0, wx.ALL | wx.EXPAND, 3)
        buttons_sizer.Add(self.load_btn, 0, wx.ALL | wx.EXPAND, 3)
        buttons_sizer.Add(self.clear_btn, 0, wx.ALL | wx.EXPAND, 3)
        buttons_sizer.AddStretchSpacer(1)
        buttons_sizer.Add(self.graph_btn, 0, wx.ALL | wx.EXPAND, 3)

        timing_sizer = wx.BoxSizer(wx.HORIZONTAL)
        timing_sizer.Add(self.tiimg_style_cb, 0, wx.ALL | wx.EXPAND, 3)
        timing_sizer.Add(self.timing_icon, 0, wx.ALL, 3)
        self.left_sizer = wx.BoxSizer(wx.VERTICAL)
        self.left_sizer.Add(buttons_sizer, 0, wx.ALL | wx.EXPAND, 3)
        self.left_sizer.Add(timing_sizer, 0, wx.ALL | wx.EXPAND, 3)
        #self.main_sizer.AddStretchSpacer(1)
        self.left_sizer.Add(self.recuring_events_lc, 0, wx.ALL | wx.EXPAND, 3)
        self.right_sizer = wx.BoxSizer(wx.VERTICAL)
        self.right_sizer.Add(self.graph_space, 0, wx.ALL | wx.EXPAND, 3)

        self.main_sizer = wx.BoxSizer(wx.HORIZONTAL)
        self.main_sizer.Add(self.left_sizer, 0, wx.ALL | wx.EXPAND, 3)
        self.main_sizer.Add(self.right_sizer, 0, wx.ALL | wx.EXPAND, 3)
        self.SetSizer(self.main_sizer)

        # delcairing variables
        self.test_time = 1