def __init__(self, browser, model, x, y): # the GUI that enables selection and manipulation of # astropy spectral components is actually handled by # the SpectralModelManager class. self.manager = SpectralModelManager() # any change in the model manager should trigger # a refresh of the local spectral model. Component # selection should cause the component to be painted # in a distinct color. self.manager.changed.connect(browser._sync_model_list) self.manager.selected.connect(browser._display_selected_model) # the model manager needs to know the actual # data being plotted and fitted. self.manager.setArrays(x, y) model_list_gui = self.manager.buildMainPanel(model) model_list_gui.setStretchFactor(0, 0) model_tree = self.manager.treeWidget win = QMainWindow() wid = QWidget() win.setCentralWidget(wid) l = QHBoxLayout() l.setSpacing(2) l.setContentsMargins(3, 3, 3, 3) wid.setLayout(l) widget = MplWidget() win.addToolBar(GlueToolbar(widget.canvas, win)) l.addWidget(widget) right = QVBoxLayout() right.setSpacing(2) right.setContentsMargins(2, 0, 2, 0) right.addWidget(model_list_gui) buttons = QHBoxLayout() buttons.setSpacing(2) buttons.setContentsMargins(2, 0, 2, 0) right.addLayout(buttons) add = QPushButton(get_icon('glue_cross'), '') add.setToolTip('Add a spectral component') remove = QPushButton(get_icon('glue_delete'), '') remove.setToolTip('Remove the current spectral component') fit = QPushButton('Fit') fit.setToolTip("Fit model to spectrum") buttons.insertStretch(0, 1) buttons.addWidget(fit) l.addLayout(right) self.canvas = widget.canvas self.window = win self.model_list_gui = model_list_gui self.model_tree = model_tree self.remove = remove self.add = add self.fit = fit