本文整理汇总了Python中Orange.widgets.utils.itemmodels.select_row函数的典型用法代码示例。如果您正苦于以下问题:Python select_row函数的具体用法?Python select_row怎么用?Python select_row使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了select_row函数的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: reset_to_input
def reset_to_input(self):
"""Reset the painting to input data if present."""
if self.input_data is None:
return
self.undo_stack.clear()
index = self.selected_class_label()
if self.input_colors is not None:
colors = self.input_colors
else:
colors = colorpalette.DefaultRGBColors
palette = colorpalette.ColorPaletteGenerator(
number_of_colors=len(colors), rgb_colors=colors)
self.colors = palette
self.class_model.colors = palette
self.class_model[:] = self.input_classes
newindex = min(max(index, 0), len(self.class_model) - 1)
itemmodels.select_row(self.classValuesView, newindex)
self.data = self.input_data.tolist()
self.__buffer = self.input_data.copy()
prev_attr2 = self.hasAttr2
self.hasAttr2 = self.input_has_attr2
if prev_attr2 != self.hasAttr2:
self.set_dimensions()
else: # set_dimensions already calls _replot, no need to call it again
self._replot()
示例2: set_data
def set_data(self, data):
self.closeContext()
self.clear()
self.warning()
self.data = data
self.distributions = None
self.contingencies = None
if self.data is not None:
if not self.data:
self.warning("Empty input data cannot be visualized")
return
domain = self.data.domain
self.varmodel[:] = list(domain.variables) + \
[meta for meta in domain.metas
if meta.is_continuous or meta.is_discrete]
self.groupvarview.clear()
self.groupvarmodel = \
["(None)"] + [var for var in domain.variables if var.is_discrete] + \
[meta for meta in domain.metas if meta.is_discrete]
self.groupvarview.addItem("(None)")
for var in self.groupvarmodel[1:]:
self.groupvarview.addItem(self.icons[var], var.name)
if domain.has_discrete_class:
self.groupvar_idx = \
self.groupvarmodel[1:].index(domain.class_var) + 1
self.openContext(domain)
self.variable_idx = min(max(self.variable_idx, 0),
len(self.varmodel) - 1)
self.groupvar_idx = min(max(self.groupvar_idx, 0),
len(self.groupvarmodel) - 1)
itemmodels.select_row(self.varview, self.variable_idx)
self._setup()
示例3: _class_count_changed
def _class_count_changed(self):
self.labels = list(self.class_model)
self.removeClassLabel.setEnabled(len(self.class_model) > 1)
self.addClassLabel.setEnabled(
len(self.class_model) < self.colors.number_of_colors)
if self.selected_class_label() is None:
itemmodels.select_row(self.classValuesView, 0)
示例4: reset_all
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()
示例5: set_data
def set_data(self, data):
self.closeContext()
self.clear()
self.data = data
if data is not None:
self.varmodel[:] = data.domain.variables
self.openContext(data.domain)
self.restore_state(self.variable_methods)
itemmodels.select_row(self.varview, 0)
self.unconditional_commit()
示例6: setCurrentIndex
def setCurrentIndex(self, index):
index = min(index, len(self.featuremodel) - 1)
self.currentIndex = index
if index >= 0:
itemmodels.select_row(self.featureview, index)
desc = self.featuremodel[min(index, len(self.featuremodel) - 1)]
editor = self.editors[type(desc)]
self.editorstack.setCurrentWidget(editor)
editor.setEditorData(desc, self.data.domain if self.data else None)
self.editorstack.setEnabled(index >= 0)
self.duplicateaction.setEnabled(index >= 0)
self.removebutton.setEnabled(index >= 0)
示例7: reset_to_input
def reset_to_input(self):
"""Reset the painting to input data if present."""
if self.input_data is None:
return
self.undo_stack.clear()
index = self.selected_class_label()
self.class_model[:] = self.input_classes
newindex = min(max(index, 0), len(self.class_model) - 1)
itemmodels.select_row(self.classValuesView, newindex)
self.data = self.input_data
prev_attr2 = self.hasAttr2
self.hasAttr2 = self.input_has_attr2
if prev_attr2 != self.hasAttr2:
self.set_dimensions()
else: # set_dimensions already calls _replot, no need to call it again
self._replot()
示例8: test_select_method
def test_select_method(self):
data = Table("iris")[::5]
self.send_signal(self.widget.Inputs.data, data)
method_types = [type(m) for m in OWImpute.METHODS]
widget = self.widget
model = widget.varmodel
view = widget.varview
defbg = widget.default_button_group
varbg = widget.variable_button_group
self.assertSequenceEqual(list(model), data.domain.variables)
asdefid = method_types.index(AsDefault)
leaveid = method_types.index(impute.DoNotImpute)
avgid = method_types.index(impute.Average)
defbg.button(avgid).click()
self.assertEqual(widget.default_method_index, avgid)
self.assertTrue(
all(isinstance(m, AsDefault) and isinstance(m.method, impute.Average)
for m in map(widget.get_method_for_column,
range(len(data.domain.variables)))))
# change method for first variable
select_row(view, 0)
varbg.button(avgid).click()
met = widget.get_method_for_column(0)
self.assertIsInstance(met, impute.Average)
# select a second var
selmodel = view.selectionModel()
selmodel.select(model.index(2), selmodel.Select)
# the current checked button must unset
self.assertEqual(varbg.checkedId(), -1)
varbg.button(leaveid).click()
self.assertIsInstance(widget.get_method_for_column(0),
impute.DoNotImpute)
self.assertIsInstance(widget.get_method_for_column(2),
impute.DoNotImpute)
# reset both back to default
varbg.button(asdefid).click()
self.assertIsInstance(widget.get_method_for_column(0), AsDefault)
self.assertIsInstance(widget.get_method_for_column(2), AsDefault)
示例9: _restore
def _restore(self):
# Restore the variable states from saved settings.
def transform(var):
vdesc = variable_description(var, skip_attributes=True)
if vdesc in self.domain_change_hints:
return variable_from_description(
self.domain_change_hints[vdesc],
compute_value=Orange.preprocess.transformation.Identity(var))
else:
return var
self.domain_model[:] = map(transform, self.input_vars)
# Restore the variable selection if possible
index = self.selected_index
if index >= len(self.input_vars):
index = 0 if len(self.input_vars) else -1
if index >= 0:
itemmodels.select_row(self.domain_view, index)
示例10: remove_selected_class_label
def remove_selected_class_label(self):
index = self.selected_class_label()
if index is None:
return
label = self.class_model[index]
mask = self.data[:, 2] == index
move_mask = self.data[~mask][:, 2] > index
self.undo_stack.beginMacro("Delete class label")
self.undo_stack.push(UndoCommand(DeleteIndices(mask), self))
self.undo_stack.push(UndoCommand(Move((move_mask, 2), -1), self))
self.undo_stack.push(
SimpleUndoCommand(lambda: self.class_model.__delitem__(index),
lambda: self.class_model.insert(index, label)))
self.undo_stack.endMacro()
newindex = min(max(index - 1, 0), len(self.class_model) - 1)
itemmodels.select_row(self.classValuesView, newindex)
示例11: set_data
def set_data(self, data):
self.closeContext()
self.clear()
self.data = data
if self.data is not None:
domain = self.data.domain
self.varmodel[:] = list(domain)
self.groupvarmodel[:] = \
["(None)"] + list(filter(is_discrete, domain))
if is_discrete(domain.class_var):
self.groupvar_idx = \
list(self.groupvarmodel).index(domain.class_var)
self.openContext(domain)
self.variable_idx = min(max(self.variable_idx, 0),
len(self.varmodel) - 1)
self.groupvar_idx = min(max(self.groupvar_idx, 0),
len(self.groupvarmodel) - 1)
itemmodels.select_row(self.groupvarview, self.groupvar_idx)
itemmodels.select_row(self.varview, self.variable_idx)
self._setup()
示例12: _restore
def _restore(self):
# Restore the variable states from saved settings.
def transform(var):
vdesc = variable_description(var)
if vdesc in self.domain_change_hints:
newvar = variable_from_description(
self.domain_change_hints[vdesc]
)
newvar.get_value_from = \
Orange.feature.transformation.Identity(var)
return newvar
else:
return var
self.domain_model[:] = map(transform, self.input_vars)
# Restore the variable selection if possible
index = self.selected_index
if index >= len(self.input_vars):
index = 0 if len(self.input_vars) else -1
if index >= 0:
itemmodels.select_row(self.domain_view, index)
示例13: _restore
def _restore(self, ):
"""
Restore the edit transform from saved state.
"""
model = self.variables_model
for i in range(model.rowCount()):
midx = model.index(i, 0)
var = model.data(midx, Qt.EditRole)
tr = self._restore_transform(var)
if tr:
model.setData(midx, tr, TransformRole)
# Restore the current variable selection
i = -1
if self._selected_item is not None:
for i, var in enumerate(model):
if var.name == self._selected_item:
break
if i == -1 and model.rowCount():
i = 0
if i != -1:
itemmodels.select_row(self.variables_view, i)
示例14: _init_ui
def _init_ui(self):
namesBox = gui.vBox(self.controlArea, "Names")
hbox = gui.hBox(namesBox, margin=0, spacing=0)
gui.lineEdit(hbox, self, "attr1", "Variable X: ",
controlWidth=80, orientation=Qt.Horizontal,
enterPlaceholder=True, callback=self._attr_name_changed)
gui.separator(hbox, 18)
hbox = gui.hBox(namesBox, margin=0, spacing=0)
attr2 = gui.lineEdit(hbox, self, "attr2", "Variable Y: ",
controlWidth=80, orientation=Qt.Horizontal,
enterPlaceholder=True,
callback=self._attr_name_changed)
gui.checkBox(hbox, self, "hasAttr2", '', disables=attr2,
labelWidth=0,
callback=self.set_dimensions)
gui.separator(namesBox)
gui.widgetLabel(namesBox, "Labels")
self.classValuesView = listView = QListView(
selectionMode=QListView.SingleSelection,
sizePolicy=QSizePolicy(QSizePolicy.Ignored,
QSizePolicy.Maximum)
)
listView.setModel(self.class_model)
itemmodels.select_row(listView, 0)
namesBox.layout().addWidget(listView)
self.addClassLabel = QAction(
"+", self,
toolTip="Add new class label",
triggered=self.add_new_class_label
)
self.removeClassLabel = QAction(
unicodedata.lookup("MINUS SIGN"), self,
toolTip="Remove selected class label",
triggered=self.remove_selected_class_label
)
actionsWidget = itemmodels.ModelActionsWidget(
[self.addClassLabel, self.removeClassLabel], self
)
actionsWidget.layout().addStretch(10)
actionsWidget.layout().setSpacing(1)
namesBox.layout().addWidget(actionsWidget)
tBox = gui.vBox(self.controlArea, "Tools", addSpace=True)
buttonBox = gui.hBox(tBox)
toolsBox = gui.widgetBox(buttonBox, orientation=QtGui.QGridLayout())
self.toolActions = QtGui.QActionGroup(self)
self.toolActions.setExclusive(True)
self.toolButtons = []
for i, (name, tooltip, tool, icon) in enumerate(self.TOOLS):
action = QAction(
name, self,
toolTip=tooltip,
checkable=tool.checkable,
icon=QIcon(icon),
)
action.triggered.connect(partial(self.set_current_tool, tool))
button = QtGui.QToolButton(
iconSize=QSize(24, 24),
toolButtonStyle=Qt.ToolButtonTextUnderIcon,
sizePolicy=QSizePolicy(QSizePolicy.MinimumExpanding,
QSizePolicy.Fixed)
)
button.setDefaultAction(action)
self.toolButtons.append((button, tool))
toolsBox.layout().addWidget(button, i / 3, i % 3)
self.toolActions.addAction(action)
for column in range(3):
toolsBox.layout().setColumnMinimumWidth(column, 10)
toolsBox.layout().setColumnStretch(column, 1)
undo = self.undo_stack.createUndoAction(self)
redo = self.undo_stack.createRedoAction(self)
undo.setShortcut(QtGui.QKeySequence.Undo)
redo.setShortcut(QtGui.QKeySequence.Redo)
self.addActions([undo, redo])
gui.separator(tBox)
indBox = gui.indentedBox(tBox, sep=8)
form = QtGui.QFormLayout(
formAlignment=Qt.AlignLeft,
labelAlignment=Qt.AlignLeft,
fieldGrowthPolicy=QtGui.QFormLayout.AllNonFixedFieldsGrow
)
indBox.layout().addLayout(form)
slider = gui.hSlider(
indBox, self, "brushRadius", minValue=1, maxValue=100,
createLabel=False
)
#.........这里部分代码省略.........