def setup_option_widget(self): widget = QtWidgets.QWidget() layout = QtWidgets.QHBoxLayout() layout.setContentsMargins(0, 0, 0, 0) self.hour_spinbox = QtWidgets.QSpinBox() self.hour_spinbox.setMinimum(-99) self.hour_spinbox.setMaximum(99) self.hour_spinbox.setValue(3) self.hour_spinbox.setSuffix(" hours") self.minute_spinbox = QtWidgets.QSpinBox() self.minute_spinbox.setMinimum(-59) self.minute_spinbox.setMaximum(59) self.minute_spinbox.setValue(30) self.minute_spinbox.setSuffix(" minutes") widget.setLayout(layout) layout.addWidget(self.hour_spinbox) layout.addWidget(self.minute_spinbox) return widget
def _setup_info_button(self): self._info = QtWidgets.QPushButton() self._info.setMinimumSize(QtCore.QSize(20, 20)) self._info.setMaximumSize(QtCore.QSize(20, 20)) # self._info.setCheckable(True) self._info.setIconSize(QtCore.QSize(20, 20)) self._info.setStyleSheet(CHECK_TOOLBUTTON_STYLESHEET) self._info.setIcon(QtGui.QIcon(":/icons/light/info.svg")) self._info.setFocusPolicy(QtCore.Qt.NoFocus) self._info.setCursor(QtCore.Qt.PointingHandCursor) self._info.clicked.connect(self.show_description) # self._info.setAutoRaise(True) return self._info
def _setup_relative_button(self): self._relative_button = QtWidgets.QPushButton() self._relative_button.setMinimumSize(QtCore.QSize(20, 20)) self._relative_button.setMaximumSize(QtCore.QSize(20, 20)) self._relative_button.setCheckable(True) self._relative_button.setIconSize(QtCore.QSize(20, 20)) self._relative_button.setIcon(QtGui.QIcon(":/icons/light/references.svg")) # self._relative_button.setAutoRaise(True) self._relative_button.setStyleSheet(CHECK_TOOLBUTTON_STYLESHEET) self._relative_button.toggled.connect(self._handle_relative_toggle) self._relative_button.setFocusPolicy(QtCore.Qt.NoFocus) self._relative_button.setCursor(QtCore.Qt.PointingHandCursor) return self._relative_button
def _setup_enable_button(self): self._enabled_button = QtWidgets.QPushButton() self._enabled_button.setMinimumSize(QtCore.QSize(35, 25)) self._enabled_button.setMaximumSize(QtCore.QSize(35, 25)) self._enabled_button.setCheckable(True) self._enabled_button.setIconSize(QtCore.QSize(34, 25)) self._enabled_button.setIcon(QtGui.QIcon(":/icons/off.png")) # self._enabled_button.setAutoRaise(True) self._enabled_button.setStyleSheet(CHECK_TOOLBUTTON_STYLESHEET) self._enabled_button.toggled.connect(self._handle_enabled_toggle) self._enabled_button.setFocusPolicy(QtCore.Qt.NoFocus) self._enabled_button.setCursor(QtCore.Qt.PointingHandCursor) return self._enabled_button
def _add_tag(self, tag_name=None, tag_color=None): if not tag_name or not tag_color: dialog = CreateTagDialog(self) dialog.exec_() result = dialog.result() if result: tag_color = dialog._color tag_name = dialog._name else: return item = QtWidgets.QListWidgetItem() item.setText(tag_name) item.setData(QtCore.Qt.BackgroundRole, QtGui.QBrush(QtGui.QColor(tag_color))) self.tags_lw.addItem(item)
def _setup_ui(self): self.main_layout = QtWidgets.QHBoxLayout() self.setLayout(self.main_layout) self.main_layout.setContentsMargins(0,0,0,0) self.main_layout.addWidget(self.option_widget) relative_widget = self._setup_relative_button() self.main_layout.addWidget(relative_widget) enabled_widget = self._setup_enable_button() self.main_layout.addWidget(enabled_widget) info_widget = self._setup_info_button() self.main_layout.addWidget(info_widget) self.option_widget.setDisabled(True) relative_widget.setDisabled(True) if self.RELATIVE: enabled_widget.toggled.connect(relative_widget.setEnabled) enabled_widget.toggled.connect(self.option_widget.setEnabled)
def setup_option_widget(self): return QtWidgets.QLineEdit()
def show_description(self): description_label = QtWidgets.QMessageBox() description_label.setText("Description") description_label.setInformativeText(self.DESCRIPTION) description_label.exec_()
description_label.setText("Description") description_label.setInformativeText(self.DESCRIPTION) description_label.exec_() def _handle_enabled_toggle(self, value, force=False): icon = QtGui.QIcon(":/icons/off.png") if not value else QtGui.QIcon(":/icons/on.png") self._enabled_button.setIcon(icon) self._enabled = value if force and value: self._enabled_button.setChecked(True) def _handle_relative_toggle(self, value, force=False): icon = QtGui.QIcon(":/icons/light/references.svg") if not value else QtGui.QIcon(":/icons/references_pushed.png") self._relative_button.setIcon(icon) self._relative = value if force and value: self._relative_button.setChecked(True) if __name__ == "__main__": import sys app = QtWidgets.QApplication(sys.argv) wh = BaseOption() # wh.start() wh.show() app.exec_()
def setup_option_widget(self): return QtWidgets.QComboBox()
def setup_option_widget(self): spinbox = QtWidgets.QSpinBox() # spinbox.setStyleSheet(STYLESHEET) return spinbox
painter.drawPath(path) def _draw_text(self, painter, option, index): rect = deepcopy(option.rect) name = index.data(QtCore.Qt.DisplayRole) # pen = QtGui.QPen(QtCore.Qt.black) # painter.setPen(pen) painter.drawText(rect, QtCore.Qt.AlignHCenter | QtCore.Qt.AlignVCenter, name) def sizeHint(self, option, index): name = index.data(QtCore.Qt.DisplayRole) return QtCore.QSize(option.fontMetrics.width(name) + 8, 21) if __name__ == "__main__": import sys app = QtWidgets.QApplication(sys.argv) listwidget = QtWidgets.QListWidget() listwidget.setFlow(QtWidgets.QListView.LeftToRight) listwidget.setSpacing(3) listwidget.setItemDelegate(TagDelegate()) for x in xrange(5): item = QtWidgets.QListWidgetItem() item.setText("Item number {}".format(x)) item.setData(QtCore.Qt.BackgroundRole, QtGui.QBrush(QtGui.QColor("#444444"))) listwidget.addItem(item) listwidget.show() app.exec_()