本文整理汇总了Python中AnyQt.QtWidgets.QStackedWidget.widget方法的典型用法代码示例。如果您正苦于以下问题:Python QStackedWidget.widget方法的具体用法?Python QStackedWidget.widget怎么用?Python QStackedWidget.widget使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AnyQt.QtWidgets.QStackedWidget
的用法示例。
在下文中一共展示了QStackedWidget.widget方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: OWEditDomain
# 需要导入模块: from AnyQt.QtWidgets import QStackedWidget [as 别名]
# 或者: from AnyQt.QtWidgets.QStackedWidget import widget [as 别名]
class OWEditDomain(widget.OWWidget):
name = "Edit Domain"
description = "Rename features and their values."
icon = "icons/EditDomain.svg"
priority = 3125
inputs = [("Data", Orange.data.Table, "set_data")]
outputs = [("Data", Orange.data.Table)]
settingsHandler = settings.DomainContextHandler()
domain_change_hints = settings.ContextSetting({})
selected_index = settings.ContextSetting({})
autocommit = settings.Setting(False)
def __init__(self):
super().__init__()
self.data = None
self.input_vars = ()
self._invalidated = False
box = gui.vBox(self.controlArea, "Domain Features")
self.domain_model = itemmodels.VariableListModel()
self.domain_view = QListView(
selectionMode=QListView.SingleSelection
)
self.domain_view.setModel(self.domain_model)
self.domain_view.selectionModel().selectionChanged.connect(
self._on_selection_changed)
box.layout().addWidget(self.domain_view)
box = gui.hBox(self.controlArea)
gui.button(box, self, "Reset Selected", callback=self.reset_selected)
gui.button(box, self, "Reset All", callback=self.reset_all)
gui.auto_commit(self.controlArea, self, "autocommit", "Apply")
box = gui.vBox(self.mainArea, "Edit")
self.editor_stack = QStackedWidget()
self.editor_stack.addWidget(DiscreteVariableEditor())
self.editor_stack.addWidget(ContinuousVariableEditor())
self.editor_stack.addWidget(VariableEditor())
box.layout().addWidget(self.editor_stack)
@check_sql_input
def set_data(self, data):
"""Set input data set."""
self.closeContext()
self.clear()
self.data = data
if self.data is not None:
self._initialize()
self.openContext(self.data)
self._restore()
self.unconditional_commit()
def clear(self):
"""Clear the widget state."""
self.data = None
self.domain_model[:] = []
self.input_vars = []
self.domain_change_hints = {}
self.selected_index = -1
def reset_selected(self):
"""Reset the currently selected variable to its original state."""
ind = self.selected_var_index()
if ind >= 0:
var = self.input_vars[ind]
desc = variable_description(var, skip_attributes=True)
if desc in self.domain_change_hints:
del self.domain_change_hints[desc]
self.domain_model[ind] = var
self.editor_stack.currentWidget().set_data(var)
self._invalidate()
def reset_all(self):
"""Reset all variables to their original state."""
self.domain_change_hints = {}
if self.data is not None:
# To invalidate stored hints
self.domain_model[:] = self.input_vars
itemmodels.select_row(self.domain_view, self.selected_index)
self._invalidate()
def selected_var_index(self):
"""Return the selected row in 'Domain Features' view."""
rows = self.domain_view.selectedIndexes()
assert len(rows) <= 1
return rows[0].row() if rows else -1
def _initialize(self):
#.........这里部分代码省略.........
示例2: OWEditDomain
# 需要导入模块: from AnyQt.QtWidgets import QStackedWidget [as 别名]
# 或者: from AnyQt.QtWidgets.QStackedWidget import widget [as 别名]
class OWEditDomain(widget.OWWidget):
name = "Edit Domain"
description = "Rename variables, edit categories and variable annotations."
icon = "icons/EditDomain.svg"
priority = 3125
keywords = []
class Inputs:
data = Input("Data", Orange.data.Table)
class Outputs:
data = Output("Data", Orange.data.Table)
class Error(widget.OWWidget.Error):
duplicate_var_name = widget.Msg("A variable name is duplicated.")
settingsHandler = settings.DomainContextHandler()
settings_version = 2
_domain_change_store = settings.ContextSetting({})
_selected_item = settings.ContextSetting(None) # type: Optional[str]
want_control_area = False
def __init__(self):
super().__init__()
self.data = None # type: Optional[Orange.data.Table]
#: The current selected variable index
self.selected_index = -1
self._invalidated = False
mainlayout = self.mainArea.layout()
assert isinstance(mainlayout, QVBoxLayout)
layout = QHBoxLayout()
mainlayout.addLayout(layout)
box = QGroupBox("Variables")
box.setLayout(QVBoxLayout())
layout.addWidget(box)
self.variables_model = VariableListModel(parent=self)
self.variables_view = self.domain_view = QListView(
selectionMode=QListView.SingleSelection,
uniformItemSizes=True,
)
self.variables_view.setItemDelegate(VariableEditDelegate(self))
self.variables_view.setModel(self.variables_model)
self.variables_view.selectionModel().selectionChanged.connect(
self._on_selection_changed
)
box.layout().addWidget(self.variables_view)
box = QGroupBox("Edit", )
box.setLayout(QVBoxLayout(margin=4))
layout.addWidget(box)
self.editor_stack = QStackedWidget()
self.editor_stack.addWidget(DiscreteVariableEditor())
self.editor_stack.addWidget(ContinuousVariableEditor())
self.editor_stack.addWidget(TimeVariableEditor())
self.editor_stack.addWidget(VariableEditor())
box.layout().addWidget(self.editor_stack)
bbox = QDialogButtonBox()
bbox.setStyleSheet(
"button-layout: {:d};".format(QDialogButtonBox.MacLayout))
bapply = QPushButton(
"Apply",
objectName="button-apply",
toolTip="Apply changes and commit data on output.",
default=True,
autoDefault=False
)
bapply.clicked.connect(self.commit)
breset = QPushButton(
"Reset Selected",
objectName="button-reset",
toolTip="Rest selected variable to its input state.",
autoDefault=False
)
breset.clicked.connect(self.reset_selected)
breset_all = QPushButton(
"Reset All",
objectName="button-reset-all",
toolTip="Reset all variables to their input state.",
autoDefault=False
)
breset_all.clicked.connect(self.reset_all)
bbox.addButton(bapply, QDialogButtonBox.AcceptRole)
bbox.addButton(breset, QDialogButtonBox.ResetRole)
bbox.addButton(breset_all, QDialogButtonBox.ResetRole)
mainlayout.addWidget(bbox)
self.variables_view.setFocus(Qt.NoFocusReason) # initial focus
@Inputs.data
def set_data(self, data):
"""Set input dataset."""
#.........这里部分代码省略.........