本文整理汇总了Python中pyqtgraph.dockarea.DockArea.restoreState方法的典型用法代码示例。如果您正苦于以下问题:Python DockArea.restoreState方法的具体用法?Python DockArea.restoreState怎么用?Python DockArea.restoreState使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyqtgraph.dockarea.DockArea
的用法示例。
在下文中一共展示了DockArea.restoreState方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: MainWindow
# 需要导入模块: from pyqtgraph.dockarea import DockArea [as 别名]
# 或者: from pyqtgraph.dockarea.DockArea import restoreState [as 别名]
class MainWindow(QMainWindow, Ui_MainWindow):
"""The only window of the application."""
def __init__(self, settings):
super(MainWindow, self).__init__()
self.settings = settings
self.setupUi(self)
self.dock_area = DockArea()
self.setCentralWidget(self.dock_area)
self.createDocks()
self.loadSettings()
def createDocks(self):
self.zmq_subscriber = ZMQSubscriber(self.settings, self)
self.zmq_subscriber_dock = Dock('Subscriber',
widget=self.zmq_subscriber)
self.dock_area.addDock(self.zmq_subscriber_dock)
def loadSettings(self):
"""Load window state from self.settings"""
self.settings.beginGroup('mainwindow')
geometry = self.settings.value('geometry').toByteArray()
state = self.settings.value('windowstate').toByteArray()
dock_string = str(self.settings.value('dockstate').toString())
if dock_string is not "":
dock_state = eval(dock_string)
self.dock_area.restoreState(dock_state)
self.settings.endGroup()
self.restoreGeometry(geometry)
self.restoreState(state)
def saveSettings(self):
"""Save window state to self.settings."""
self.settings.beginGroup('mainwindow')
self.settings.setValue('geometry', self.saveGeometry())
self.settings.setValue('windowstate', self.saveState())
dock_state = self.dock_area.saveState()
# dock_state returned here is a python dictionary. Coundn't find a good
# way to save dicts in QSettings, hence just using representation
# of it.
self.settings.setValue('dockstate', repr(dock_state))
self.settings.endGroup()
def closeEvent(self, event):
self.zmq_subscriber.saveSettings()
self.saveSettings()
示例2: DockAreaTabWidgetBase
# 需要导入模块: from pyqtgraph.dockarea import DockArea [as 别名]
# 或者: from pyqtgraph.dockarea.DockArea import restoreState [as 别名]
class DockAreaTabWidgetBase(QtGui.QWidget):
def __init__(self, *args, **kwargs):
self.main = kwargs.pop("main")
tabName = kwargs.pop("tabName")
QtGui.QWidget.__init__(self, *args, **kwargs)
self.setObjectName(tabName)
self._layout = QtGui.QGridLayout(self)
def _InitDocks(self):
# Define docking area
if hasattr(self, "_dockArea"):
self._dockArea.setParent(None)
self._dockArea = DockArea()
self._plotDocks = self._defaultDockPos.keys()
# Add dock to area
for dock, pos in self._defaultDockPos.iteritems():
self._dockArea.addDock(dock, *pos)
self._layout.addWidget(self._dockArea, 0, 0, 1, 1)
def Shown(self):
self.DrawFrame()
def DrawFrame(self, clear = True):
if clear:
self.ClearPlots()
for dock in self._plotDocks:
if not dock.automaticDraw:
continue
dock.DrawPlot()
def ClearPlots(self):
for dock in self._plotDocks:
if not dock.automaticDraw:
continue
dock.ClearPlot()
def AutoscalePlots(self):
for dock in self._plotDocks:
if not dock.automaticDraw:
continue
dock.Autoscale()
def SaveState(self):
res = {}
res["dockingState"] = self._dockArea.saveState()
for dock in self._plotDocks:
res["dock_" + dock.name()] = dock.SaveState()
return res
def SetState(self, state):
try:
if "dockingState" in state:
self._dockArea.restoreState(state["dockingState"])
except:
print "Docking area restore failed, restoring defaults:"
traceback.print_exc()
print "Restore defaults"
self._InitDocks()
for dock in self._plotDocks:
stateName = "dock_" + dock.name()
if stateName in state:
dock.SetState(state[stateName])
示例3: AWGOptimizer
# 需要导入模块: from pyqtgraph.dockarea import DockArea [as 别名]
# 或者: from pyqtgraph.dockarea.DockArea import restoreState [as 别名]
class AWGOptimizer(Form, Base):
def __init__(self, deviceClass, config, parent=None):
Base.__init__(self, parent)
Form.__init__(self)
Form.setupUi(self, self)
self.config = config
self.configname = "AWGOptimizer"
self.setWindowTitle("AWG Optimizer")
guiState = self.config.get(self.configname+".guiState")
state = self.config.get(self.configname+'.state')
pos = self.config.get(self.configname+'.pos')
size = self.config.get(self.configname+'.size')
isMaximized = self.config.get(self.configname+'.isMaximized')
restoreGuiState(self, self.config.get(self.configname+".guiState"))
if state: self.restoreState(state)
if pos: self.move(pos)
if size: self.resize(size)
if isMaximized: self.showMaximized()
self.show()
self.awgUi = AWGUi(deviceClass, config, dict())
self.awgUi.setupUi(self.awgUi)
self.splitter.insertWidget(1, self.awgUi)
#oscilloscope plot window
name = "Oscilloscope Trace"
self.scopeDock = Dock(name)
self.scopePlot = CoordinatePlotWidget(self, name=name)
self.scopeView = self.scopePlot._graphicsView
self.scopeDock.addWidget(self.scopePlot)
self.area = DockArea()
self.area.addDock(self.scopeDock)
self.plotDict ={name: {"dock":self.scopeDock, "widget":self.scopePlot, "view":self.scopeView}}
self.verticalLayout.insertWidget(0, self.area)
#trace ui
self.penicons = pens.penicons().penicons()
self.traceui = Traceui.Traceui(self.penicons, self.config, self.configname, self.plotDict, hasMeasurementLog=False, highlightUnsaved=False)
self.traceui.setupUi(self.traceui)
traceDock = Dock("Traces")
traceDock.addWidget(self.traceui)
self.area.addDock(traceDock, 'left')
self.device = self.awgUi.device
self.measureWaveformButton.clicked.connect(self.onMeasureWaveform)
self.optimizeButton.clicked.connect(self.onOptimize)
dockAreaState = self.config.get(self.configname+'.dockAreaState')
try:
if dockAreaState: self.area.restoreState(dockAreaState)
except Exception as e:
print(e)
def saveConfig(self):
self.config[self.configname+".guiState"] = saveGuiState(self)
self.config[self.configname+'.state'] = self.saveState()
self.config[self.configname+'.pos'] = self.pos()
self.config[self.configname+'.size'] = self.size()
self.config[self.configname+'.isMaximized'] = self.isMaximized()
self.config[self.configname+'.dockAreaState'] = self.area.saveState()
self.awgUi.saveConfig()
def closeEvent(self, e):
self.saveConfig()
def onMeasureWaveform(self):
pass
def onOptimize(self):
pass
示例4: MainWindow
# 需要导入模块: from pyqtgraph.dockarea import DockArea [as 别名]
# 或者: from pyqtgraph.dockarea.DockArea import restoreState [as 别名]
#.........这里部分代码省略.........
self.dock_roi_plot_v = Dock('ROIV Plot', widget=self.roi_plot_v)
self.dock_analyzer = Dock('Analyze', widget=self.analyzer)
self.dock_area.addDock(self.dock_image_view, position='top')
self.dock_area.addDock(self.dock_image_browser, position='right',
relativeTo=self.dock_image_view)
self.dock_area.addDock(self.dock_fitter, position='left',
relativeTo=self.dock_image_view)
self.dock_area.addDock(self.dock_roi_h, position='bottom',
relativeTo=self.dock_fitter)
self.dock_area.addDock(self.dock_roi_v, position='below',
relativeTo=self.dock_roi_h)
self.dock_area.addDock(self.dock_roi_int, position='below',
relativeTo=self.dock_roi_v)
self.dock_area.addDock(self.dock_roi_err, position='below',
relativeTo=self.dock_roi_int)
self.dock_area.addDock(self.dock_roi_plot_h, position='below',
relativeTo=self.dock_image_view)
self.dock_area.addDock(self.dock_roi_plot_v, position='right',
relativeTo=self.dock_roi_plot_h)
self.dock_area.addDock(self.dock_analyzer, position='top',
relativeTo=self.dock_image_browser)
def initAfterCreatingDockWidgets(self):
self.setWindowTitle(self.image_browser.current_directory)
def connectSignalsToSlots(self):
self.actionOpen_Directory.triggered.connect(self.image_browser.handleOpenDirectoryAction)
self.actionDark_File.triggered.connect(self.image_browser.handleDarkFileAction)
self.actionRefresh.triggered.connect(self.image_browser.handleRefreshAction)
self.actionSave.triggered.connect(self.image_browser.handleSaveAnalysis)
self.image_browser.windowTitleChanged.connect(self.setWindowTitle)
# self.image_browser.imageChanged.connect(self.image_view.handleImageChanged)
self.image_browser.imageChanged.connect(self.fitter.handleImageChanged)
self.image_browser.imageChanged.connect(self.analyzer.handleImageChanged)
self.roi_editor_int.roiChanged.connect(self.image_browser.handleRoiChanged)
self.roi_editor_err.roiChanged.connect(self.image_browser.handleROIErrChanged)
self.roi_editor_h.roiChanged.connect(self.image_browser.handleROIHChanged)
self.roi_editor_v.roiChanged.connect(self.image_browser.handleROIVChanged)
self.roi_editor_h.roiChanged.connect(self.fitter.handleROIHChanged)
self.roi_editor_h.roiChanged.connect(self.analyzer.handleROIHChanged)
self.roi_editor_v.roiChanged.connect(self.fitter.handleROIVChanged)
self.roi_editor_v.roiChanged.connect(self.analyzer.handleROIVChanged)
self.roi_editor_int.roiChanged.connect(self.fitter.handleROIIntChanged)
self.roi_editor_int.roiChanged.connect(self.analyzer.handleROIIntChanged)
self.roi_editor_err.roiChanged.connect(self.fitter.handleROIErrChanged)
self.roi_editor_err.roiChanged.connect(self.analyzer.handleROIErrChanged)
self.image_view.doubleClicked.connect(self.roi_editor_h.centerROI)
self.image_view.doubleClicked.connect(self.roi_editor_v.centerROI)
self.fitter.imageChanged.connect(self.image_view.handleImageChanged)
self.fitter.horDataChanged.connect(self.roi_plot_h.handleDataChanged)
self.fitter.verDataChanged.connect(self.roi_plot_v.handleDataChanged)
self.fitter.doneFitting.connect(self.analyzer.handleDoneFitting)
def loadSettings(self):
"""Load window state from self.settings"""
self.settings.beginGroup('mainwindow')
geometry = self.settings.value('geometry').toByteArray()
state = self.settings.value('windowstate').toByteArray()
dock_string = str(self.settings.value('dockstate').toString())
if dock_string is not "":
dock_state = eval(dock_string)
self.dock_area.restoreState(dock_state)
self.settings.endGroup()
self.restoreGeometry(geometry)
self.restoreState(state)
def saveSettings(self):
"""Save window state to self.settings."""
self.settings.beginGroup('mainwindow')
self.settings.setValue('geometry', self.saveGeometry())
self.settings.setValue('windowstate', self.saveState())
dock_state = self.dock_area.saveState()
# dock_state returned here is a python dictionary. Coundn't find a good
# way to save dicts in QSettings, hence just using representation
# of it.
self.settings.setValue('dockstate', repr(dock_state))
self.settings.endGroup()
def closeEvent(self, event):
self.saveSettings()
self.image_browser.saveSettings()
self.roi_editor_int.saveSettings()
self.roi_editor_err.saveSettings()
self.roi_editor_v.saveSettings()
self.roi_editor_h.saveSettings()
self.analyzer.saveSettings()
super(MainWindow, self).closeEvent(event)
def setWindowTitle(self, newTitle=''):
"""Prepend IP-BEC to all window titles."""
title = 'IP-BEC: ' + newTitle
super(MainWindow, self).setWindowTitle(title)
示例5: AWGUi
# 需要导入模块: from pyqtgraph.dockarea import DockArea [as 别名]
# 或者: from pyqtgraph.dockarea.DockArea import restoreState [as 别名]
#.........这里部分代码省略.........
self.filenameComboBox.setCurrentIndex(self.filenameComboBox.findText(os.path.basename(self.settings.filename)))
self.filenameComboBox.currentIndexChanged[str].connect(self.onFilename)
self.removeFileButton.clicked.connect(self.onRemoveFile)
self.newFileButton.clicked.connect(self.onNewFile)
self.openFileButton.clicked.connect(self.onOpenFile)
self.saveFileButton.clicked.connect(self.onSaveFile)
self.reloadFileButton.clicked.connect(self.onReloadFile)
#cache
self.cacheDepthSpinBox.setValue(self.settings.cacheDepth)
self.cacheDepthSpinBox.valueChanged.connect(self.onCacheDepth)
self.clearCacheButton.clicked.connect(self.onClearCache)
#status bar
self.label = QtGui.QLabel('Sample Rate: {0}'.format(self.settings.deviceProperties['sampleRate']))
self.statusbar.addWidget(self.label)
#Restore GUI state
state = self.config.get(self.configname+'.state')
pos = self.config.get(self.configname+'.pos')
size = self.config.get(self.configname+'.size')
isMaximized = self.config.get(self.configname+'.isMaximized')
dockAreaState = self.config.get(self.configname+'.dockAreaState')
guiState = self.config.get(self.configname+".guiState")
restoreGuiState(self, guiState)
try:
if pos:
self.move(pos)
if size:
self.resize(size)
if isMaximized:
self.showMaximized()
if state:
self.restoreState(state)
for awgChannelUi in self.awgChannelUiList:
channelGuiState = self.config[self.configname+"channel{0}.guiState".format(awgChannelUi.channel)]
restoreGuiState(awgChannelUi, channelGuiState)
except Exception as e:
logger.warning("Error on restoring state in AWGUi {0}. Exception occurred: {1}".format(self.device.displayName, e))
try:
if dockAreaState:
self.area.restoreState(dockAreaState)
except Exception as e:
logger.warning("Cannot restore dock state in AWGUi {0}. Exception occurred: {1}".format(self.device.displayName, e))
self.area.deleteLater()
self.area = DockArea()
self.splitter.insertWidget(0, self.area)
for channelUi in self.awgChannelUiList:
dock = Dock("AWG Channel {0}".format(channel))
dock.addWidget(channelUi)
self.area.addDock(dock, 'right')
self.saveIfNecessary()
def onCacheDepth(self, newVal):
self.settings.cacheDepth = newVal
self.saveIfNecessary()
def onClearCache(self):
self.waveformCache.clear()
def onComboBoxEditingFinished(self):
"""a settings name is typed into the combo box"""
currentText = str(self.settingsComboBox.currentText())
if self.settingsName != currentText:
self.settingsName = currentText
if self.settingsName not in self.settingsDict: