本文整理汇总了Python中AnyQt.QtWidgets.QSplitter.restoreState方法的典型用法代码示例。如果您正苦于以下问题:Python QSplitter.restoreState方法的具体用法?Python QSplitter.restoreState怎么用?Python QSplitter.restoreState使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AnyQt.QtWidgets.QSplitter
的用法示例。
在下文中一共展示了QSplitter.restoreState方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: OWPythonScript
# 需要导入模块: from AnyQt.QtWidgets import QSplitter [as 别名]
# 或者: from AnyQt.QtWidgets.QSplitter import restoreState [as 别名]
#.........这里部分代码省略.........
self.defaultFont = defaultFont = \
"Monaco" if sys.platform == "darwin" else "Courier"
self.textBox = gui.vBox(self, 'Python Script')
self.splitCanvas.addWidget(self.textBox)
self.text = PythonScriptEditor(self)
self.textBox.layout().addWidget(self.text)
self.textBox.setAlignment(Qt.AlignVCenter)
self.text.setTabStopWidth(4)
self.text.modificationChanged[bool].connect(self.onModificationChanged)
self.saveAction = action = QAction("&Save", self.text)
action.setToolTip("Save script to file")
action.setShortcut(QKeySequence(QKeySequence.Save))
action.setShortcutContext(Qt.WidgetWithChildrenShortcut)
action.triggered.connect(self.saveScript)
self.consoleBox = gui.vBox(self, 'Console')
self.splitCanvas.addWidget(self.consoleBox)
self.console = PythonConsole({}, self)
self.consoleBox.layout().addWidget(self.console)
self.console.document().setDefaultFont(QFont(defaultFont))
self.consoleBox.setAlignment(Qt.AlignBottom)
self.console.setTabStopWidth(4)
select_row(self.libraryView, self.currentScriptIndex)
self.restoreScriptText()
self.splitCanvas.setSizes([2, 1])
if self.splitterState is not None:
self.splitCanvas.restoreState(QByteArray(self.splitterState))
self.splitCanvas.splitterMoved[int, int].connect(self.onSpliterMoved)
self.controlArea.layout().addStretch(1)
self.resize(800, 600)
def storeSpecificSettings(self):
self.saveScriptText()
def restoreScriptText(self):
if self.scriptText is not None:
current = self.text.toPlainText()
# do not mark scripts as modified
if self.scriptText != current:
self.text.document().setPlainText(self.scriptText)
def saveScriptText(self):
self.scriptText = self.text.toPlainText()
def handle_input(self, obj, id, signal):
id = id[0]
dic = getattr(self, signal)
if obj is None:
if id in dic.keys():
del dic[id]
else:
dic[id] = obj
@Inputs.data
def set_data(self, data, id):
self.handle_input(data, id, "data")
@Inputs.learner
示例2: OWPythonScript
# 需要导入模块: from AnyQt.QtWidgets import QSplitter [as 别名]
# 或者: from AnyQt.QtWidgets.QSplitter import restoreState [as 别名]
#.........这里部分代码省略.........
self.mainArea.layout().addWidget(self.splitCanvas)
self.defaultFont = defaultFont = \
"Monaco" if sys.platform == "darwin" else "Courier"
self.textBox = gui.vBox(self, 'Python Script')
self.splitCanvas.addWidget(self.textBox)
self.text = PythonScriptEditor(self)
self.textBox.layout().addWidget(self.text)
self.textBox.setAlignment(Qt.AlignVCenter)
self.text.setTabStopWidth(4)
self.text.modificationChanged[bool].connect(self.onModificationChanged)
self.saveAction = action = QAction("&Save", self.text)
action.setToolTip("Save script to file")
action.setShortcut(QKeySequence(QKeySequence.Save))
action.setShortcutContext(Qt.WidgetWithChildrenShortcut)
action.triggered.connect(self.saveScript)
self.consoleBox = gui.vBox(self, 'Console')
self.splitCanvas.addWidget(self.consoleBox)
self.console = PythonConsole({}, self)
self.consoleBox.layout().addWidget(self.console)
self.console.document().setDefaultFont(QFont(defaultFont))
self.consoleBox.setAlignment(Qt.AlignBottom)
self.console.setTabStopWidth(4)
select_row(self.libraryView, self.currentScriptIndex)
self.splitCanvas.setSizes([2, 1])
if self.splitterState is not None:
self.splitCanvas.restoreState(QByteArray(self.splitterState))
self.splitCanvas.splitterMoved[int, int].connect(self.onSpliterMoved)
self.controlArea.layout().addStretch(1)
self.resize(800, 600)
def setExampleTable(self, et):
self.in_data = et
def setDistanceMatrix(self, dm):
self.in_distance = dm
def setLearner(self, learner):
self.in_learner = learner
def setClassifier(self, classifier):
self.in_classifier = classifier
def setObject(self, obj):
self.in_object = obj
def handleNewSignals(self):
self.unconditional_commit()
def selectedScriptIndex(self):
rows = self.libraryView.selectionModel().selectedRows()
if rows:
return [i.row() for i in rows][0]
else:
return None
def setSelectedScript(self, index):
select_row(self.libraryView, index)
示例3: OWDataSets
# 需要导入模块: from AnyQt.QtWidgets import QSplitter [as 别名]
# 或者: from AnyQt.QtWidgets.QSplitter import restoreState [as 别名]
class OWDataSets(widget.OWWidget):
name = "Data Sets"
description = "Load a data set from an online repository"
icon = "icons/DataSets.svg"
priority = 20
replaces = ["orangecontrib.prototypes.widgets.owdatasets.OWDataSets"]
# The following constants can be overridden in a subclass
# to reuse this widget for a different repository
# Take care when refactoring! (used in e.g. single-cell)
INDEX_URL = "http://datasets.orange.biolab.si/"
DATASET_DIR = "datasets"
class Error(widget.OWWidget.Error):
no_remote_datasets = Msg("Could not fetch data set list")
class Warning(widget.OWWidget.Warning):
only_local_datasets = Msg("Could not fetch data sets list, only local "
"cached data sets are shown")
class Outputs:
data = Output("Data", Orange.data.Table)
#: Selected data set id
selected_id = settings.Setting(None) # type: Optional[str]
auto_commit = settings.Setting(False) # type: bool
#: main area splitter state
splitter_state = settings.Setting(b'') # type: bytes
header_state = settings.Setting(b'') # type: bytes
def __init__(self):
super().__init__()
self.local_cache_path = os.path.join(data_dir(), self.DATASET_DIR)
self.__awaiting_state = None # type: Optional[_FetchState]
box = gui.widgetBox(self.controlArea, "Info")
self.infolabel = QLabel(text="Initializing...\n\n")
box.layout().addWidget(self.infolabel)
gui.widgetLabel(self.mainArea, "Filter")
self.filterLineEdit = QLineEdit(
textChanged=self.filter
)
self.mainArea.layout().addWidget(self.filterLineEdit)
self.splitter = QSplitter(orientation=Qt.Vertical)
self.view = QTreeView(
sortingEnabled=True,
selectionMode=QTreeView.SingleSelection,
alternatingRowColors=True,
rootIsDecorated=False,
editTriggers=QTreeView.NoEditTriggers,
)
box = gui.widgetBox(self.splitter, "Description", addToLayout=False)
self.descriptionlabel = QLabel(
wordWrap=True,
textFormat=Qt.RichText,
)
self.descriptionlabel = QTextBrowser(
openExternalLinks=True,
textInteractionFlags=(Qt.TextSelectableByMouse |
Qt.LinksAccessibleByMouse)
)
self.descriptionlabel.setFrameStyle(QTextBrowser.NoFrame)
# no (white) text background
self.descriptionlabel.viewport().setAutoFillBackground(False)
box.layout().addWidget(self.descriptionlabel)
self.splitter.addWidget(self.view)
self.splitter.addWidget(box)
self.splitter.setSizes([300, 200])
self.splitter.splitterMoved.connect(
lambda:
setattr(self, "splitter_state", bytes(self.splitter.saveState()))
)
self.mainArea.layout().addWidget(self.splitter)
self.controlArea.layout().addStretch(10)
gui.auto_commit(self.controlArea, self, "auto_commit", "Send Data")
model = QStandardItemModel(self)
model.setHorizontalHeaderLabels(HEADER)
proxy = QSortFilterProxyModel()
proxy.setSourceModel(model)
proxy.setFilterKeyColumn(-1)
proxy.setFilterCaseSensitivity(False)
self.view.setModel(proxy)
if self.splitter_state:
self.splitter.restoreState(self.splitter_state)
self.view.setItemDelegateForColumn(
Header.Size, SizeDelegate(self))
self.view.setItemDelegateForColumn(
#.........这里部分代码省略.........
示例4: OWDataSets
# 需要导入模块: from AnyQt.QtWidgets import QSplitter [as 别名]
# 或者: from AnyQt.QtWidgets.QSplitter import restoreState [as 别名]
#.........这里部分代码省略.........
box = gui.widgetBox(self.splitter, "Description", addToLayout=False)
self.descriptionlabel = QLabel(
wordWrap=True,
textFormat=Qt.RichText,
)
self.descriptionlabel = QTextBrowser(
openExternalLinks=True,
textInteractionFlags=(Qt.TextSelectableByMouse |
Qt.LinksAccessibleByMouse)
)
self.descriptionlabel.setFrameStyle(QTextBrowser.NoFrame)
# no (white) text background
self.descriptionlabel.viewport().setAutoFillBackground(False)
box.layout().addWidget(self.descriptionlabel)
self.splitter.addWidget(self.view)
self.splitter.addWidget(box)
self.splitter.setSizes([300, 200])
self.splitter.splitterMoved.connect(
lambda:
setattr(self, "splitter_state", bytes(self.splitter.saveState()))
)
self.mainArea.layout().addWidget(self.splitter)
self.controlArea.layout().addStretch(10)
gui.auto_commit(self.controlArea, self, "auto_commit", "Send Data")
proxy = QSortFilterProxyModel()
proxy.setFilterKeyColumn(-1)
proxy.setFilterCaseSensitivity(False)
self.view.setModel(proxy)
if self.splitter_state:
self.splitter.restoreState(self.splitter_state)
self.assign_delegates()
self.setBlocking(True)
self.setStatusMessage("Initializing")
self._executor = ThreadPoolExecutor(max_workers=1)
f = self._executor.submit(self.list_remote)
w = FutureWatcher(f, parent=self)
w.done.connect(self.__set_index)
def assign_delegates(self):
# NOTE: All columns must have size hinting delegates.
# QTreeView queries only the columns displayed in the viewport so
# the layout would be different depending in the horizontal scroll
# position
self.view.setItemDelegate(UniformHeightDelegate(self))
self.view.setItemDelegateForColumn(
self.Header.islocal,
UniformHeightIndicatorDelegate(self, role=Qt.DisplayRole)
)
self.view.setItemDelegateForColumn(
self.Header.size,
SizeDelegate(self)
)
self.view.setItemDelegateForColumn(
self.Header.instances,
NumericalDelegate(self)
)
self.view.setItemDelegateForColumn(
self.Header.variables,
NumericalDelegate(self)