本文整理汇总了Python中AnyQt.QtWidgets.QStackedWidget.setEnabled方法的典型用法代码示例。如果您正苦于以下问题:Python QStackedWidget.setEnabled方法的具体用法?Python QStackedWidget.setEnabled怎么用?Python QStackedWidget.setEnabled使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AnyQt.QtWidgets.QStackedWidget
的用法示例。
在下文中一共展示了QStackedWidget.setEnabled方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: OWFeatureConstructor
# 需要导入模块: from AnyQt.QtWidgets import QStackedWidget [as 别名]
# 或者: from AnyQt.QtWidgets.QStackedWidget import setEnabled [as 别名]
class OWFeatureConstructor(OWWidget):
name = "Feature Constructor"
description = "Construct new features (data columns) from a set of " \
"existing features in the input data set."
icon = "icons/FeatureConstructor.svg"
class Inputs:
data = Input("Data", Orange.data.Table)
class Outputs:
data = Output("Data", Orange.data.Table)
want_main_area = False
settingsHandler = FeatureConstructorHandler()
descriptors = ContextSetting([])
currentIndex = ContextSetting(-1)
EDITORS = [
(ContinuousDescriptor, ContinuousFeatureEditor),
(DiscreteDescriptor, DiscreteFeatureEditor),
(StringDescriptor, StringFeatureEditor)
]
class Error(OWWidget.Error):
more_values_needed = Msg("Categorical feature {} needs more values.")
invalid_expressions = Msg("Invalid expressions: {}.")
def __init__(self):
super().__init__()
self.data = None
self.editors = {}
box = gui.vBox(self.controlArea, "Variable Definitions")
toplayout = QHBoxLayout()
toplayout.setContentsMargins(0, 0, 0, 0)
box.layout().addLayout(toplayout)
self.editorstack = QStackedWidget(
sizePolicy=QSizePolicy(QSizePolicy.MinimumExpanding,
QSizePolicy.MinimumExpanding)
)
for descclass, editorclass in self.EDITORS:
editor = editorclass()
editor.featureChanged.connect(self._on_modified)
self.editors[descclass] = editor
self.editorstack.addWidget(editor)
self.editorstack.setEnabled(False)
buttonlayout = QVBoxLayout(spacing=10)
buttonlayout.setContentsMargins(0, 0, 0, 0)
self.addbutton = QPushButton(
"New", toolTip="Create a new variable",
minimumWidth=120,
shortcut=QKeySequence.New
)
def unique_name(fmt, reserved):
candidates = (fmt.format(i) for i in count(1))
return next(c for c in candidates if c not in reserved)
def reserved_names():
varnames = []
if self.data is not None:
varnames = [var.name for var in
self.data.domain.variables + self.data.domain.metas]
varnames += [desc.name for desc in self.featuremodel]
return set(varnames)
def generate_newname(fmt):
return unique_name(fmt, reserved_names())
menu = QMenu(self.addbutton)
cont = menu.addAction("Numeric")
cont.triggered.connect(
lambda: self.addFeature(
ContinuousDescriptor(generate_newname("X{}"), "", 3))
)
disc = menu.addAction("Categorical")
disc.triggered.connect(
lambda: self.addFeature(
DiscreteDescriptor(generate_newname("D{}"), "",
("A", "B"), -1, False))
)
string = menu.addAction("Text")
string.triggered.connect(
lambda: self.addFeature(
StringDescriptor(generate_newname("S{}"), ""))
)
menu.addSeparator()
self.duplicateaction = menu.addAction("Duplicate Selected Variable")
self.duplicateaction.triggered.connect(self.duplicateFeature)
self.duplicateaction.setEnabled(False)
self.addbutton.setMenu(menu)
self.removebutton = QPushButton(
#.........这里部分代码省略.........