本文整理汇总了Python中AnyQt.QtWidgets.QGridLayout类的典型用法代码示例。如果您正苦于以下问题:Python QGridLayout类的具体用法?Python QGridLayout怎么用?Python QGridLayout使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QGridLayout类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, var, lc, widget_parent=None, widget=None):
QWidget.__init__(self)
self.list_view = QListView()
text = []
model = QStandardItemModel(self.list_view)
for (i, val) in enumerate(var.values):
item = QStandardItem(val)
item.setCheckable(True)
if i + 1 in lc:
item.setCheckState(Qt.Checked)
text.append(val)
model.appendRow(item)
model.itemChanged.connect(widget_parent.conditions_changed)
self.list_view.setModel(model)
layout = QGridLayout(self)
layout.addWidget(self.list_view)
layout.setContentsMargins(0, 0, 0, 0)
self.setLayout(layout)
self.adjustSize()
self.setWindowFlags(Qt.Popup)
self.widget = widget
self.widget.desc_text = ', '.join(text)
self.widget.set_text()
示例2: __init__
def __init__(self):
super().__init__()
self.data = None
self.results = None
self.learners = []
self.headers = []
box = gui.vBox(self.controlArea, "Learners")
self.learners_box = gui.listBox(
box, self, "selected_learner", "learners",
callback=self._learner_changed
)
box = gui.vBox(self.controlArea, "Show")
gui.comboBox(box, self, "selected_quantity", items=self.quantities,
callback=self._update)
box = gui.vBox(self.controlArea, "Select")
gui.button(box, self, "Select Correct",
callback=self.select_correct, autoDefault=False)
gui.button(box, self, "Select Misclassified",
callback=self.select_wrong, autoDefault=False)
gui.button(box, self, "Clear Selection",
callback=self.select_none, autoDefault=False)
self.outputbox = box = gui.vBox(self.controlArea, "Output")
gui.checkBox(box, self, "append_predictions",
"Predictions", callback=self._invalidate)
gui.checkBox(box, self, "append_probabilities",
"Probabilities",
callback=self._invalidate)
gui.auto_commit(self.controlArea, self, "autocommit",
"Send Selected", "Send Automatically")
grid = QGridLayout()
self.tablemodel = QStandardItemModel(self)
view = self.tableview = QTableView(
editTriggers=QTableView.NoEditTriggers)
view.setModel(self.tablemodel)
view.horizontalHeader().hide()
view.verticalHeader().hide()
view.horizontalHeader().setMinimumSectionSize(60)
view.selectionModel().selectionChanged.connect(self._invalidate)
view.setShowGrid(False)
view.setItemDelegate(BorderedItemDelegate(Qt.white))
view.clicked.connect(self.cell_clicked)
grid.addWidget(view, 0, 0)
self.mainArea.layout().addLayout(grid)
示例3: __setupUi
def __setupUi(self):
layout = QGridLayout()
layout.setContentsMargins(0, 0, 0, 0)
layout.setSpacing(0)
layout.setSizeConstraint(QGridLayout.SetFixedSize)
self.setLayout(layout)
self.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.MinimumExpanding)
示例4: create_gridbox
def create_gridbox(self, widget, box=True):
grid = QGridLayout()
grid.setColumnMinimumWidth(0, 50)
grid.setColumnStretch(1, 1)
box = gui.widgetBox(widget, box=box, orientation=grid)
# This must come after calling widgetBox, since widgetBox overrides it
grid.setVerticalSpacing(8)
return box
示例5: __init__
def __init__(self, title, master, attr, items, cols=1, callback=None):
super().__init__(title=title)
self.master = master
self.attr = attr
self.items = items
self.callback = callback
self.current_values = getattr(self.master, self.attr)
layout = QGridLayout()
self.setLayout(layout)
nrows = len(items) // cols + bool(len(items) % cols)
self.boxes = []
for i, value in enumerate(self.items):
box = QCheckBox(value)
box.setChecked(value in self.current_values)
box.stateChanged.connect(self.synchronize)
self.boxes.append(box)
layout.addWidget(box, i % nrows, i // nrows)
示例6: __init__
def __init__(self):
super().__init__()
self.dataset = None
self.attrs = DomainModel(
valid_types=Orange.data.DiscreteVariable, separators=False)
cb = gui.comboBox(
self.controlArea, self, "attribute", box=True,
model=self.attrs, callback=self.update_scene, contentsLength=12)
grid = QGridLayout()
self.legend = gui.widgetBox(gui.indentedBox(cb.box), orientation=grid)
grid.setColumnStretch(1, 1)
grid.setHorizontalSpacing(6)
self.legend_items = []
self.split_vars = DomainModel(
valid_types=Orange.data.DiscreteVariable, separators=False,
placeholder="None", )
gui.comboBox(
self.controlArea, self, "split_var", box="Split by",
model=self.split_vars, callback=self.update_scene)
gui.checkBox(
self.controlArea, self, "explode", "Explode pies", box=True,
callback=self.update_scene)
gui.rubber(self.controlArea)
gui.widgetLabel(
gui.hBox(self.controlArea, box=True),
"The aim of this widget is to\n"
"demonstrate that pie charts are\n"
"a terrible visualization. Please\n"
"don't use it for any other purpose.")
self.scene = QGraphicsScene()
self.view = QGraphicsView(self.scene)
self.view.setRenderHints(
QPainter.Antialiasing | QPainter.TextAntialiasing |
QPainter.SmoothPixmapTransform)
self.mainArea.layout().addWidget(self.view)
self.mainArea.setMinimumWidth(600)
示例7: __init__
def __init__(self):
super().__init__()
self.data = None
form = QGridLayout()
self.row_type = ""
gui.lineEdit(self.controlArea, self, "row_type", "Row Type", callback=self.send_output)
self.col_type = ""
gui.lineEdit(self.controlArea, self, "col_type", "Column Type", callback=self.send_output)
methodbox = gui.radioButtonsInBox(
self.controlArea, self, "method", [],
box=self.tr("Sampling method"), orientation=form)
rows = gui.appendRadioButton(methodbox, "Rows", addToLayout=False)
form.addWidget(rows, 0, 0, Qt.AlignLeft)
cols = gui.appendRadioButton(methodbox, "Columns", addToLayout=False)
form.addWidget(cols, 0, 1, Qt.AlignLeft)
rows_and_cols = gui.appendRadioButton(methodbox, "Rows and columns", addToLayout=False)
form.addWidget(rows_and_cols, 1, 0, Qt.AlignLeft)
entries = gui.appendRadioButton(methodbox, "Entries", addToLayout=False)
form.addWidget(entries, 1, 1, Qt.AlignLeft)
sample_size = gui.widgetBox(self.controlArea, "Proportion of data in the sample")
gui.hSlider(sample_size, self, 'percent', minValue=1, maxValue=100, step=5, ticks=10,
labelFormat=" %d%%")
gui.button(self.controlArea, self, "&Apply",
callback=self.send_output, default=True)
self.setSizePolicy(QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed))
self.setMinimumWidth(250)
self.send_output()
示例8: __init__
def __init__(self):
super().__init__()
self.corpus = None
form = QGridLayout()
self.method_box = box = gui.radioButtonsInBox(
self.controlArea, self, "method_idx", [], box="Method",
orientation=form, callback=self._method_changed)
self.liu_hu = gui.appendRadioButton(box, "Liu Hu", addToLayout=False)
self.liu_lang = gui.comboBox(None, self, 'language',
sendSelectedValue=True,
items=self.LANG,
callback=self._method_changed)
self.vader = gui.appendRadioButton(box, "Vader", addToLayout=False)
form.addWidget(self.liu_hu, 0, 0, Qt.AlignLeft)
form.addWidget(QLabel("Language:"), 0, 1, Qt.AlignRight)
form.addWidget(self.liu_lang, 0, 2, Qt.AlignRight)
form.addWidget(self.vader, 1, 0, Qt.AlignLeft)
ac = gui.auto_commit(self.controlArea, self, 'autocommit', 'Commit',
'Autocommit is on')
ac.layout().insertSpacing(1, 8)
示例9: __init__
def __init__(self):
super().__init__()
self.controlArea = QWidget(self.controlArea)
self.layout().addWidget(self.controlArea)
layout = QGridLayout()
self.controlArea.setLayout(layout)
layout.setContentsMargins(4, 4, 4, 4)
box = gui.vBox(self.controlArea, "Available Variables",
addToLayout=False)
self.available_attrs = VariableListModel(enable_dnd=True)
filter_edit, self.available_attrs_view = variables_filter(
parent=self, model=self.available_attrs)
box.layout().addWidget(filter_edit)
def dropcompleted(action):
if action == Qt.MoveAction:
self.commit()
self.available_attrs_view.selectionModel().selectionChanged.connect(
partial(self.update_interface_state, self.available_attrs_view))
self.available_attrs_view.selectionModel().selectionChanged.connect(
partial(self.update_interface_state, self.available_attrs_view))
self.available_attrs_view.dragDropActionDidComplete.connect(dropcompleted)
box.layout().addWidget(self.available_attrs_view)
layout.addWidget(box, 0, 0, 3, 1)
box = gui.vBox(self.controlArea, "Features", addToLayout=False)
self.used_attrs = VariableListModel(enable_dnd=True)
self.used_attrs_view = VariablesListItemView(
acceptedType=(Orange.data.DiscreteVariable,
Orange.data.ContinuousVariable))
self.used_attrs_view.setModel(self.used_attrs)
self.used_attrs_view.selectionModel().selectionChanged.connect(
partial(self.update_interface_state, self.used_attrs_view))
self.used_attrs_view.dragDropActionDidComplete.connect(dropcompleted)
box.layout().addWidget(self.used_attrs_view)
layout.addWidget(box, 0, 2, 1, 1)
box = gui.vBox(self.controlArea, "Target Variable", addToLayout=False)
self.class_attrs = ClassVarListItemModel(enable_dnd=True)
self.class_attrs_view = ClassVariableItemView(
acceptedType=(Orange.data.DiscreteVariable,
Orange.data.ContinuousVariable))
self.class_attrs_view.setModel(self.class_attrs)
self.class_attrs_view.selectionModel().selectionChanged.connect(
partial(self.update_interface_state, self.class_attrs_view))
self.class_attrs_view.dragDropActionDidComplete.connect(dropcompleted)
self.class_attrs_view.setMaximumHeight(72)
box.layout().addWidget(self.class_attrs_view)
layout.addWidget(box, 1, 2, 1, 1)
box = gui.vBox(self.controlArea, "Meta Attributes", addToLayout=False)
self.meta_attrs = VariableListModel(enable_dnd=True)
self.meta_attrs_view = VariablesListItemView(
acceptedType=Orange.data.Variable)
self.meta_attrs_view.setModel(self.meta_attrs)
self.meta_attrs_view.selectionModel().selectionChanged.connect(
partial(self.update_interface_state, self.meta_attrs_view))
self.meta_attrs_view.dragDropActionDidComplete.connect(dropcompleted)
box.layout().addWidget(self.meta_attrs_view)
layout.addWidget(box, 2, 2, 1, 1)
bbox = gui.vBox(self.controlArea, addToLayout=False, margin=0)
layout.addWidget(bbox, 0, 1, 1, 1)
self.up_attr_button = gui.button(bbox, self, "Up",
callback=partial(self.move_up, self.used_attrs_view))
self.move_attr_button = gui.button(bbox, self, ">",
callback=partial(self.move_selected,
self.used_attrs_view)
)
self.down_attr_button = gui.button(bbox, self, "Down",
callback=partial(self.move_down, self.used_attrs_view))
bbox = gui.vBox(self.controlArea, addToLayout=False, margin=0)
layout.addWidget(bbox, 1, 1, 1, 1)
self.up_class_button = gui.button(bbox, self, "Up",
callback=partial(self.move_up, self.class_attrs_view))
self.move_class_button = gui.button(bbox, self, ">",
callback=partial(self.move_selected,
self.class_attrs_view,
exclusive=False)
)
self.down_class_button = gui.button(bbox, self, "Down",
callback=partial(self.move_down, self.class_attrs_view))
bbox = gui.vBox(self.controlArea, addToLayout=False, margin=0)
layout.addWidget(bbox, 2, 1, 1, 1)
self.up_meta_button = gui.button(bbox, self, "Up",
callback=partial(self.move_up, self.meta_attrs_view))
self.move_meta_button = gui.button(bbox, self, ">",
callback=partial(self.move_selected,
self.meta_attrs_view)
)
self.down_meta_button = gui.button(bbox, self, "Down",
callback=partial(self.move_down, self.meta_attrs_view))
#.........这里部分代码省略.........
示例10: __init__
def __init__(self):
super().__init__()
self.data = None
self.stored_phase = None
self.spectra_table = None
if self.dx_HeNe is True:
self.dx = 1.0 / self.laser_wavenumber / 2.0
# GUI
# An info box
infoBox = gui.widgetBox(self.controlArea, "Info")
self.infoa = gui.widgetLabel(infoBox, "No data on input.")
self.infob = gui.widgetLabel(infoBox, "")
self.infoc = gui.widgetLabel(infoBox, "")
# Input Data control area
self.dataBox = gui.widgetBox(self.controlArea, "Input Data")
gui.widgetLabel(self.dataBox, "Datapoint spacing (Δx):")
grid = QGridLayout()
grid.setContentsMargins(0, 0, 0, 0)
self.dx_edit = gui.lineEdit(
self.dataBox, self, "dx",
callback=self.setting_changed,
valueType=float,
controlWidth=100, disabled=self.dx_HeNe
)
self.dx_HeNe_cb = gui.checkBox(
self.dataBox, self, "dx_HeNe",
label="HeNe laser",
callback=self.dx_changed,
)
lb = gui.widgetLabel(self.dataBox, "cm")
grid.addWidget(self.dx_HeNe_cb, 0, 0)
grid.addWidget(self.dx_edit, 0, 1)
grid.addWidget(lb, 0, 2)
wl = gui.widgetLabel(self.dataBox, "Sweep Direction:")
box = gui.comboBox(
self.dataBox, self, "sweeps",
label=None,
items=self.sweep_opts,
callback=self.sweeps_changed,
disabled=self.auto_sweeps
)
cb2 = gui.checkBox(
self.dataBox, self, "auto_sweeps",
label="Auto",
callback=self.sweeps_changed,
)
grid.addWidget(wl, 1, 0, 1, 3)
grid.addWidget(cb2, 2, 0)
grid.addWidget(box, 2, 1)
self.dataBox.layout().addLayout(grid)
box = gui.comboBox(
self.dataBox, self, "peak_search",
label="ZPD Peak Search:",
items=[name.title() for name, _ in irfft.PeakSearch.__members__.items()],
callback=self.setting_changed
)
# FFT Options control area
self.optionsBox = gui.widgetBox(self.controlArea, "FFT Options")
box = gui.comboBox(
self.optionsBox, self, "apod_func",
label="Apodization function:",
items=self.apod_opts,
callback=self.setting_changed
)
box = gui.comboBox(
self.optionsBox, self, "zff",
label="Zero Filling Factor:",
items=(2**n for n in range(10)),
callback=self.setting_changed
)
box = gui.comboBox(
self.optionsBox, self, "phase_corr",
label="Phase Correction:",
items=self.phase_opts,
callback=self.setting_changed
)
grid = QGridLayout()
grid.setContentsMargins(0, 0, 0, 0)
le1 = gui.lineEdit(
self.optionsBox, self, "phase_resolution",
callback=self.setting_changed,
valueType=int, controlWidth=30
)
cb1 = gui.checkBox(
self.optionsBox, self, "phase_res_limit",
label="Limit phase resolution to ",
callback=self.setting_changed,
#.........这里部分代码省略.........
示例11: __init__
def __init__(self):
super().__init__()
self.controlArea = QWidget(self.controlArea)
self.layout().addWidget(self.controlArea)
layout = QGridLayout()
self.controlArea.setLayout(layout)
layout.setContentsMargins(4, 4, 4, 4)
box = gui.vBox(self.controlArea, "Available Variables",
addToLayout=False)
self.filter_edit = QLineEdit()
self.filter_edit.setToolTip("Filter the list of available variables.")
box.layout().addWidget(self.filter_edit)
if hasattr(self.filter_edit, "setPlaceholderText"):
self.filter_edit.setPlaceholderText("Filter")
self.completer = QCompleter()
self.completer.setCompletionMode(QCompleter.InlineCompletion)
self.completer_model = QStringListModel()
self.completer.setModel(self.completer_model)
self.completer.setModelSorting(
QCompleter.CaseSensitivelySortedModel)
self.filter_edit.setCompleter(self.completer)
self.completer_navigator = CompleterNavigator(self)
self.filter_edit.installEventFilter(self.completer_navigator)
def dropcompleted(action):
if action == Qt.MoveAction:
self.commit()
self.available_attrs = VariableListModel(enable_dnd=True)
self.available_attrs_proxy = VariableFilterProxyModel()
self.available_attrs_proxy.setSourceModel(self.available_attrs)
self.available_attrs_view = VariablesListItemView(
acceptedType=Orange.data.Variable)
self.available_attrs_view.setModel(self.available_attrs_proxy)
aa = self.available_attrs
aa.dataChanged.connect(self.update_completer_model)
aa.rowsInserted.connect(self.update_completer_model)
aa.rowsRemoved.connect(self.update_completer_model)
self.available_attrs_view.selectionModel().selectionChanged.connect(
partial(self.update_interface_state, self.available_attrs_view))
self.available_attrs_view.dragDropActionDidComplete.connect(dropcompleted)
self.filter_edit.textChanged.connect(self.update_completer_prefix)
self.filter_edit.textChanged.connect(
self.available_attrs_proxy.set_filter_string)
box.layout().addWidget(self.available_attrs_view)
layout.addWidget(box, 0, 0, 3, 1)
box = gui.vBox(self.controlArea, "Features", addToLayout=False)
self.used_attrs = VariableListModel(enable_dnd=True)
self.used_attrs_view = VariablesListItemView(
acceptedType=(Orange.data.DiscreteVariable,
Orange.data.ContinuousVariable))
self.used_attrs_view.setModel(self.used_attrs)
self.used_attrs_view.selectionModel().selectionChanged.connect(
partial(self.update_interface_state, self.used_attrs_view))
self.used_attrs_view.dragDropActionDidComplete.connect(dropcompleted)
box.layout().addWidget(self.used_attrs_view)
layout.addWidget(box, 0, 2, 1, 1)
box = gui.vBox(self.controlArea, "Target Variable", addToLayout=False)
self.class_attrs = ClassVarListItemModel(enable_dnd=True)
self.class_attrs_view = ClassVariableItemView(
acceptedType=(Orange.data.DiscreteVariable,
Orange.data.ContinuousVariable))
self.class_attrs_view.setModel(self.class_attrs)
self.class_attrs_view.selectionModel().selectionChanged.connect(
partial(self.update_interface_state, self.class_attrs_view))
self.class_attrs_view.dragDropActionDidComplete.connect(dropcompleted)
self.class_attrs_view.setMaximumHeight(24)
box.layout().addWidget(self.class_attrs_view)
layout.addWidget(box, 1, 2, 1, 1)
box = gui.vBox(self.controlArea, "Meta Attributes", addToLayout=False)
self.meta_attrs = VariableListModel(enable_dnd=True)
self.meta_attrs_view = VariablesListItemView(
acceptedType=Orange.data.Variable)
self.meta_attrs_view.setModel(self.meta_attrs)
self.meta_attrs_view.selectionModel().selectionChanged.connect(
partial(self.update_interface_state, self.meta_attrs_view))
self.meta_attrs_view.dragDropActionDidComplete.connect(dropcompleted)
box.layout().addWidget(self.meta_attrs_view)
layout.addWidget(box, 2, 2, 1, 1)
bbox = gui.vBox(self.controlArea, addToLayout=False, margin=0)
layout.addWidget(bbox, 0, 1, 1, 1)
self.up_attr_button = gui.button(bbox, self, "Up",
callback=partial(self.move_up, self.used_attrs_view))
self.move_attr_button = gui.button(bbox, self, ">",
callback=partial(self.move_selected, self.used_attrs_view))
self.down_attr_button = gui.button(bbox, self, "Down",
callback=partial(self.move_down, self.used_attrs_view))
bbox = gui.vBox(self.controlArea, addToLayout=False, margin=0)
#.........这里部分代码省略.........
示例12: __init__
def __init__(self):
super().__init__()
self.results = None
self.classifier_names = []
self.perf_line = None
self.colors = []
self._curve_data = {}
self._plot_curves = {}
self._rocch = None
self._perf_line = None
box = gui.vBox(self.controlArea, "Plot")
tbox = gui.vBox(box, "Target Class")
tbox.setFlat(True)
self.target_cb = gui.comboBox(
tbox, self, "target_index", callback=self._on_target_changed,
contentsLength=8)
cbox = gui.vBox(box, "Classifiers")
cbox.setFlat(True)
self.classifiers_list_box = gui.listBox(
cbox, self, "selected_classifiers", "classifier_names",
selectionMode=QListView.MultiSelection,
callback=self._on_classifiers_changed)
abox = gui.vBox(box, "Combine ROC Curves From Folds")
abox.setFlat(True)
gui.comboBox(abox, self, "roc_averaging",
items=["Merge Predictions from Folds", "Mean TP Rate",
"Mean TP and FP at Threshold", "Show Individual Curves"],
callback=self._replot)
hbox = gui.vBox(box, "ROC Convex Hull")
hbox.setFlat(True)
gui.checkBox(hbox, self, "display_convex_curve",
"Show convex ROC curves", callback=self._replot)
gui.checkBox(hbox, self, "display_convex_hull",
"Show ROC convex hull", callback=self._replot)
box = gui.vBox(self.controlArea, "Analysis")
gui.checkBox(box, self, "display_def_threshold",
"Default threshold (0.5) point",
callback=self._on_display_def_threshold_changed)
gui.checkBox(box, self, "display_perf_line", "Show performance line",
callback=self._on_display_perf_line_changed)
grid = QGridLayout()
ibox = gui.indentedBox(box, orientation=grid)
sp = gui.spin(box, self, "fp_cost", 1, 1000, 10,
callback=self._on_display_perf_line_changed)
grid.addWidget(QLabel("FP Cost:"), 0, 0)
grid.addWidget(sp, 0, 1)
sp = gui.spin(box, self, "fn_cost", 1, 1000, 10,
callback=self._on_display_perf_line_changed)
grid.addWidget(QLabel("FN Cost:"))
grid.addWidget(sp, 1, 1)
sp = gui.spin(box, self, "target_prior", 1, 99,
callback=self._on_display_perf_line_changed)
sp.setSuffix("%")
sp.addAction(QAction("Auto", sp))
grid.addWidget(QLabel("Prior target class probability:"))
grid.addWidget(sp, 2, 1)
self.plotview = pg.GraphicsView(background="w")
self.plotview.setFrameStyle(QFrame.StyledPanel)
self.plot = pg.PlotItem(enableMenu=False)
self.plot.setMouseEnabled(False, False)
self.plot.hideButtons()
pen = QPen(self.palette().color(QPalette.Text))
tickfont = QFont(self.font())
tickfont.setPixelSize(max(int(tickfont.pixelSize() * 2 // 3), 11))
axis = self.plot.getAxis("bottom")
axis.setTickFont(tickfont)
axis.setPen(pen)
axis.setLabel("FP Rate (1-Specificity)")
axis = self.plot.getAxis("left")
axis.setTickFont(tickfont)
axis.setPen(pen)
axis.setLabel("TP Rate (Sensitivity)")
self.plot.showGrid(True, True, alpha=0.1)
self.plot.setRange(xRange=(0.0, 1.0), yRange=(0.0, 1.0), padding=0.05)
self.plotview.setCentralItem(self.plot)
self.mainArea.layout().addWidget(self.plotview)
示例13: __init__
def __init__(self, *args):
QWidget.__init__(self, *args)
self.setContentsMargins(0, 0, 0, 0)
gridLayout = QGridLayout()
gridLayout.setContentsMargins(0, 0, 0, 0)
gridLayout.setSpacing(1)
model = QStandardItemModel(self)
model.rowsInserted.connect(self.__changed)
model.rowsRemoved.connect(self.__changed)
model.dataChanged.connect(self.__changed)
self._listView = QListView(self)
self._listView.setModel(model)
# self._listView.setDragEnabled(True)
self._listView.setDropIndicatorShown(True)
self._listView.setDragDropMode(QListView.InternalMove)
self._listView.viewport().setAcceptDrops(True)
self._listView.setMinimumHeight(100)
gridLayout.addWidget(self._listView, 0, 0, 2, 2)
vButtonLayout = QVBoxLayout()
self._upAction = QAction(
"\u2191", self, toolTip="Move up")
self._upButton = QToolButton(self)
self._upButton.setDefaultAction(self._upAction)
self._upButton.setSizePolicy(
QSizePolicy.Fixed, QSizePolicy.MinimumExpanding)
self._downAction = QAction(
"\u2193", self, toolTip="Move down")
self._downButton = QToolButton(self)
self._downButton.setDefaultAction(self._downAction)
self._downButton.setSizePolicy(
QSizePolicy.Fixed, QSizePolicy.MinimumExpanding)
vButtonLayout.addWidget(self._upButton)
vButtonLayout.addWidget(self._downButton)
gridLayout.addLayout(vButtonLayout, 0, 2, 2, 1)
hButtonLayout = QHBoxLayout()
self._addAction = QAction("+", self)
self._addButton = QToolButton(self)
self._addButton.setDefaultAction(self._addAction)
self._removeAction = QAction("-", self)
self._removeButton = QToolButton(self)
self._removeButton.setDefaultAction(self._removeAction)
hButtonLayout.addWidget(self._addButton)
hButtonLayout.addWidget(self._removeButton)
hButtonLayout.addStretch(10)
gridLayout.addLayout(hButtonLayout, 2, 0, 1, 2)
self.setLayout(gridLayout)
self._addAction.triggered.connect(self._onAddAction)
self._removeAction.triggered.connect(self._onRemoveAction)
self._upAction.triggered.connect(self._onUpAction)
self._downAction.triggered.connect(self._onDownAction)
示例14: __init__
def __init__(self):
super().__init__()
self.data = None
self.features = None
# Schedule interface updates (enabled buttons) using a coalescing
# single shot timer (complex interactions on selection and filtering
# updates in the 'available_attrs_view')
self.__interface_update_timer = QTimer(self, interval=0, singleShot=True)
self.__interface_update_timer.timeout.connect(
self.__update_interface_state)
# The last view that has the selection for move operation's source
self.__last_active_view = None # type: Optional[QListView]
def update_on_change(view):
# Schedule interface state update on selection change in `view`
self.__last_active_view = view
self.__interface_update_timer.start()
self.controlArea = QWidget(self.controlArea)
self.layout().addWidget(self.controlArea)
layout = QGridLayout()
self.controlArea.setLayout(layout)
layout.setContentsMargins(4, 4, 4, 4)
box = gui.vBox(self.controlArea, "Available Variables",
addToLayout=False)
self.available_attrs = VariablesListItemModel()
filter_edit, self.available_attrs_view = variables_filter(
parent=self, model=self.available_attrs)
box.layout().addWidget(filter_edit)
def dropcompleted(action):
if action == Qt.MoveAction:
self.commit()
self.available_attrs_view.selectionModel().selectionChanged.connect(
partial(update_on_change, self.available_attrs_view))
self.available_attrs_view.dragDropActionDidComplete.connect(dropcompleted)
box.layout().addWidget(self.available_attrs_view)
layout.addWidget(box, 0, 0, 3, 1)
box = gui.vBox(self.controlArea, "Features", addToLayout=False)
self.used_attrs = VariablesListItemModel()
filter_edit, self.used_attrs_view = variables_filter(
parent=self, model=self.used_attrs,
accepted_type=(Orange.data.DiscreteVariable,
Orange.data.ContinuousVariable))
self.used_attrs.rowsInserted.connect(self.__used_attrs_changed)
self.used_attrs.rowsRemoved.connect(self.__used_attrs_changed)
self.used_attrs_view.selectionModel().selectionChanged.connect(
partial(update_on_change, self.used_attrs_view))
self.used_attrs_view.dragDropActionDidComplete.connect(dropcompleted)
self.use_features_box = gui.auto_commit(
self.controlArea, self, "use_input_features",
"Use input features", "Always use input features",
box=False, commit=self.__use_features_clicked,
callback=self.__use_features_changed, addToLayout=False
)
self.enable_use_features_box()
box.layout().addWidget(self.use_features_box)
box.layout().addWidget(filter_edit)
box.layout().addWidget(self.used_attrs_view)
layout.addWidget(box, 0, 2, 1, 1)
box = gui.vBox(self.controlArea, "Target Variable", addToLayout=False)
self.class_attrs = VariablesListItemModel()
self.class_attrs_view = VariablesListItemView(
acceptedType=(Orange.data.DiscreteVariable,
Orange.data.ContinuousVariable))
self.class_attrs_view.setModel(self.class_attrs)
self.class_attrs_view.selectionModel().selectionChanged.connect(
partial(update_on_change, self.class_attrs_view))
self.class_attrs_view.dragDropActionDidComplete.connect(dropcompleted)
self.class_attrs_view.setMaximumHeight(72)
box.layout().addWidget(self.class_attrs_view)
layout.addWidget(box, 1, 2, 1, 1)
box = gui.vBox(self.controlArea, "Meta Attributes", addToLayout=False)
self.meta_attrs = VariablesListItemModel()
self.meta_attrs_view = VariablesListItemView(
acceptedType=Orange.data.Variable)
self.meta_attrs_view.setModel(self.meta_attrs)
self.meta_attrs_view.selectionModel().selectionChanged.connect(
partial(update_on_change, self.meta_attrs_view))
self.meta_attrs_view.dragDropActionDidComplete.connect(dropcompleted)
box.layout().addWidget(self.meta_attrs_view)
layout.addWidget(box, 2, 2, 1, 1)
bbox = gui.vBox(self.controlArea, addToLayout=False, margin=0)
layout.addWidget(bbox, 0, 1, 1, 1)
self.up_attr_button = gui.button(bbox, self, "Up",
callback=partial(self.move_up, self.used_attrs_view))
self.move_attr_button = gui.button(bbox, self, ">",
callback=partial(self.move_selected,
self.used_attrs_view)
)
self.down_attr_button = gui.button(bbox, self, "Down",
#.........这里部分代码省略.........
示例15: __init__
def __init__(self):
super().__init__()
self.data = None
self.clusterings = {}
layout = QGridLayout()
bg = gui.radioButtonsInBox(
self.controlArea, self, "optimize_k", orientation=layout,
box="Number of Clusters", callback=self.invalidate)
layout.addWidget(
gui.appendRadioButton(bg, "Fixed:", addToLayout=False), 1, 1)
sb = gui.hBox(None, margin=0)
gui.spin(
sb, self, "k", minv=2, maxv=30,
controlWidth=60, alignment=Qt.AlignRight, callback=self.update_k)
gui.rubber(sb)
layout.addWidget(sb, 1, 2)
layout.addWidget(
gui.appendRadioButton(bg, "From", addToLayout=False), 2, 1)
ftobox = gui.hBox(None)
ftobox.layout().setContentsMargins(0, 0, 0, 0)
layout.addWidget(ftobox, 2, 2)
gui.spin(
ftobox, self, "k_from", minv=2, maxv=29,
controlWidth=60, alignment=Qt.AlignRight,
callback=self.update_from)
gui.widgetLabel(ftobox, "to")
gui.spin(
ftobox, self, "k_to", minv=3, maxv=30,
controlWidth=60, alignment=Qt.AlignRight,
callback=self.update_to)
gui.rubber(ftobox)
box = gui.vBox(self.controlArea, "Initialization")
gui.comboBox(
box, self, "smart_init", items=self.INIT_METHODS,
callback=self.invalidate)
layout = QGridLayout()
gui.widgetBox(box, orientation=layout)
layout.addWidget(gui.widgetLabel(None, "Re-runs: "), 0, 0, Qt.AlignLeft)
sb = gui.hBox(None, margin=0)
layout.addWidget(sb, 0, 1)
gui.lineEdit(
sb, self, "n_init", controlWidth=60,
valueType=int, validator=QIntValidator(), callback=self.invalidate)
layout.addWidget(
gui.widgetLabel(None, "Maximum iterations: "), 1, 0, Qt.AlignLeft)
sb = gui.hBox(None, margin=0)
layout.addWidget(sb, 1, 1)
gui.lineEdit(
sb, self, "max_iterations", controlWidth=60, valueType=int,
validator=QIntValidator(), callback=self.invalidate)
self.apply_button = gui.auto_commit(
self.buttonsArea, self, "auto_run", "Apply", box=None,
commit=self.apply)
self.buttonsArea.layout().addWidget(self.report_button)
gui.rubber(self.controlArea)
box = gui.vBox(self.mainArea, box="Silhouette Scores")
table = self.table_view = QTableView(self.mainArea)
table.setModel(ClusterTableModel(self))
table.setSelectionMode(QTableView.SingleSelection)
table.setSelectionBehavior(QTableView.SelectRows)
table.setItemDelegate(gui.ColoredBarItemDelegate(self, color=Qt.cyan))
table.selectionModel().selectionChanged.connect(self.select_row)
table.setMaximumWidth(200)
table.horizontalHeader().setStretchLastSection(True)
table.horizontalHeader().hide()
table.setShowGrid(False)
box.layout().addWidget(table)