def updateGui(self): try: dlist = GuiMgr.get().GetDatalist() for key in dlist.keys(): try: objData = dlist[key][0] strFrom = dlist[key][1] self.dataViewTree.set(key, 'Value', objData.Value) self.dataViewTree.set(key, 'Source', strFrom) except Exception as Ex: try: index = self.__findIndex(key) self.dataViewTree.insert('', index, key, values=(objData.Namespace, objData.ID, str(objData.Value), strFrom)) except Exception as Ex: Log.getLogger().error(str(Ex)) except Exception as Ex: # Likely had the list updated while I was iterating (didn't make this thread safe), just ignore and wait for next loop pass
def updateGui(self): gm = GuiMgr.get() if gm.Live_Receiving or gm.Playback_Playing: val = DISABLED else: val = NORMAL if self._PreviousFileMenuStatus != val: #will kill performance if you do this every loop! self.FileMenu.entryconfigure(self.SaveAsCSV, state=val) self.FileMenu.entryconfigure(self.SaveStr, state=val) self.FileMenu.entryconfigure(self.OpenStr, state=val) self.FileMenu.entryconfigure(self.ExportToDB, state=val) self._PreviousFileMenuStatus = val self.__KludgeCounter = 0 if val == NORMAL: if Playback.get().GetDataCount() < 1: self.FileMenu.entryconfigure(self.SaveStr, state=DISABLED) self.FileMenu.entryconfigure(self.SaveAsCSV, state=DISABLED) self.FileMenu.entryconfigure(self.ExportToDB, state=DISABLED) else: self.__KludgeCounter += 1 # easy to get out of sync if stopped live, but no data, etc. Quick hack if self.__KludgeCounter > 100: self._PreviousFileMenuStatus = None self.__KludgeCounter = 0
def sliderHandler(self, event): if GuiMgr.get().Playback_Playing: return percent = float(self.slider.get()) / 100.0 number = int(Playback.get().GetDataCount() * percent) Playback.get().SetCurrentNumber(number) strVal = str(number) + "/" + str(Playback.get().GetDataCount()) self.lblPacketNumber.config(text=strVal)
def sliderUpdate(self, event): number = Playback.get().GetCurrentNumber() strVal = str(number) + "/" + str(Playback.get().GetDataCount()) if GuiMgr.get().GetRepeatMode()[0] != Playback.RepeatMode.NONE: strVal = strVal + " Loop: " + str(Playback.get().GetLoopCount()) self.lblPacketNumber.config(text=strVal)
def UpdateGui(self): for widget in self.updateList: widget.updateGui() currCount = len(GuiMgr.get().GetDatalist()) if currCount != self._LastDataPointCount: self.dataText.set("Data {" + str(currCount) + "}") self._LastDataPointCount = currCount self.root.after(100, self.UpdateGui)
def updatePlaybackSpeed(self): if GuiMgr.get().GetPlaybackSpeed() == float(self.lstBoxPlaybackSpeed.get()): return currSpeed = GuiMgr.get().GetPlaybackSpeed() insertIndex = 0 index = 0 for strVal in self.lstBoxPlaybackSpeed['values']: fVal = float(strVal) if fVal < currSpeed: insertIndex = index if fVal == currSpeed: self.lstBoxPlaybackSpeed.set(strVal) return index +=1 #so it wasn't there, must have been set via cmdline OR via Oscar Task itemList = list(self.lstBoxPlaybackSpeed['values']) itemList.insert(insertIndex, str(currSpeed)) self.lstBoxPlaybackSpeed['values'] = tuple(itemList)
def updateGui(self): playbackMgr = Playback.get() guiMgr = GuiMgr.get() if False == guiMgr.Playback_Active and False == self.Visible: return self.updatePlaybackSpeed() self.updateLoopValue() self.updatePlaybackTime() if guiMgr.Playback_Active and False == self.Visible: self.root.grid() self.Visible = True self.slider.set(0) self.lstBoxRepeatMode.current(0) self.lstBoxPlaybackSpeed.current(4) if guiMgr.Live_Receiving and self.Visible: self.Visible = False guiMgr.ShowPlayback(False) self.root.grid_remove() if guiMgr.GetRepeatMode( )[0] == Playback.RepeatMode.LOOP and False == self.LoopValuesVisible: self.LoopValuesVisible = True self.lblEndLoop.grid() self.lblStartLoop.grid() if guiMgr.GetRepeatMode( )[0] != Playback.RepeatMode.LOOP and True == self.LoopValuesVisible: self.LoopValuesVisible = False self.lblEndLoop.grid_remove() self.lblStartLoop.grid_remove() if guiMgr.Playback_Playing and not (enabled(self.btnPausePlayback) or enabled(self.btnStopPlayback)): enable(self.btnPausePlayback) enable(self.btnStopPlayback) disable(self.btnStartPlayback) if not guiMgr.Playback_Playing and (enabled(self.btnPausePlayback) or enabled(self.btnStopPlayback)): disable(self.btnPausePlayback) disable(self.btnStopPlayback) enable(self.btnStartPlayback) if guiMgr.Playback_Playing and enabled(self.slider): disable(self.slider) if not guiMgr.Playback_Playing and not enabled(self.slider): enable(self.slider) currNum = playbackMgr.GetCurrentNumber() total = playbackMgr.GetDataCount() if guiMgr.Playback_Playing: enable(self.slider) self.slider.set(int(currNum * 100 / total)) disable(self.slider) elif currNum == total and self.slider.get() != 100: self.slider.set(100) if guiMgr.GetRepeatMode()[0] != Playback.RepeatMode.LOOP and enabled( self.btnStartLoop): disable(self.btnStartLoop) self.btnStartLoop.grid_remove() self.btnStopLoop.grid_remove() if guiMgr.Playback_Playing and enabled(self.btnStartLoop): disable(self.btnStartLoop) self.btnStartLoop.grid_remove() self.btnStopLoop.grid_remove() if not guiMgr.Playback_Playing and guiMgr.GetRepeatMode( )[0] == Playback.RepeatMode.LOOP and not enabled(self.btnStartLoop): enable(self.btnStartLoop) self.btnStartLoop.grid() self.btnStopLoop.grid() if True == self.LoopValuesVisible: mode = guiMgr.GetRepeatMode() self.lblStartLoop.config(text=str(mode[1])) self.lblEndLoop.config(text=str(mode[2]))
def updateLoopValue(self): mode = GuiMgr.get().GetRepeatMode()[0] if Playback.RepeatMode.toString(mode) == self.lstBoxRepeatMode.get(): return self.lstBoxRepeatMode.set(Playback.RepeatMode.toString(mode))
def onSetPlaybackSpeed(self, event): GuiMgr.get().OnSetPlaybackSpeed(float(self.lstBoxPlaybackSpeed.get()))
def updateGui(self): if True == GuiMgr.get().Playback_Playing and (enabled( self.btnStopLive) or enabled(self.btnStartRecording)): disable(self.btnStopLive) disable(self.btnStartRecording) if False == GuiMgr.get().Live_Active and True == self.Visible: self.root.grid_remove() self.Visible = False return if True == GuiMgr.get().Live_Active and False == self.Visible: self.root.grid() self.Visible = True if False == self.Visible: return if True == GuiMgr.get().Playback_Playing and enabled( self.btnStartLive): disable(self.btnStartLive) if True == GuiMgr.get().Playback_Playing: return if True == GuiMgr.get().Live_Receiving and enabled(self.btnStartLive): self.btnStartLive.config(state=DISABLED) self.btnStopLive.config(state=NORMAL) self.RecordingInfoFrame.grid_remove() if False == GuiMgr.get().Live_Receiving and enabled(self.btnStopLive): enable(self.btnStartLive) disable(self.btnStopLive) if True == GuiMgr.get().Live_Recording and enabled( self.btnStartRecording): disable(self.btnStartRecording) enable(self.btnStopRecording) disable(self.btnStopLive) self.RecordingInfoFrame.grid() if enabled(self.btnStartRecording) and not enabled(self.btnStopLive): enable(self.btnStopLive) if enabled(self.btnStartLive) and enabled(self.btnStartRecording): self.btnStartRecording.config(state=DISABLED) if not enabled(self.btnStartLive) and not enabled( self.btnStartRecording) and not enabled(self.btnStopRecording): enable(self.btnStartRecording) if False == GuiMgr.get().Live_Recording and enabled( self.btnStopRecording): enable(self.btnStartRecording) disable(self.btnStopRecording) if True == GuiMgr.get().Live_Recording: self.RecordingTree.set("foo", "COUNT", str(Recorder.get().GetRecordedCount())) bytes = Recorder.get().GetBytesRecorded() if bytes < 1024: strVal = str(bytes) + " B" elif bytes < 1024 * 1024: strVal = "{0:.2f}".format(float(bytes / 1024)) + " KB" else: strVal = "{0:.2f}".format(float((bytes / 1024) / 1024)) + " MB" self.RecordingTree.set("foo", "MEM", str(strVal)) self.RecordingTree.set("foo", "SECS", str(Recorder.get().GetRecordingTime()))
def onClearBtn(self): GuiMgr.get().ClearDataView()