def setupUi(self, MainWindow): if not MainWindow.objectName(): MainWindow.setObjectName(u"MainWindow") MainWindow.resize(659, 477) self.centralwidget = QWidget(MainWindow) self.centralwidget.setObjectName(u"centralwidget") self.verticalLayout = QVBoxLayout(self.centralwidget) self.verticalLayout.setObjectName(u"verticalLayout") self.verticalLayout.setContentsMargins(50, -1, 50, -1) self.pushButton = QPushButton(self.centralwidget) self.pushButton.setObjectName(u"pushButton") self.pushButton.setMinimumSize(QSize(0, 50)) font = QFont() font.setPointSize(16) self.pushButton.setFont(font) self.verticalLayout.addWidget(self.pushButton) MainWindow.setCentralWidget(self.centralwidget) self.menubar = QMenuBar(MainWindow) self.menubar.setObjectName(u"menubar") self.menubar.setGeometry(QRect(0, 0, 659, 27)) MainWindow.setMenuBar(self.menubar) self.statusbar = QStatusBar(MainWindow) self.statusbar.setObjectName(u"statusbar") MainWindow.setStatusBar(self.statusbar) self.retranslateUi(MainWindow) QMetaObject.connectSlotsByName(MainWindow)
def formattedLabel(self, text): # Format a label given text font = QFont() font.setPixelSize(18) self.setText(text) self.setFont(font) self.setToolButtonStyle(Qt.ToolButtonTextUnderIcon)
def __init__(self, parent=None): QWidget.__init__(self, parent) self.model = None self.table_name = '' self.mapper = None self.modified = False self.name = "N/A" self.operation_type = None self.layout = QGridLayout(self) self.layout.setContentsMargins(2, 2, 2, 2) self.bold_font = QFont() self.bold_font.setBold(True) self.main_label = QLabel(self) self.main_label.setFont(self.bold_font) self.layout.addWidget(self.main_label, 0, 0, 1, 1, Qt.AlignLeft) self.commit_button = QPushButton(load_icon("accept.png"), '', self) self.commit_button.setToolTip(self.tr("Commit changes")) self.commit_button.setEnabled(False) self.revert_button = QPushButton(load_icon("cancel.png"), '', self) self.revert_button.setToolTip(self.tr("Cancel changes")) self.revert_button.setEnabled(False) self.verticalSpacer = QSpacerItem(20, 40, QSizePolicy.Minimum, QSizePolicy.Expanding) self.horizontalSpacer = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum)
def __init__(self, text, parent): super().__init__(parent) font = QFont() font.setPointSize(h1fontsize) self.setFont(font) self.setText(text) self.setAlignment(Qt.AlignCenter)
def __init__(self, parent=None): super(Window, self).__init__(parent) #Configure the window self.setWindowTitle("EightyFive") self.setGeometry(100, 100, 300, 50) #Font set self.font = QFont("FIRACODE-REGULAR") self.font.setPointSize(14) self.font.setStyleStrategy(QFont.PreferAntialias) #Window style self.setStyleSheet("background-color: #2E3440") # Create label self.time_cnt_lbl_log_on = QLabel("00:00:00", self) self.time_cnt_lbl_log_on.setStyleSheet("color: #ECEFF4") self.time_cnt_lbl_log_on.show() self.time_cnt_lbl_log_on.setFont(self.font) self.time_cnt_lbl_log_on.setGeometry(10, 5, 300, 20) self.time_cnt_lbl_log_off = QLabel("00:00:00", self) self.time_cnt_lbl_log_off.setStyleSheet("color: #ECEFF4") self.time_cnt_lbl_log_off.show() self.time_cnt_lbl_log_off.setFont(self.font) self.time_cnt_lbl_log_off.setGeometry(10, 25, 300, 20) #Set window icon app_icon = QIcon("app_icon.png") self.setWindowIcon(app_icon) self.show()
def data(self, index, role=Qt.DisplayRole, field=''): row = index.row() if not index.isValid(): return None operation = LedgerTransaction().get_operation( self._data[index.row()]['op_type'], self._data[index.row()]['id'], self._data[index.row()]['subtype']) if role == Qt.DisplayRole: return self.data_text(operation, index.column()) if role == Qt.FontRole and index.column() == 0: # below line isn't related with font, it is put here to be called for each row minimal times (ideally 1) self._view.setRowHeight( row, self._view.verticalHeader().defaultSectionSize() * operation.view_rows()) font = QFont() font.setBold(True) return font if role == Qt.ForegroundRole and self._view.isEnabled(): if index.column() == 0: return QBrush(operation.label_color()) elif index.column() == 5: if operation.reconciled(): return QBrush(CustomColor.Blue) if role == Qt.TextAlignmentRole: if index.column() == 0: return int(Qt.AlignCenter | Qt.AlignVCenter) if index.column() == 4 or index.column() == 5: return int(Qt.AlignRight) return int(Qt.AlignLeft) if role == Qt.UserRole: # return underlying data for given field extra parameter return self._data[index.row()][field]
def __init__(self, settings: Settings, index: int, center_x, center_y, prefix: str = '', suffix: str = ''): super().__init__(prefix + str(index) + suffix) self.settings = settings self.settings_helper = SettingWidgetHelper(settings) self.index = index self.setFlag(QGraphicsItem.ItemIsSelectable, True) self.setFlag(QGraphicsItem.ItemIsMovable, True) font = QFont(self.settings.value(default_settings.mark_font)) font.setPixelSize(self.settings.int_value(default_settings.mark_size)) self.setFont(font) self.setBrush(self.settings_helper.mark_brush(index)) radius = self.settings.int_value(default_settings.particle_size) x = center_x - radius - self.boundingRect().width() y = center_y - radius - self.boundingRect().height() if x < 0: x = center_x + radius if y < 0: y = center_y + radius self.setX(x) self.setY(y)
def setupUi(self, Dialog): if not Dialog.objectName(): Dialog.setObjectName(u"Dialog") Dialog.resize(480, 150) self.buttonBox = QDialogButtonBox(Dialog) self.buttonBox.setObjectName(u"buttonBox") self.buttonBox.setGeometry(QRect(0, 100, 461, 32)) self.buttonBox.setOrientation(Qt.Horizontal) self.buttonBox.setStandardButtons(QDialogButtonBox.Apply|QDialogButtonBox.Cancel) self.label = QLabel(Dialog) self.label.setObjectName(u"label") self.label.setGeometry(QRect(10, 20, 81, 16)) self.label_2 = QLabel(Dialog) self.label_2.setObjectName(u"label_2") self.label_2.setGeometry(QRect(240, 20, 57, 14)) self.key = QLineEdit(Dialog) self.key.setObjectName(u"key") self.key.setGeometry(QRect(10, 40, 211, 22)) font = QFont() font.setFamilies([u"Monospace"]) self.key.setFont(font) self.val = QLineEdit(Dialog) self.val.setObjectName(u"val") self.val.setGeometry(QRect(240, 40, 211, 22)) font1 = QFont() self.val.setFont(font1) self.retranslateUi(Dialog) self.buttonBox.accepted.connect(Dialog.accept) self.buttonBox.rejected.connect(Dialog.reject) QMetaObject.connectSlotsByName(Dialog)
def __init__(self, parent=None): QToolButton.__init__(self) self.setParent(parent)\ # Set the layout of the button layout = QGridLayout() # Button formatting self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) self.setAutoRaise(True) # Icon part of the button self.icon = QLabel() self.icon.setAlignment(Qt.AlignCenter) self.icon.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) self.iconPixmap = QPixmap() # Text part of the button # Initialise label self.text = QLabel() self.text.setAlignment(Qt.AlignBottom) # TODO: Change colour with universal theme self.text.setStyleSheet("color: white") # Add font styling font = QFont() font.setPixelSize(15) self.text.setFont(font) # Add components to the layer layout.addWidget(self.icon, 0, 0, 3, 3) layout.addWidget(self.text, 2, 0, 1, 3) self.setLayout(layout)
def __init__(self, block): super().__init__() self.setFlag(QGraphicsItem.ItemIsMovable) self.setFlag(QGraphicsItem.ItemIsFocusable) self.setFlag(QGraphicsItem.ItemSendsGeometryChanges) self.setCacheMode(QGraphicsItem.DeviceCoordinateCache) self.setAcceptHoverEvents(True) # define code text shape: self.code = QGraphicsTextItem() self.code.setHtml(block) f = QFont("Monospace") f.setPointSize(8) self.code.setFont(f) self.code.setParentItem(self) # define circle shape: self.codebox = QGraphicsRectItem(self.code.boundingRect().adjusted( -2, -2, 2, 2)) self.codebox.setBrush(QBrush(QColor("#fdf6e3"))) shadow = QGraphicsDropShadowEffect() shadow.setOffset(4) self.codebox.setGraphicsEffect(shadow) self.codebox.setParentItem(self) self.codebox.setZValue(1.0) self.code.setZValue(2.0) center = (self.codebox.boundingRect().center() - self.code.boundingRect().center()) self.code.setPos(center) self.setZValue(1.0) self.cx = []
def data(self, index, role=Qt.DisplayRole): if not index.isValid(): return None if role == Qt.FontRole and (index.row() in self.deleted): font = QFont() font.setStrikeOut(True) return font return super().data(index, role)
def __init__(self): self.db = ClientesDB() QWidget.__init__(self) font = QFont() font.setBold(True) # Labels em Negrito # Labels: self.label_title = QLabel("Novo Cliente") self.label_title.setFont(font) self.label_nome = QLabel("Nome Completo:") self.label_nome.setFont(font) self.label_endereco = QLabel("Endereço:") self.label_endereco.setFont(font) self.label_numero = QLabel("Número:") self.label_numero.setFont(font) self.label_cpf = QLabel("CPF:") self.label_cpf.setFont(font) # Entries: self.entry_nome = QLineEdit() self.entry_endereco = QTextEdit() self.entry_numero = QLineEdit() self.entry_cpf = QLineEdit() # Botões; self.button_salvar = QPushButton("&Salvar") self.button_salvar.clicked.connect(self.salvar_cliente) self.button_salvar.setShortcut("Ctrl+S") self.button_cancelar = QPushButton("Cancelar") self.button_cancelar.clicked.connect(self.limpar) self.button_cancelar.setShortcut("ESC") # Linha self.line = QFrame() self.line.setFrameShape(QFrame.HLine) self.line.setFrameShadow(QFrame.Sunken) self.line.setLineWidth(0) self.line.setMidLineWidth(1) # Leiaute: self.layout = QVBoxLayout() self.layout_buttons = QHBoxLayout() self.layout.addWidget(self.label_title) self.layout.addWidget(self.line) self.layout.addWidget(self.label_nome) self.layout.addWidget(self.entry_nome) self.layout.addWidget(self.label_numero) self.layout.addWidget(self.entry_numero) self.layout.addWidget(self.label_cpf) self.layout.addWidget(self.entry_cpf) self.layout.addWidget(self.label_endereco) self.layout.addWidget(self.entry_endereco) self.layout_buttons.addWidget(self.button_salvar) self.layout_buttons.addWidget(self.button_cancelar) self.layout.addStretch(2) self.layout.addLayout(self.layout_buttons) self.setLayout(self.layout)
def formattedLabel(self, label): font = QFont() font.setPixelSize(25) # TODO: change with global themes label.setStyleSheet("color: white") label.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) label.setFont(font) return label
def getFont(self): userFont = binaryninjaui.getMonospaceFont(self) if sys.platform == "darwin": # Some fonts aren't fixed width across all characters, use a known good one font = QFont("Menlo", userFont.pointSize()) font.setKerning(False) else: font = userFont return font
def __init__(self, editor): QWidget.__init__(self, editor) global bnstyles self.editor = editor self.editor.blockCountChanged.connect(self.updateWidth) self.editor.updateRequest.connect(self.updateContents) self.font = QFont() self.numberBarColor = bnstyles["numberBar"]
def buildWindow(self, window: QWidget): window.resize(self.newSizeX, self.newSizeY) font = QFont() font.setBold(False) font.setUnderline(False) font.setKerning(False) font.setWeight(QFont.Weight.Normal) window.setFont(font) window.setObjectName(u"background") window.setStyleSheet("QWidget#background {background-color: gray}")
def hidePassword(self): font = QFont('Helvetica', 10, weight=QFont.Bold) font.setLetterSpacing(QFont.PercentageSpacing, 110) self.stopTimer() self.passLabel.setText('* ' * 5) self.passLabel.setFont(font) self.passLabel.disableEdit() self.showButton.show() self.timerProgress.hide()
def init_UI(self): QToolTip.setFont(QFont('TimesNeWRoman', 14)) self.setFont(QFont('SansSerif', 10)) self.simple_button() self.menu_button() self.setGeometry(650, 400, 500, 150) # (300, 300, 300, 200) self.setWindowTitle('example 2') self.show()
def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) font = QFont('monospace', 8) font.setStyleHint(QFont.Monospace) self.setFont(font) self.setShowGrid(False) self.horizontalHeader().hide() self.verticalHeader().setSectionResizeMode( QtWidgets.QHeaderView.Fixed) self.verticalHeader().setHighlightSections(False) self.horizontalHeader().setHighlightSections(False) self.verticalHeader().setSectionsClickable(False) # Don't let the user edit the table cells. self.setEditTriggers(self.NoEditTriggers) self.setSelectionBehavior(QAbstractItemView.SelectItems) self.setSelectionMode(QAbstractItemView.ContiguousSelection) self.setModel(QStandardItemModel(1, 33)) # This will store the raw data that is displayed in the hex view. self.hex_data = None # Determine how wide ASCII columns should be. self.ascii_width = self.fontMetrics().horizontalAdvance('m') # HACK: Get how much space a hex item needs by asking temporarily creating one, and then asking Qt, # because self.fontMetrics().width('mm') isn't enough, apparently, unlike above. self.model().setItem(0, 0, QStandardItem('mm')) self.resizeColumnToContents(0) self.hex_width = self.visualRect(self.model().createIndex( 0, 0)).width() # Default to 16 hex columns, with 16 ASCII columns, and one separator column, for a total of 33. self._set_bytes_per_row(16) # HACK: Get how much space is needed for 16 bytes per row by # getting the left and right bound of the left-most and right-most items, respectively. start = self.visualRect(self.model().createIndex(0, 0)).left() end = self.visualRect(self.model().createIndex(0, 32)).right() self.full_width = end - start # Record the default background color for items, since apparently that's platform dependent. # Note: Normally we can only get the default background color if there's actually an item there, # but we made one earlier to determine the value for self.hex_width, so we don't need to do it again. self.default_background_color = self.model().item(0, 0).background() self.model().setRowCount(0) self.selectionModel().selectionChanged.connect( self._selection_changed)
def setupUi(self): self.centralwidget = QWidget(self) with open(resource_path('style.css'), 'r') as file: self.centralwidget.setStyleSheet(file.read()) self.layout_widget_about = QWidget(self.centralwidget) self.layout_widget_about.setGeometry(QRect(10, 10, 221, 81)) self.layout_about = QVBoxLayout(self.layout_widget_about) self.layout_about.setContentsMargins(0, 0, 0, 0) self.label_logo = QLabel(self.layout_widget_about) self.pixmap = QPixmap(resource_path('icon.ico')) self.pixmap = self.pixmap.scaledToWidth(30, Qt.SmoothTransformation) self.label_logo.setPixmap(self.pixmap) self.layout_about.addWidget(self.label_logo, 0, Qt.AlignHCenter) self.title_font = QFont() self.title_font.setPointSize(13) self.font = QFont() self.font.setPointSize(10) self.label_title = QLabel(self.layout_widget_about) self.title_font.setStyleStrategy(QFont.PreferAntialias) self.label_title.setFont(self.title_font) self.label_title.setLayoutDirection(Qt.LeftToRight) self.layout_about.addWidget(self.label_title, 0, Qt.AlignHCenter) self.label_version = QLabel(self.layout_widget_about) self.label_version.setFont(self.font) self.label_version.setLayoutDirection(Qt.LeftToRight) self.layout_about.addWidget(self.label_version, 0, Qt.AlignHCenter) self.layout_widget_about_2 = QWidget(self.centralwidget) self.layout_widget_about_2.setGeometry(QRect(10, 100, 221, 81)) self.layout_about_2 = QVBoxLayout(self.layout_widget_about_2) self.layout_about_2.setContentsMargins(0, 0, 0, 0) self.label_copyright = QLabel(self.layout_widget_about_2) self.label_copyright.setFont(self.font) self.label_copyright.setLayoutDirection(Qt.LeftToRight) self.layout_about_2.addWidget(self.label_copyright, 0, Qt.AlignHCenter) self.label_author = QLabel(self.layout_widget_about_2) self.label_author.setFont(self.font) self.label_author.setLayoutDirection(Qt.LeftToRight) self.layout_about_2.addWidget(self.label_author, 0, Qt.AlignHCenter) self.button_quit_about = QPushButton(self.layout_widget_about_2) self.layout_about_2.addWidget(self.button_quit_about) self.button_quit_about.setMinimumSize(100, 30) self.button_quit_about.setProperty('class', 'Aqua') self.setCentralWidget(self.centralwidget) self.retranslateUi() QMetaObject.connectSlotsByName(self)
def __init__(self): super(SideMenuWidget, self).__init__() self.layout = QVBoxLayout() self.layout.setContentsMargins(0, 0, 0, 0) self.layout.setSpacing(12) self.setLayout(self.layout) # PROFILE self.layout.addWidget(Profile()) # BUTTONS self.listview = ListView() self.listview.setFrameStyle(QFrame.NoFrame) self.listview.setFocusPolicy(Qt.NoFocus) self.listview.setModel(Model()) self.listview.setItemDelegate(Delegate()) self.layout.addWidget(self.listview) # LABELS self.labels = QWidget() self.labels.setFixedHeight(60) self.layout.addWidget(self.labels) _margins = 16 # left margin self.app_name = LinkLabel(self.labels, "color: rgba(0, 0, 0, 80%)", "color: rgba(0, 0, 0, 60%)") self.app_name.setText("sidemenu app") self.app_name.setFont(QFont("Roboto Light", 12)) self.app_name.move(self.labels.x() + _margins, self.labels.y()) self.app_ver = LinkLabel(self.labels, "color: rgba(0, 0, 0, 60%)", "color: rgba(0, 0, 0, 60%)") self.app_ver.setText("Версия 1.0.0") self.app_ver.setFont(QFont("Roboto Light", 11)) self.app_ver.move(self.labels.x() + _margins, self.labels.y() + _margins * 2) self.lbl = QLabel(self.labels) self.lbl.setText("-") self.lbl.setStyleSheet("color: rgba(0, 0, 0, 60%)") self.lbl.setFont(QFont("Roboto Light", 11)) self.lbl.move(self.labels.x() + _margins * 7, self.labels.y() + _margins * 2) self.app_about = LinkLabel(self.labels, "color: rgba(0, 0, 0, 60%)", "color: rgba(0, 0, 0, 60%)") self.app_about.setText("О программе") self.app_about.setFont(QFont("Roboto Light", 11)) self.app_about.move(self.labels.x() + _margins * 8, self.labels.y() + _margins * 2) self.setStyleSheet("background: white;")
def __init__(self, base, *args, **kwargs): TritonWidget.__init__(self, base, *args, **kwargs) self.sharedSecret = None self.identitySecret = None self.steamId = None self.type = Globals.SteamAuth self.setWindowTitle('Add Steam') self.setBackgroundColor(self, Qt.white) self.boxLayout = QVBoxLayout(self) self.boxLayout.setContentsMargins(20, 20, 20, 20) self.nameWidget = TextboxWidget(base, 'Name:') self.steamIdWidget = TextboxWidget(base, 'Steam ID:') self.sharedWidget = TextboxWidget(base, 'Shared Secret:') self.identityWidget = TextboxWidget(base, 'Identity Secret:') self.verifyLabel = QLabel() self.verifyLabel.setText('Click the Verify button to check the first code.') self.verifyLabel.setFont(QFont('Helvetica', 10)) self.verifyBox = QLineEdit() self.verifyBox.setFixedWidth(150) self.verifyBox.setFont(QFont('Helvetica', 10)) self.verifyBox.setEnabled(False) palette = QPalette() palette.setColor(QPalette.Text, Qt.black) self.verifyBox.setPalette(palette) self.verifyBox.setAlignment(Qt.AlignCenter) self.verifyButton = QPushButton('Verify') self.verifyButton.clicked.connect(self.checkVerify) self.verifyButton.setFixedWidth(150) self.addButton = QPushButton('OK') self.addButton.clicked.connect(self.add) self.boxLayout.addWidget(self.nameWidget) self.boxLayout.addWidget(self.steamIdWidget) self.boxLayout.addWidget(self.sharedWidget) self.boxLayout.addWidget(self.identityWidget) self.boxLayout.addSpacing(10) self.boxLayout.addWidget(self.verifyLabel) self.boxLayout.addWidget(self.verifyBox, 0, Qt.AlignCenter) self.boxLayout.addWidget(self.verifyButton, 0, Qt.AlignCenter) self.boxLayout.addSpacing(10) self.boxLayout.addWidget(self.addButton, 0, Qt.AlignRight) self.setFixedSize(self.sizeHint()) self.center() self.show()
def setup_editor(self): variable_format = QTextCharFormat() variable_format.setFontWeight(QFont.Bold) variable_format.setForeground(Qt.blue) self._highlighter.add_mapping("\\b[A-Z_]+\\b", variable_format) single_line_comment_format = QTextCharFormat() single_line_comment_format.setBackground(QColor("#77ff77")) self._highlighter.add_mapping("#[^\n]*", single_line_comment_format) quotation_format = QTextCharFormat() quotation_format.setBackground(Qt.cyan) quotation_format.setForeground(Qt.blue) self._highlighter.add_mapping("\".*\"", quotation_format) function_format = QTextCharFormat() function_format.setFontItalic(True) function_format.setForeground(Qt.blue) self._highlighter.add_mapping("\\b[a-z0-9_]+\\(.*\\)", function_format) font = QFont() font.setFamily("Courier") font.setFixedPitch(True) font.setPointSize(10) self._editor = QPlainTextEdit() self._editor.setFont(font) self._highlighter.setDocument(self._editor.document())
def __init__(self, parent=None): QScrollArea.__init__(self) self.setParent(parent) self.text = "" # Set the background colour of the marquee text to white self.setStyleSheet("QScrollArea { background-color: rgba(255, 255, 255, 1)}") # Initialise the base label and text self.label = QLabel() # Set the font for marquee font = QFont() font.setItalic(True) font.setBold(True) font.setPixelSize(25) self.label.setFont(font) # Set the base label as the base widget of QScrollArea self.setWidget(self.label) # Set QScrollBar Policies self.setWidgetResizable(True) self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) # Initialise timer and associated variables, used for marquee effect self.timer = QTimer(self) self.x = 0 self.speed = 0 # Connect a function to the timer, which controls the marquee effect self.timer.timeout.connect(self.updatePos) # TODO: Set a nominal speed self.setSpeed(33)
def refresh_font(self): font = None if self.font_combo.isEnabled(): index = self.font_combo.currentIndex() font_info = self.system_fonts[index] if font_info: font = QFont() font.setFamily(font_info[2]) font.setBold(font_info[3].lower().find("bold") > -1) else: if self.custom_family: font = QFont(self.custom_family) if font: font.setPointSize(Globals.config.get(Globals.UserData.font_size)) self.input_edit.setFont(font)
def showPassword(self): font = QFont('Helvetica', 13, weight=QFont.Bold) font.setLetterSpacing(QFont.PercentageSpacing, 110) self.passLabel.setText(self.getValue()) self.passLabel.setFont(font) self.passLabel.enableEdit() self.showButton.hide() self.timerProgress.show() self.timerEnd = time.time() + 15 if not self.timer: self.timerProgress.setValue(100) self.timer = QTimer() self.timer.timeout.connect(self.updateProgress) self.timer.start(100)
def add_breakdown_series(self, breakdown_series, color): font = QFont("Arial", 8) # add breakdown series as a slice to center pie main_slice = MainSlice(breakdown_series) main_slice.setName(breakdown_series.name()) main_slice.setValue(breakdown_series.sum()) self.main_series.append(main_slice) # customize the slice main_slice.setBrush(color) main_slice.setLabelVisible() main_slice.setLabelColor(Qt.white) main_slice.setLabelPosition(QtCharts.QPieSlice.LabelInsideHorizontal) main_slice.setLabelFont(font) # position and customize the breakdown series breakdown_series.setPieSize(0.8) breakdown_series.setHoleSize(0.7) breakdown_series.setLabelsVisible() for pie_slice in breakdown_series.slices(): color = QColor(color).lighter(115) pie_slice.setBrush(color) pie_slice.setLabelFont(font) # add the series to the chart self.addSeries(breakdown_series) # recalculate breakdown donut segments self.recalculate_angles() # update customize legend markers self.update_legend_markers()
def __init__(self, parent: QWidget): # , scroll_bar: QScrollBar, statusBar: QLabel super().__init__(parent=parent) self.line_height = 18 self.byte_width = 25 self.bytes_per_line = settings.get_bytes_per_line() self.label_offset_x = 5 self.label_length = 100 self.is_dragging_to_select = False self.display_data: List[DisplayByte] = [] self.display_labels: List[str] = [] # TODO make configurable self.font = QFont('DejaVu Sans Mono, Courier, Monospace', 12) self.label_color = QColor(128, 128, 128) self.byte_color = QColor(210, 210, 210) self.selection_color = QPen(QColor(97, 175, 239)) self.selection_color.setWidth(2) self.annotation_pen = QPen(QColor(0, 0, 0), 2) self.enabled_constraint_pen = QPen(QColor(255, 80, 0), 2) self.disabled_constraint_pen = QPen(QColor(130, 40, 0), 2) # Make this widget focussable on click, so that we can reduce the context of the shortcut, so that multiple shortcuts are possible in the same window self.setFocusPolicy(Qt.FocusPolicy.ClickFocus)
def paint(self, painter, option, index): super(Delegate, self).paint(painter, option, index) # HOVER if option.state & QStyle.State_MouseOver: painter.fillRect(option.rect, QColor("#F1F1F1")) else: painter.fillRect(option.rect, Qt.transparent) # SELECTED if option.state & QStyle.State_Selected: painter.fillRect(option.rect, QColor("#F1F1F1")) # DRAW ICON icon = QPixmap() icon.load(index.data()[1]) icon = icon.scaled(24, 24, Qt.IgnoreAspectRatio, Qt.SmoothTransformation) left = 24 # margin left icon_pos = QRect(left, ((self._height - icon.height()) / 2) + option.rect.y(), icon.width(), icon.height()) painter.setRenderHint(QPainter.Antialiasing) painter.setRenderHint(QPainter.SmoothPixmapTransform) painter.drawPixmap(icon_pos, icon) # DRAW TEXT font = QFont("Roboto Black", 12) text_pos = QRect((left * 2) + icon.width(), option.rect.y(), option.rect.width(), option.rect.height()) painter.setFont(font) painter.setPen(Qt.black) painter.drawText(text_pos, Qt.AlignVCenter, index.data()[0])
def update(self): for i, fact in enumerate(self.game.factories): img = QPixmap('pictures/factory1.png') self.money[i].setText(str(fact.money)) if i == self.game.cur_factory: self.money[i].setFont(QFont('Times', 24, QFont.Bold)) img = img.scaled(280, 280, QtCore.Qt.KeepAspectRatio) else: self.money[i].setFont(QFont('Times', 14)) img = img.scaled(200, 200, QtCore.Qt.KeepAspectRatio) self.pictures[i].setPixmap(img) self.level.setText(f'Уровень: {self.game.cur_level}') self.river.setText( f'Процент загрязнения реки: {self.game.river.mud_level}%')