def editTmpl(self, template): ind = get_templates().indexOf(template) if ind.isValid(): get_templates.replace(ind.row(), template)
def __init__(self, spreadsheet, parent=None): super(InspectorWidget, self).__init__("Inspector", parent=parent) self.allowed_sides = [QtCore.Qt.DockWidgetArea.RightDockWidgetArea] spreadsheet.selectionChanged.connect(self.selection_change) self.cells = [] self.current_plot = None self.plots = PlotterListModel() widget = QtGui.QWidget() l = QtGui.QVBoxLayout() widget.setLayout(l) # Plot selector label = QtGui.QLabel("Plots:") l.addWidget(label) plots = ComboButton(self.plots, "Delete") plots.selected_object.connect(self.selectPlot) plots.clicked_button.connect(self.deletePlot) l.addWidget(plots) self.plot_combo = plots l.addWidget(QtGui.QLabel("Variables:")) var_1 = ComboButton(get_variables(), "Edit") var_1.selected_object.connect(self.setFirstVar) var_1.clicked_button.connect(self.editFirstVar) l.addWidget(var_1) var_2 = ComboButton(get_variables(), "Edit") var_2.selected_object.connect(self.setSecondVar) var_2.clicked_button.connect(self.editSecondVar) l.addWidget(var_2) self.var_combos = [var_1, var_2] l.addWidget(QtGui.QLabel("Graphics Method:")) self.gm_type_combo = QtGui.QComboBox() self.gm_type_combo.setModel(get_gms()) self.gm_type_combo.currentIndexChanged.connect(self.setGMRoot) self.gm_type_combo.setEnabled(False) l.addWidget(self.gm_type_combo) gm_layout = QtGui.QHBoxLayout() self.gm_instance_combo = QtGui.QComboBox() self.gm_instance_combo.setModel(get_gms()) self.gm_instance_combo.setRootModelIndex(get_gms().index(0, 0)) self.gm_instance_combo.setCurrentIndex(0) self.gm_instance_combo.setEnabled(False) self.gm_instance_combo.currentIndexChanged.connect(self.updateGM) gm_layout.addWidget(self.gm_instance_combo, 1) edit_gm = QtGui.QPushButton("Edit") edit_gm.clicked.connect(self.editGM) gm_layout.addWidget(edit_gm, 0) self.edit_gm_button = edit_gm edit_gm.setEnabled(False) l.addLayout(gm_layout) l.addWidget(QtGui.QLabel("Template:")) self.template_combo = ComboButton(get_templates(), "Edit") self.template_combo.selected_object.connect(self.setTemplate) self.template_combo.clicked_button.connect(self.editTemplate) l.addWidget(self.template_combo) self.plot_combo.setEnabled(False) for v in self.var_combos: v.setEnabled(False) self.template_combo.setEnabled(False) self.tmpl_editor = None self.var_editor = None self.current_var = None self.gm_editor = None self.setWidget(widget)
def makeTmpl(self, template): get_templates().add_template(template)