def do_mouseDoubleClick(self, point): ##鼠标双击 pt = self.__view.mapToScene(point) # 转换到Scene坐标,QPointF item = self.__scene.itemAt(pt, self.__view.transform()) # 获取光标下的绘图项 if item is None: return className = str(type(item)) # 将类名称转换为字符串 if className.find("QGraphicsRectItem") >= 0: # 矩形框 self.__setBrushColor(item) elif className.find( "QGraphicsEllipseItem") >= 0: # 椭圆和圆都是 QGraphicsEllipseItem self.__setBrushColor(item) elif className.find("QGraphicsPolygonItem") >= 0: # 梯形和三角形 self.__setBrushColor(item) elif className.find("QGraphicsLineItem") >= 0: # 直线,设置线条颜色 pen = item.pen() color = item.pen().__color() color = QColorDialog.getColor(color, self, "选择线条颜色") if color.isValid(): pen.setColor(color) item.setPen(pen) elif className.find("QGraphicsTextItem") >= 0: # 文字,设置字体 font = item.font() font, OK = QFontDialog.getFont(font) if OK: item.setFont(font)
def fontButtonClicked(self): ok = True font = QFontDialog.getFont(self) if font[1]: self.changeFontButton.setText('{0} {1}'.format(font[0].family(), font[0].pointSize())) self.fontChangeTrigger.emit(font[0])
def open_dialog(self): response, font = QFontDialog.getFont( self.last_font, parent=self.ui, title='Configuração da fonte.', ) if response: self.label.setText(f'Fonte selecionada: {font.family()}') self.label.setFont(font) self.last_font = font
def font_app(self, checked): (ok, font) = QFontDialog.getFont(self) if ok: self.widget.setFont(font) self.widget.test_widget.formula.setFont( QFont(font.family(), font.pointSize() + 8)) self.widget.test_widget.answer.setFont( QFont(font.family(), font.pointSize() + 8))
def setFont_(self): font, ok = QFontDialog.getFont() if ok: GlobalVars.CurrentFont = font if GlobalVars.CurrentDocument.SelBlocks: # 处于选中状态 for block in GlobalVars.CurrentDocument.SelBlocks: if hasattr(block, "setFont_"): block.setFont_(font) else: if hasattr(GlobalVars.CurrentBlock, "setFont_"): GlobalVars.CurrentBlock.setFont_(font)
def chooseFont(self): """ Selecione a fonte do texto """ atual = self.tedit.currentFont() font, ok = QFontDialog.getFont(atual, self, options=QFontDialog.DontUseNativeDialog) if ok: self.tedit.setCurrentFont(font)
def getFont(self): status, font = QFontDialog.getFont() if status: self.font = QFontInfo(font) self.fontName = self.font.family() self.fontSize = self.font.pointSize() self.fontBold = self.font.bold() self.fontItalic = self.font.italic() self.fontUnderline = self.font.underline() self.fontStrikeout = self.font.strikeOut() fontBold = '粗体' if self.fontBold else '' fontItalic = '斜体' if self.fontItalic else '' fontUnderline = '下划线' if self.fontUnderline else '' fontStrikeOut = '删除线' if self.fontStrikeout else '' self.fontSelect.setText('%s%s号%s%s%s%s' % (self.fontName, self.fontSize, fontBold, fontItalic, fontUnderline, fontStrikeOut))
def openFontDialog(self): ok, font = QFontDialog.getFont() if ok: self.label_10.setFont(font) self.label_11.setFont(font) self.label_12.setFont(font) self.label_13.setFont(font) self.label_14.setFont(font) self.label_30.setFont(font) self.label_29.setFont(font) self.label_10.adjustSize() self.label_11.adjustSize() self.label_12.adjustSize() self.label_13.adjustSize() self.label_14.adjustSize() self.label_30.adjustSize() self.label_29.adjustSize()
def fontChange(self): (font, ok) = QFontDialog.getFont(QFont("Helvetica[Cronyx]", 10), self) if ok: self.textEdit.setCurrentFont(font)
def changeFont(self): ok, font = QFontDialog.getFont(self) if ok: self.textedit.setFont(font)
def set_markdown_font(self): (ok, font) = QFontDialog.getFont(self.md_text_edit.font(), self, "Markdown Font") self.md_text_edit.setFont(font)
def actionFont_triggered(self): font = QFontDialog.getFont() self.textEdit.setFont(font[1])
def fontDialog(self): (ok, font) = QFontDialog.getFont() if ok: self.textEdit.setFont(font)
def change_font(self, name): """Changes the font used throughout the application. Currently triggered via a menu action. name: Used to specify whether the font should be resized or changed to a different font family. """ # Get the context. if name == "": # Case 1: Default Change Font menu option. ok, f = QFontDialog.getFont(self.window) start = False elif name == "+" or name == "-": # Case 2: Increase/Decrease font size menu option. f = self.ui.table_PS.font() f_size = f.pointSize() + 2 if name == "+" else f.pointSize() - 2 f = f.toString().split(",")[0] f = QFont(f, f_size) ok, start = True, False else: if type(name) == str: # Case 3.1: Init with pref.json f = name.split("%") f = QFont(f[0], int(f[1])) else: # Case 3.2: Init without pref.json (first launch). f = name ok, start = True, True if ok: # Change the font for everything (within reason). self.font = f new_font = f big_font = QFont(f.toString().split(",")[0], f.pointSize() + 6) # self.ui.tabs.setFont(new_font) # PS tab self.ui.table_PS.setFont(new_font) self.ui.table_PS.horizontalHeader().setFont(new_font) self.ui.text_browser_PS.setFont(big_font) self.ui.refresh_pch_btn.setFont(new_font) self.ui.btn_dwn_all.setFont(new_font) # Local tab self.ui.table_local.setFont(new_font) self.ui.table_local.horizontalHeader().setFont(new_font) self.ui.text_browser_local.setFont(big_font) self.ui.back_btn_local.setFont(new_font) self.ui.check_for_updates_btn.setFont(new_font) self.ui.update_patch_notes.setFont(new_font) self.ui.btn_show_routing.setFont(new_font) self.ui.page_label.setFont(new_font) self.ui.back_btn.setFont(new_font) self.ui.btn_next_page.setFont(new_font) self.ui.btn_prev_page.setFont(new_font) # SD tab self.ui.sd_tree.setFont(new_font) self.ui.table_sd_left.setFont(new_font) self.ui.table_sd_left.horizontalHeader().setFont(new_font) self.ui.table_sd_left.verticalHeader().setFont(new_font) self.ui.table_sd_right.setFont(new_font) self.ui.table_sd_right.horizontalHeader().setFont(new_font) self.ui.table_sd_right.verticalHeader().setFont(new_font) self.ui.delete_folder_sd_btn.setFont(new_font) self.ui.set_export_dir_btn.setFont(new_font) self.ui.import_all_btn.setFont(new_font) self.ui.import_all_ver_btn.setFont(new_font) # Folders tab self.ui.table_bank_local.setFont(new_font) self.ui.table_bank_local.horizontalHeader().setFont(new_font) self.ui.table_bank_left.setFont(new_font) self.ui.text_browser_viz.setFont(new_font) self.ui.table_bank_left.horizontalHeader().setFont(new_font) self.ui.table_bank_left.verticalHeader().setFont(new_font) self.ui.table_bank_right.setFont(new_font) self.ui.table_bank_right.horizontalHeader().setFont(new_font) self.ui.table_bank_right.verticalHeader().setFont(new_font) self.ui.back_btn_bank.setFont(new_font) self.ui.btn_save_bank.setFont(new_font) self.ui.btn_load_bank.setFont(new_font) self.ui.btn_clear_bank.setFont(new_font) self.ui.btn_export_bank.setFont(new_font) self.ui.text_browser_bank.setFont(big_font) if not start: for i in range(self.ui.table_PS.rowCount()): self.ui.table_PS.cellWidget(i, 0).setFont(new_font) self.ui.table_PS.cellWidget(i, 4).setFont(new_font) if self.ui.table_local.cellWidget(0, 0) is not None: for i in range(self.ui.table_local.rowCount()): self.ui.table_local.cellWidget(i, 0).setFont(new_font) self.ui.table_local.cellWidget(i, 4).setFont(new_font) self.ui.table_local.cellWidget(i, 5).setFont(new_font) for i in range(32): # Need trys here in case the table does not have a # cell widget there yet. try: self.ui.table_sd_left.cellWidget(i, 1).setFont(new_font) except AttributeError: pass try: self.ui.table_sd_left.cellWidget(i, 2).setFont(new_font) except AttributeError: pass try: self.ui.table_sd_right.cellWidget(i, 1).setFont(new_font) except AttributeError: pass try: self.ui.table_sd_right.cellWidget(i, 2).setFont(new_font) except AttributeError: pass try: self.ui.table_bank_left.cellWidget(i, 1).setFont(new_font) except AttributeError: pass try: self.ui.table_bank_left.cellWidget(i, 2).setFont(new_font) except AttributeError: pass try: self.ui.table_bank_right.cellWidget(i, 1).setFont(new_font) except AttributeError: pass try: self.ui.table_bank_right.cellWidget(i, 2).setFont(new_font) except AttributeError: pass if self.ui.table_bank_local.cellWidget(0, 0) is not None: for i in range(self.ui.table_bank_local.rowCount()): self.ui.table_bank_local.cellWidget(i, 0).setFont(new_font)
def showDialog(self): font, ok = QFontDialog.getFont() if ok: # self.lbl.setFont(font) self.lbl.setFont(font)
def font_choice(self) -> None: valid, font = QFontDialog.getFont() if valid is True: self.styleChoice.setFont(font)
def showDialog(self): ok, font = QFontDialog.getFont() if ok: self.lbl.setFont(font)
def showDialog(self): font, OK = QFontDialog.getFont() if OK: self.label.setFont(font)