本文整理汇总了Python中Orange.widgets.utils.itemmodels.VariableListModel类的典型用法代码示例。如果您正苦于以下问题:Python VariableListModel类的具体用法?Python VariableListModel怎么用?Python VariableListModel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了VariableListModel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self):
super().__init__()
self.data = None
self.input_features = None
self.attrs = []
self.attr_box = gui.hBox(self.mainArea)
model = VariableListModel()
model.wrap(self.attrs)
self.attrXCombo = gui.comboBox(
self.attr_box, self, value="attrX", contentsLength=12,
callback=self.change_attr, sendSelectedValue=True, valueType=str)
self.attrXCombo.setModel(model)
gui.widgetLabel(self.attr_box, "\u2715").\
setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
self.attrYCombo = gui.comboBox(
self.attr_box, self, value="attrY", contentsLength=12,
callback=self.change_attr, sendSelectedValue=True, valueType=str)
self.attrYCombo.setModel(model)
self.canvas = QGraphicsScene()
self.canvasView = ViewWithPress(self.canvas, self.mainArea,
handler=self.reset_selection)
self.mainArea.layout().addWidget(self.canvasView)
self.canvasView.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
self.canvasView.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
box = gui.hBox(self.mainArea)
box.layout().addWidget(self.graphButton)
box.layout().addWidget(self.report_button)
示例2: __init__
def __init__(self):
self.model_selected = VariableListModel(enable_dnd=True)
self.model_selected.removed.connect(self.__model_selected_changed)
self.model_other = VariableListModel(enable_dnd=True)
self.vizrank, self.btn_vizrank = LinearProjectionVizRank.add_vizrank(
None, self, "Suggest Features", self.__vizrank_set_attrs)
super().__init__()
示例3: __init__
def __init__(self):
self.model_selected = VariableListModel(enable_dnd=True)
self.model_selected.rowsInserted.connect(self.__model_selected_changed)
self.model_selected.rowsRemoved.connect(self.__model_selected_changed)
self.model_other = VariableListModel(enable_dnd=True)
self.vizrank, self.btn_vizrank = RadvizVizRank.add_vizrank(
None, self, "Suggest features", self.__vizrank_set_attrs
)
super().__init__()
示例4: TestListModel
class TestListModel(GuiTest):
def setUp(self):
self.widget = OWWidget()
self.widget.foo = None
self.attrs = VariableListModel()
self.view = gui.listView(
self.widget.controlArea, self.widget, "foo", model=self.attrs)
def test_select_callback(self):
widget = self.widget
view = self.view
self.assertIsNone(widget.foo)
a, b, c = (ContinuousVariable(x) for x in "abc")
self.attrs[:] = [a, b, c]
view.setCurrentIndex(self.attrs.index(0, 0))
self.assertIs(widget.foo, a)
view.setCurrentIndex(self.attrs.index(2, 0))
self.assertIs(widget.foo, c)
view.setSelectionMode(view.MultiSelection)
sel_model = view.selectionModel()
sel_model.clear()
view.setCurrentIndex(self.attrs.index(1, 0))
self.assertEqual(widget.foo, [b])
def test_select_callfront(self):
widget = self.widget
view = self.view
a, b, c = (ContinuousVariable(x) for x in "abc")
self.attrs[:] = [a, b, c]
widget.foo = b
selection = view.selectedIndexes()
self.assertEqual(len(selection), 1)
self.assertEqual(selection[0].row(), 1)
view.setSelectionMode(view.MultiSelection)
widget.foo = [a, c]
selection = view.selectedIndexes()
self.assertEqual(len(selection), 2)
self.assertEqual({selection[0].row(), selection[1].row()}, {0, 2})
widget.foo = []
selection = view.selectedIndexes()
self.assertEqual(len(selection), 0)
widget.foo = [2, "b"]
selection = view.selectedIndexes()
self.assertEqual(len(selection), 2)
self.assertEqual({selection[0].row(), selection[1].row()}, {1, 2})
示例5: __init__
def __init__(self):
super().__init__()
self.corpus = None
# Browse file box
fbox = gui.widgetBox(self.controlArea, "Corpus file", orientation=0)
self.file_widget = widgets.FileWidget(
recent_files=self.recent_files, icon_size=(16, 16),
on_open=self.open_file, dialog_format=self.dlgFormats,
dialog_title='Open Orange Document Corpus',
reload_label='Reload', browse_label='Browse',
allow_empty=False, minimal_width=250,
)
fbox.layout().addWidget(self.file_widget)
# Corpus info
ibox = gui.widgetBox(self.controlArea, "Corpus info", addSpace=True)
self.info_label = gui.label(ibox, self, "")
self.update_info()
# Used Text Features
fbox = gui.widgetBox(self.controlArea, orientation=0)
ubox = gui.widgetBox(fbox, "Used text features", addSpace=False)
self.used_attrs_model = VariableListModel(enable_dnd=True)
self.used_attrs_view = VariablesListItemView()
self.used_attrs_view.setModel(self.used_attrs_model)
ubox.layout().addWidget(self.used_attrs_view)
aa = self.used_attrs_model
aa.dataChanged.connect(self.update_feature_selection)
aa.rowsInserted.connect(self.update_feature_selection)
aa.rowsRemoved.connect(self.update_feature_selection)
# Ignored Text Features
ibox = gui.widgetBox(fbox, "Ignored text features", addSpace=False)
self.unused_attrs_model = VariableListModel(enable_dnd=True)
self.unused_attrs_view = VariablesListItemView()
self.unused_attrs_view.setModel(self.unused_attrs_model)
ibox.layout().addWidget(self.unused_attrs_view)
# Documentation Data Sets & Report
box = gui.hBox(self.controlArea)
self.browse_documentation = gui.button(
box, self, "Browse documentation corpora",
callback=lambda: self.file_widget.browse(
get_sample_corpora_dir()),
autoDefault=False,
)
# load first file
self.file_widget.select(0)
示例6: _create_layout
def _create_layout(self):
box = gui.widgetBox(self.controlArea,
orientation='horizontal')
self.varmodel = VariableListModel(parent=self)
self.attr_combo = gui.comboBox(box, self, 'selected_attr',
orientation=Qt.Horizontal,
label='Region attribute:',
callback=self.on_attr_change,
sendSelectedValue=True)
self.attr_combo.setModel(self.varmodel)
self.map_combo = gui.comboBox(box, self, 'selected_map',
orientation=Qt.Horizontal,
label='Map type:',
callback=self.on_map_change,
items=Map.all)
hexpand = QSizePolicy(QSizePolicy.Expanding,
QSizePolicy.Fixed)
self.attr_combo.setSizePolicy(hexpand)
self.map_combo.setSizePolicy(hexpand)
url = urljoin('file:',
pathname2url(os.path.join(
os.path.dirname(__file__),
'resources',
'owgeomap.html')))
self.webview = gui.WebviewWidget(self.controlArea, self, url=QUrl(url))
self.controlArea.layout().addWidget(self.webview)
QTimer.singleShot(
0, lambda: self.webview.evalJS('REGIONS = {};'.format({Map.WORLD: CC_WORLD,
Map.EUROPE: CC_EUROPE,
Map.USA: CC_USA})))
示例7: __init__
def __init__(self):
self.data = None
self.indices = []
box = gui.vBox(self.controlArea, 'Axes')
self.combo_ax2 = gui.comboBox(
box, self, 'ax2', label='Y axis:', callback=self.replot,
sendSelectedValue=True, orientation='horizontal')
self.combo_ax1 = gui.comboBox(
box, self, 'ax1', label='Radial:', callback=self.replot,
sendSelectedValue=True, orientation='horizontal')
box = gui.vBox(self.controlArea, 'Aggregation')
self.combo_func = gui.comboBox(
box, self, 'agg_func', label='Function:', orientation='horizontal',
callback=self.replot)
func_model = ListModel(AGG_FUNCTIONS, parent=self)
self.combo_func.setModel(func_model)
self.attrlist_model = VariableListModel(parent=self)
self.attrlist = QListView(selectionMode=QListView.ExtendedSelection)
self.attrlist.setModel(self.attrlist_model)
self.attrlist.selectionModel().selectionChanged.connect(
self.attrlist_selectionChanged)
box.layout().addWidget(self.attrlist)
gui.rubber(self.controlArea)
self.chart = chart = Spiralogram(self,
selection_callback=self.on_selection)
self.mainArea.layout().addWidget(chart)
示例8: TestListModel
class TestListModel(GuiTest):
def test_select(self):
widget = OWWidget()
widget.foo = None
self.attrs = VariableListModel()
view = gui.listView(widget.controlArea, widget, "foo", model=self.attrs)
self.assertIsNone(widget.foo)
a, b, c = (ContinuousVariable(x) for x in "abc")
self.attrs[:] = [a, b, c]
view.setCurrentIndex(self.attrs.index(0, 0))
self.assertIs(widget.foo, a)
view.setCurrentIndex(self.attrs.index(2, 0))
self.assertIs(widget.foo, c)
widget.foo = b
selection = view.selectedIndexes()
self.assertEqual(len(selection), 1)
self.assertEqual(selection[0].row(), 1)
示例9: dropMimeData
def dropMimeData(self, mime, action, row, column, parent):
""" Ensure only one variable can be dropped onto the view.
"""
vars = mime.property('_items')
if vars is None or len(self) + len(vars) > 1:
return False
if action == Qt.IgnoreAction:
return True
return VariableListModel.dropMimeData(
self, mime, action, row, column, parent)
示例10: _create_layout
def _create_layout(self):
box = gui.widgetBox(self.controlArea,
orientation='horizontal')
self.varmodel = VariableListModel(parent=self)
self.attr_combo = gui.comboBox(box, self, 'selected_attr',
orientation=Qt.Horizontal,
label='Region attribute:',
callback=self.on_attr_change,
sendSelectedValue=True)
self.attr_combo.setModel(self.varmodel)
self.map_combo = gui.comboBox(box, self, 'selected_map',
orientation=Qt.Horizontal,
label='Map type:',
callback=self.on_map_change,
items=Map.all)
hexpand = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding,
QtGui.QSizePolicy.Fixed)
self.attr_combo.setSizePolicy(hexpand)
self.map_combo.setSizePolicy(hexpand)
html = '''
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<base href="{}/"/>
<style>
html, body, #map {{margin:0px;padding:0px;width:100%;height:100%;}}
</style>
<link href="resources/jquery-jvectormap-2.0.2.css" rel="stylesheet">
<script src="resources/jquery-2.1.4.min.js"></script>
<script src="resources/jquery-jvectormap-2.0.2.min.js"></script>
<script src="resources/jquery-jvectormap-world-mill-en.js"></script>
<script src="resources/jquery-jvectormap-europe-mill-en.js"></script>
<script src="resources/jquery-jvectormap-us-aea-en.js"></script>
<script src="resources/geomap-script.js"></script>
</head>
<body>
<div id="map"></div>
</body>
</html>'''.format(urljoin('file:', pathname2url(path.abspath(path.dirname(__file__)))))
self.webview = gui.WebviewWidget(self.controlArea, self, debug=False)
self.controlArea.layout().addWidget(self.webview)
self.webview.setHtml(html)
QTimer.singleShot(
0, lambda: self.webview.evalJS('REGIONS = {};'.format({Map.WORLD: CC_WORLD,
Map.EUROPE: CC_EUROPE,
Map.USA: CC_USA})))
示例11: __init__
def __init__(self):
self.data = None
self.plots = []
self.configs = []
self.forecasts = OrderedDict()
self.varmodel = VariableListModel(parent=self)
icon = QIcon(join(dirname(__file__), 'icons', 'LineChart-plus.png'))
self.add_button = button = QPushButton(icon, ' &Add plot', self)
button.clicked.connect(self.add_plot)
self.controlArea.layout().addWidget(button)
self.configsArea = gui.vBox(self.controlArea)
self.controlArea.layout().addStretch(1)
# TODO: allow selecting ranges that are sent to output as subset table
self.chart = highstock = Highstock(self, highchart='StockChart')
self.mainArea.layout().addWidget(highstock)
highstock.chart()
QTimer.singleShot(0, self.add_plot)
示例12: __init__
def __init__(self):
self.data = None
self.indices = []
box = gui.vBox(self.controlArea, 'Axes')
self.combo_ax2_model = VariableListModel(parent=self)
self.combo_ax1_model = VariableListModel(parent=self)
for model in (self.combo_ax1_model, self.combo_ax2_model):
model[:] = [_enum_str(i) for i in Spiralogram.AxesCategories]
self.combo_ax2 = gui.comboBox(
box, self, 'ax2', label='Y axis:', callback=self.replot,
sendSelectedValue=True, orientation='horizontal',
model=self.combo_ax2_model)
self.combo_ax1 = gui.comboBox(
box, self, 'ax1', label='Radial:', callback=self.replot,
sendSelectedValue=True, orientation='horizontal',
model=self.combo_ax1_model)
gui.checkBox(box, self, 'invert_date_order', 'Invert Y axis order',
callback=self.replot)
box = gui.vBox(self.controlArea, 'Aggregation')
self.combo_func = gui.comboBox(
box, self, 'agg_func', label='Function:', orientation='horizontal',
callback=self.replot)
func_model = ListModel(AGG_FUNCTIONS, parent=self)
self.combo_func.setModel(func_model)
self.attrlist_model = VariableListModel(parent=self)
self.attrlist = QListView(selectionMode=QListView.SingleSelection)
self.attrlist.setModel(self.attrlist_model)
self.attrlist.selectionModel().selectionChanged.connect(
self.attrlist_selectionChanged)
box.layout().addWidget(self.attrlist)
gui.rubber(self.controlArea)
self.chart = chart = Spiralogram(self,
selection_callback=self.on_selection)
self.mainArea.layout().addWidget(chart)
示例13: __init__
def __init__(self):
self.data = None
self.plots = []
self.configs = []
self.forecasts = OrderedDict()
self.varmodel = VariableListModel(parent=self)
icon = QIcon(join(dirname(__file__), 'icons', 'LineChart-plus.png'))
self.add_button = button = QPushButton(icon, ' &Add plot', self)
button.clicked.connect(self.add_plot)
self.controlArea.layout().addWidget(button)
self.configsArea = gui.vBox(self.controlArea)
self.controlArea.layout().addStretch(1)
# TODO: allow selecting ranges that are sent to output as subset table
self.chart = highstock = Highstock(self, highchart='StockChart')
self.mainArea.layout().addWidget(highstock)
# highstock.evalJS('Highcharts.setOptions({navigator: {enabled:false}});')
highstock.chart(
# For some reason, these options don't work as global opts applied at Highstock init time
# Disable top range selector
rangeSelector_enabled=False,
rangeSelector_inputEnabled=False,
# Disable bottom miniview navigator (it doesn't update)
navigator_enabled=False, )
QTimer.singleShot(0, self.add_plot)
示例14: OWSpiralogram
class OWSpiralogram(widget.OWWidget):
name = 'Spiralogram'
description = "Visualize time series' periodicity in a spiral heatmap."
icon = 'icons/Spiralogram.svg'
priority = 120
class Inputs:
time_series = Input("Time series", Table)
class Outputs:
time_series = Output("Time series", Timeseries)
settingsHandler = settings.DomainContextHandler()
ax1 = settings.ContextSetting('months of year')
ax2 = settings.ContextSetting('years')
agg_attr = settings.ContextSetting([])
agg_func = settings.ContextSetting(0)
invert_date_order = settings.Setting(False)
graph_name = 'chart'
def __init__(self):
self.data = None
self.indices = []
box = gui.vBox(self.controlArea, 'Axes')
self.combo_ax2_model = VariableListModel(parent=self)
self.combo_ax1_model = VariableListModel(parent=self)
for model in (self.combo_ax1_model, self.combo_ax2_model):
model[:] = [_enum_str(i) for i in Spiralogram.AxesCategories]
self.combo_ax2 = gui.comboBox(
box, self, 'ax2', label='Y axis:', callback=self.replot,
sendSelectedValue=True, orientation='horizontal',
model=self.combo_ax2_model)
self.combo_ax1 = gui.comboBox(
box, self, 'ax1', label='Radial:', callback=self.replot,
sendSelectedValue=True, orientation='horizontal',
model=self.combo_ax1_model)
gui.checkBox(box, self, 'invert_date_order', 'Invert Y axis order',
callback=self.replot)
box = gui.vBox(self.controlArea, 'Aggregation')
self.combo_func = gui.comboBox(
box, self, 'agg_func', label='Function:', orientation='horizontal',
callback=self.replot)
func_model = ListModel(AGG_FUNCTIONS, parent=self)
self.combo_func.setModel(func_model)
self.attrlist_model = VariableListModel(parent=self)
self.attrlist = QListView(selectionMode=QListView.SingleSelection)
self.attrlist.setModel(self.attrlist_model)
self.attrlist.selectionModel().selectionChanged.connect(
self.attrlist_selectionChanged)
box.layout().addWidget(self.attrlist)
gui.rubber(self.controlArea)
self.chart = chart = Spiralogram(self,
selection_callback=self.on_selection)
self.mainArea.layout().addWidget(chart)
def attrlist_selectionChanged(self):
self.agg_attr = [self.attrlist_model[i.row()]
for i in self.attrlist.selectionModel().selectedIndexes()]
self.replot()
@Inputs.time_series
def set_data(self, data):
self.data = data = None if data is None else Timeseries.from_data_table(data)
def init_combos():
for model in (self.combo_ax1_model, self.combo_ax2_model):
model.clear()
newmodel = []
if data is not None and data.time_variable is not None:
for model in (self.combo_ax1_model, self.combo_ax2_model):
model[:] = [_enum_str(i) for i in Spiralogram.AxesCategories]
for var in data.domain.variables if data is not None else []:
if (var.is_primitive() and
(var is not data.time_variable or
isinstance(var, TimeVariable) and data.time_delta is None)):
newmodel.append(var)
if var.is_discrete:
for model in (self.combo_ax1_model, self.combo_ax2_model):
model.append(var)
self.attrlist_model.wrap(newmodel)
init_combos()
self.chart.clear()
if data is None:
self.commit()
return
self.closeContext()
self.ax2 = next((self.combo_ax2.itemText(i)
for i in range(self.combo_ax2.count())), '')
self.ax1 = next((self.combo_ax1.itemText(i)
#.........这里部分代码省略.........
示例15: OWLinearProjection
class OWLinearProjection(OWAnchorProjectionWidget):
name = "Linear Projection"
description = "A multi-axis projection of data onto " \
"a two-dimensional plane."
icon = "icons/LinearProjection.svg"
priority = 240
keywords = []
Placement = Enum("Placement", dict(Circular=0, LDA=1, PCA=2),
type=int, qualname="OWLinearProjection.Placement")
Projection_name = {Placement.Circular: "Circular Placement",
Placement.LDA: "Linear Discriminant Analysis",
Placement.PCA: "Principal Component Analysis"}
settings_version = 5
placement = Setting(Placement.Circular)
selected_vars = ContextSetting([])
vizrank = SettingProvider(LinearProjectionVizRank)
GRAPH_CLASS = OWLinProjGraph
graph = SettingProvider(OWLinProjGraph)
class Error(OWAnchorProjectionWidget.Error):
no_cont_features = Msg("Plotting requires numeric features")
def __init__(self):
self.model_selected = VariableListModel(enable_dnd=True)
self.model_selected.rowsInserted.connect(self.__model_selected_changed)
self.model_selected.rowsRemoved.connect(self.__model_selected_changed)
self.model_other = VariableListModel(enable_dnd=True)
self.vizrank, self.btn_vizrank = LinearProjectionVizRank.add_vizrank(
None, self, "Suggest Features", self.__vizrank_set_attrs)
super().__init__()
def _add_controls(self):
self._add_controls_variables()
self._add_controls_placement()
super()._add_controls()
self.graph.gui.add_control(
self._effects_box, gui.hSlider, "Hide radius:", master=self.graph,
value="hide_radius", minValue=0, maxValue=100, step=10,
createLabel=False, callback=self.__radius_slider_changed
)
self.controlArea.layout().removeWidget(self.control_area_stretch)
self.control_area_stretch.setParent(None)
def _add_controls_variables(self):
self.variables_selection = VariablesSelection(
self, self.model_selected, self.model_other, self.controlArea
)
self.variables_selection.add_remove.layout().addWidget(
self.btn_vizrank
)
def _add_controls_placement(self):
box = gui.widgetBox(
self.controlArea, True,
sizePolicy=(QSizePolicy.Minimum, QSizePolicy.Maximum)
)
self.radio_placement = gui.radioButtonsInBox(
box, self, "placement",
btnLabels=[self.Projection_name[x] for x in self.Placement],
callback=self.__placement_radio_changed
)
@property
def continuous_variables(self):
if self.data is None or self.data.domain is None:
return []
dom = self.data.domain
return [v for v in chain(dom.variables, dom.metas) if v.is_continuous]
@property
def effective_variables(self):
return self.model_selected[:]
def __vizrank_set_attrs(self, attrs):
if not attrs:
return
self.model_selected[:] = attrs[:]
self.model_other[:] = [var for var in self.continuous_variables
if var not in attrs]
def __model_selected_changed(self):
self.selected_vars = [(var.name, vartype(var)) for var
in self.model_selected]
self.projection = None
self._check_options()
self.init_projection()
self.setup_plot()
self.commit()
def __placement_radio_changed(self):
self.controls.graph.hide_radius.setEnabled(
self.placement != self.Placement.Circular)
self.projection = self.projector = None
self._init_vizrank()
#.........这里部分代码省略.........