def _create_header_window(self, info): widget = QtGui.QWidget() vbox = QtGui.QVBoxLayout() vbox.setContentsMargins(2, 2, 2, 2) widget.setLayout(vbox) table = QtGui.QTableView() self.table = table table.setSelectionBehavior(QtGui.QAbstractItemView.SelectRows) table.setShowGrid(False) vh = table.verticalHeader() # Hack to make the rows in a TableView all have a # reasonable height for the data if QtHelp.have_pyqt5: vh.setSectionResizeMode(QtGui.QHeaderView.ResizeToContents) else: vh.setResizeMode(QtGui.QHeaderView.ResizeToContents) # Hide vertical header vh.setVisible(False) vbox.addWidget(table, stretch=1) # create sort toggle cb = QtGui.QCheckBox("Sortable") cb.stateChanged.connect(lambda tf: self.set_sortable_cb(info)) hbox = QtHelp.HBox() hbox.addWidget(cb, stretch=0) vbox.addWidget(hbox, stretch=0) info.setvals(widget=widget, table=table, sortw=cb) return widget
def _build_gui(self, container): self.mframe = container vbox = QtHelp.VBox() # create the table table = QtGui.QTableView() self.table = table table.setSelectionBehavior(QtGui.QAbstractItemView.SelectRows) table.setSelectionMode(QtGui.QAbstractItemView.SingleSelection) table.setShowGrid(False) vh = table.verticalHeader() # Hack to make the rows in a TableView all have a # reasonable height for the data if QtHelp.have_pyqt5: vh.setSectionResizeMode(QtGui.QHeaderView.ResizeToContents) else: vh.setResizeMode(QtGui.QHeaderView.ResizeToContents) # Hide vertical header vh.setVisible(False) vbox.addWidget(table, stretch=1) self.cbar = ColorBar.ColorBar(self.logger) self.cbar.set_cmap(self.cmap) self.cbar.set_imap(self.imap) #self.cbar.set_size_request(-1, 20) rgbmap = self.cbar.get_rgbmap() rgbmap.add_callback('changed', lambda *args: self.replot_stars()) vbox.addWidget(self.cbar, stretch=0) btns = QtHelp.HBox() btns.setSpacing(5) combobox = QtHelp.ComboBox() options = [] index = 0 for name in self.cmap_names: options.append(name) combobox.addItem(name) index += 1 cmap_name = self.magcmap try: index = self.cmap_names.index(cmap_name) except Exception: index = self.cmap_names.index('ramp') combobox.setCurrentIndex(index) combobox.activated.connect(self.set_cmap_cb) self.btn['cmap'] = combobox btns.addWidget(combobox, stretch=0, alignment=QtCore.Qt.AlignRight) combobox = QtHelp.ComboBox() options = [] index = 0 for name in self.imap_names: options.append(name) combobox.addItem(name) index += 1 imap_name = self.magimap try: index = self.imap_names.index(imap_name) except Exception: index = self.imap_names.index('ramp') combobox.setCurrentIndex(index) combobox.activated.connect(self.set_imap_cb) self.btn['imap'] = combobox btns.addWidget(combobox, stretch=0, alignment=QtCore.Qt.AlignRight) vbox.addWidget(btns, stretch=0, alignment=QtCore.Qt.AlignTop) btns = QtHelp.HBox() btns.setSpacing(5) for name in ('Plot', 'Clear', #'Close' ): btn = QtGui.QPushButton(name) btns.addWidget(btn, stretch=0, alignment=QtCore.Qt.AlignLeft) self.btn[name.lower()] = btn self.btn.plot.clicked.connect(self.replot_stars) self.btn.clear.clicked.connect(self.clear) #self.btn.close.clicked.connect(self.close) combobox = QtHelp.ComboBox() options = [] index = 0 for name in ['Mag']: options.append(name) combobox.addItem(name) index += 1 combobox.setCurrentIndex(0) combobox.activated.connect(self.set_field_cb) self.btn['field'] = combobox btns.addWidget(combobox, stretch=0, alignment=QtCore.Qt.AlignLeft) vbox.addWidget(btns, stretch=0, alignment=QtCore.Qt.AlignTop) # create the table info = Bunch.Bunch(columns=self.columns, color='Mag') self.build_table(info) self.mframe.addWidget(vbox, stretch=1)