def create_layout(self): self.setStyleSheet(DOCKSTYLESHEET) # Create the title layout. self.setContentsMargins(0, 0, 0, 0) box = QtGui.QHBoxLayout() box.setContentsMargins(0, 2, 0, 2) box.setSpacing(0) # Add the title. self.title_widget = QtGui.QLabel(self.name, self) box.addSpacing(5) box.addWidget(self.title_widget) # Add spacing. box.addStretch(1000) # Add the dock-related buttons. if self.is_floatable(): box.addWidget(self.dockable_button) box.addWidget(self.maximize_button) box.addWidget(self.dock_button) # Add the close button. if self.is_closable(): box.addWidget(self.close_button) self.setLayout(box)
def create_feature_widget(self, coord=0): # coord => (channel, feature) self.projection = [(0, 0), (0, 1)] hbox = QtGui.QHBoxLayout() hbox.setSpacing(0) # HACK: pyside does not have this function if hasattr(hbox, 'setMargin'): hbox.setMargin(0) # channel selection comboBox = QtGui.QComboBox(self) comboBox.setEditable(True) comboBox.setMaximumWidth(100) comboBox.setInsertPolicy(QtGui.QComboBox.NoInsert) comboBox.addItems(["%d" % i for i in self.channels]) comboBox.addItems(["Extra %d" % i for i in xrange(self.nextrafet)]) comboBox.editTextChanged.connect(partial(self.select_channel, coord)) # comboBox.setFocusPolicy(QtCore.Qt.ClickFocus) self.channel_box[coord] = comboBox hbox.addWidget(comboBox) # create 3 buttons for selecting the feature widths = [30] * self.fetdim labels = ['PC%d' % i for i in xrange(1, self.fetdim + 1)] hbox.addSpacing(10) # ensure exclusivity of the group of buttons pushButtonGroup = QtGui.QButtonGroup(self) for i in xrange(len(labels)): # selecting feature i pushButton = QtGui.QPushButton(labels[i], self) pushButton.setCheckable(True) if coord == i: pushButton.setChecked(True) pushButton.setMaximumSize(QtCore.QSize(widths[i], 20)) pushButton.clicked.connect(partial(self.select_feature, coord, i)) pushButtonGroup.addButton(pushButton, i) self.feature_buttons[coord][i] = pushButton hbox.addWidget(pushButton) return hbox
def create_widget(self): box = QtGui.QHBoxLayout() if hasattr(box, 'setMargin'): box.setContentsMargins(QtCore.QMargins(10, 2, 10, 2)) # box.addSpacing(10) # coord => channel combo box self.channel_box = [None, None] # coord => (butA, butB, butC) self.feature_buttons = [[None] * self.fetdim, [None] * self.fetdim] # add feature widget self.feature_widget1 = self.create_feature_widget(0) box.addLayout(self.feature_widget1) box.addSpacing(10) # Switch button. # button = QtGui.QPushButton('Flip', self) button = QtGui.QPushButton(self) button.setIcon(get_icon('flip')) button.setMaximumWidth(40) button.clicked.connect(self.flip_projections_callback) box.addWidget(button) box.addSpacing(10) # add feature widget self.feature_widget2 = self.create_feature_widget(1) box.addLayout(self.feature_widget2) # box.addSpacing(10) self.setTabOrder(self.channel_box[0], self.channel_box[1]) # self.setMaximumWidth(300) # self.setMaximumHeight(80) return box