def seed_img(self, is_seed = True): if is_seed: try: cseed = self.get_seed() except UserCancelled: return except InvalidPassword as e: self.d.show_error(str(e)) return if not cseed: self.d.show_message(_("This wallet has no seed")) return txt = cseed.upper() else: txt = self.txt.upper() img = QImage(self.SIZE[0], self.SIZE[1], QImage.Format_Mono) bitmap = QBitmap.fromImage(img, Qt.MonoOnly) bitmap.fill(Qt.white) painter = QPainter() painter.begin(bitmap) QFontDatabase.addApplicationFont(os.path.join(os.path.dirname(__file__), 'SourceSansPro-Bold.otf') ) if len(txt) < 102 : fontsize = 15 linespace = 15 max_letters = 17 max_lines = 6 max_words = 3 else: fontsize = 12 linespace = 10 max_letters = 21 max_lines = 9 max_words = int(max_letters/4) font = QFont('Source Sans Pro', fontsize, QFont.Bold) font.setLetterSpacing(QFont.PercentageSpacing, 100) font.setPixelSize(fontsize) painter.setFont(font) seed_array = txt.split(' ') for n in range(max_lines): nwords = max_words temp_seed = seed_array[:nwords] while len(' '.join(map(str, temp_seed))) > max_letters: nwords = nwords - 1 temp_seed = seed_array[:nwords] painter.drawText(QRect(0, linespace*n , self.SIZE[0], self.SIZE[1]), Qt.AlignHCenter, ' '.join(map(str, temp_seed))) del seed_array[:nwords] painter.end() img = bitmap.toImage() if (self.rawnoise == False): self.make_rawnoise() self.make_cypherseed(img, self.rawnoise, False, is_seed) return img
def __init__(self, name, currentValue): super(QDialog, self).__init__() self.setWindowTitle(name) self.resize(800, 600) self.codeEdit = QsciScintilla() self.codeEdit.setText(currentValue) fixedWidthFont = QFontDatabase.systemFont(QFontDatabase.FixedFont) self.codeEdit.setFont(fixedWidthFont) fontmetrics = QFontMetrics(fixedWidthFont) self.codeEdit.setMarginWidth(0, fontmetrics.width("000")) self.codeEdit.setMarginLineNumbers(0, True) self.codeEdit.setMarginsBackgroundColor(QColor("#cccccc")) self.codeEdit.setBraceMatching(QsciScintilla.SloppyBraceMatch) self.codeEdit.setCaretLineVisible(True) self.codeEdit.setCaretLineBackgroundColor(QColor("#ffe4e4")) lexer = QsciLexerPython() lexer.setDefaultFont(fixedWidthFont) self.codeEdit.setLexer(lexer) self.codeEdit.SendScintilla(QsciScintilla.SCI_SETHSCROLLBAR, 0) self.codeEdit.setUtf8(True) self.codeEdit.setTabWidth(4) self.codeEdit.setIndentationsUseTabs(True) self.codeEdit.setIndentationGuides(True) self.codeEdit.setTabIndents(True) self.codeEdit.setAutoIndent(True) self.cancelButton = QPushButton('Cancel') self.cancelButton.clicked.connect(self.cancel) self.acceptButton = QPushButton('Accept') self.acceptButton.clicked.connect(self.accept) self.pythonButton = QRadioButton('Python') self.pythonButton.setChecked(True) self.pythonButton.clicked.connect(self.pythonClicked) self.cppButton = QRadioButton('C++') self.cppButton.clicked.connect(self.cppClicked) hLayout0 = QHBoxLayout() hLayout0.addWidget(self.pythonButton) hLayout0.addWidget(self.cppButton) container0 = QWidget() container0.setLayout(hLayout0) verticalLayout = QVBoxLayout() verticalLayout.addWidget(container0) verticalLayout.addWidget(self.codeEdit) container = QWidget() hLayout =QHBoxLayout() hLayout.addWidget(self.cancelButton) hLayout.addWidget(self.acceptButton) container.setLayout(hLayout) verticalLayout.addWidget(container) self.setLayout(verticalLayout) self.language = 'python'
def create_encrypt_tab(self): w = QWidget() layout = QGridLayout(w) message_e = QTextEdit() layout.addWidget(QLabel(_('Message')), 1, 0) layout.addWidget(message_e, 1, 1) layout.setRowStretch(2, 2) recipient_e = QTextEdit() recipient_e.setPlaceholderText('''-----BEGIN PGP PUBLIC KEY BLOCK-----''') recipient_e.setFont(QFontDatabase.systemFont(QFontDatabase.FixedFont)) layout.addWidget(QLabel(_('Recipient key')), 2, 0) layout.addWidget(recipient_e, 2, 1) encrypted_e = QTextEdit() encrypted_e.setFont(QFontDatabase.systemFont(QFontDatabase.FixedFont)) layout.addWidget(QLabel(_('Encrypted')), 3, 0) layout.addWidget(encrypted_e, 3, 1) layout.setRowStretch(3, 1) hbox = QHBoxLayout() b = QPushButton(_('Encrypt')) b.clicked.connect(lambda: self.do_encrypt(message_e, recipient_e, encrypted_e)) hbox.addWidget(b) b = QPushButton(_('Decrypt')) b.clicked.connect(lambda: self.do_decrypt(encrypted_e, message_e)) hbox.addWidget(b) layout.addLayout(hbox, 4, 1) return w
def updateStyle(self, fontStyle): fontDatabase = QFontDatabase() oldStrategy = self.displayFont.styleStrategy() self.displayFont = fontDatabase.font(self.displayFont.family(), fontStyle, self.displayFont.pointSize()) self.displayFont.setStyleStrategy(oldStrategy) self.squareSize = max(24, QFontMetrics(self.displayFont).xHeight() * 3) self.adjustSize() self.update()
def __init__(self, app): super().__init__() self.setupUi(self) self.setAcceptDrops(True) # Server self.server = QLocalServer() self.server.listen("blender-launcher-server") self.server.newConnection.connect(self.new_connection) # Global scope self.app = app self.favorite = None self.status = "None" self.app_state = AppState.IDLE self.cashed_builds = [] self.notification_pool = [] self.windows = [self] self.manager = PoolManager(num_pools=50, maxsize=10) self.timer = None self.started = True self.latest_tag = "" self.new_downloads = False # Setup window self.setWindowTitle("Blender Launcher") self.app.setWindowIcon( QIcon(taskbar_icon_paths[get_taskbar_icon_color()])) # Setup font QFontDatabase.addApplicationFont( ":/resources/fonts/OpenSans-SemiBold.ttf") self.font = QFont("Open Sans SemiBold", 10) self.font.setHintingPreference(QFont.PreferNoHinting) self.app.setFont(self.font) # Setup style file = QFile(":/resources/styles/global.qss") file.open(QFile.ReadOnly | QFile.Text) self.style_sheet = QTextStream(file).readAll() self.app.setStyleSheet(self.style_sheet) # Check library folder if is_library_folder_valid() is False: self.dlg = DialogWindow( self, title="Information", text="First, choose where Blender<br>builds will be stored", accept_text="Continue", cancel_text=None, icon=DialogIcon.INFO) self.dlg.accepted.connect(self.set_library_folder) else: create_library_folders(get_library_folder()) self.draw()
def __init__(self): super().__init__() follow_bk_pic_path = './source/pic/follow_bk.png' search_1_pic_path = './source/pic/next.png' search_2_pic_path = './source/pic/next_1.png' search_3_pic_path = './source/pic/next_2.png' hgzy_font_path = './source/font/HGZYT_CNKI.TTF' rem_ico_path = './source/pic/rem.png' self.pix = QPixmap(follow_bk_pic_path) self.resize(self.pix.width(), self.pix.height()) self.pix = self.pix.scaled(int(self.pix.width()), int(self.pix.height())) self.setMask(self.pix.mask()) screen = QDesktopWidget().screenGeometry() self.move((screen.width() - self.pix.width()) / 2, (screen.height() - self.pix.height()) / 2) self.setWindowFlags( Qt.FramelessWindowHint) # | QtCore.Qt.WindowStaysOnTopHint self.setAttribute(Qt.WA_TranslucentBackground) # 窗口透明抗锯齿 rem_icon = QIcon(QPixmap(rem_ico_path)) self.setWindowIcon(rem_icon) self.m_DragPosition = None fontId = QFontDatabase.addApplicationFont(hgzy_font_path) fontName = QFontDatabase.applicationFontFamilies(fontId)[0] self.followlist = QDListWidget(self) self.followlist.setObjectName('FollowListWidget') self.followlist.setGeometry(17, 280, self.pix.width() - 34, self.pix.height() - 280 - 50) self.followlist.setStyleSheet( '#FollowListWidget{background:transparent;}') self.followlist.setFont(QFont(fontName, 15, QFont.Light)) self.followlist.setIconSize(QSize(100, 100)) self.ShowData() self.search = QPushButton(self) self.search.setObjectName('Search') self.search.setStyleSheet( "#Search{border-image: url(%s)}" "#Search:hover{border-image: url(%s)}" "#Search:pressed{border-image: url(%s)}" % (search_1_pic_path, search_2_pic_path, search_3_pic_path)) self.search.setGeometry(self.pix.width() - self.search.width(), self.pix.height() - self.search.height() - 10, self.search.width() - 20, self.search.height()) self.choose = Choose(self.x() + self.width(), self.y() + self.height()) self.choose_show = False self.choose_info = {} self.search.clicked.connect(self.SearchBt) self.detail = Detail(self.x(), self.y()) self.detail_show = False self.followlist.itemDoubleClicked.connect(self.DetailBt) self.followlist.installEventFilter(self) self.rightclick = FollowRightclick() self.followshow = False
def load_app_font(self): ''' 系统字体 ''' fontDB = QFontDatabase() font_path = Config().font_path + '/Microsoft-YaHei.ttf' fontDB.addApplicationFont(font_path) font = QFont('Microsoft YaHei') font.setPixelSize(12) font.setWeight(50) return font
def __init__(self, parent): super(CColorStraw, self).__init__(parent) QFontDatabase.addApplicationFontFromData(QByteArray.fromBase64(FONT)) font = self.font() or QFont() font.setFamily('iconfont') self.setFont(font) self.setToolTip('Нарисуйте цвет экрана') self._scaleWindow = ScaleWindow() # Не забудьте сначала показать его, а затем спрятать. self._scaleWindow.show() self._scaleWindow.hide()
def __init__(self, flags, networkManager, sessionData, taskQueue): app = QApplication(sys.argv) app.setStyle("Fusion") QFontDatabase.addApplicationFont("Resources/Fonts/Adequate.ttf") app.setStyleSheet(open('style.qss', "r").read()) # If user is about to close window app.aboutToQuit.connect(self.closeEvent) loginApp = LoginWindow(flags, networkManager, sessionData, taskQueue) loginApp.show() # Execute the app mainloop app.exec_()
def __init__(self): super(Window, self).__init__() BASE_DIR = os.path.dirname(os.path.abspath(__file__)) font_id = QFontDatabase.addApplicationFont( os.path.join(BASE_DIR, "../../resources/font/fontawesome-webfont.ttf")) if font_id is not -1: fontName = QFontDatabase.applicationFontFamilies(font_id)[0] self.font = QFont(fontName, 32) self.home()
def add_fonts(self): fontdir = os.path.join(system.execpath, "fonts") # filenames = os.listdir(fontdir) filenames = ["fa-solid-900.ttf"] for filename in filenames: suffix = filename.split(".")[-1].lower() if suffix in ["ttf"]: filepath = os.path.join(fontdir, filename) fontId = QFontDatabase.addApplicationFont(filepath) print("Added font:", QFontDatabase.applicationFontFamilies(fontId))
def __init__(self): self.STRETCH = "STRETCH" self.STRETCHi = "STRETCHi" self.defaultSectionIcon = "client/static/assets/section.png" self.CursorPointer = QCursor(Qt.PointingHandCursor) self.CursorEdit = QCursor(Qt.IBeamCursor) self.sWH = GetSystemMetrics(0), GetSystemMetrics(1) self.RobotoLight = QFontDatabase.applicationFontFamilies( QFontDatabase.addApplicationFont(fontsPath.RobotoLight))[0] self.RobotoBold = QFontDatabase.applicationFontFamilies( QFontDatabase.addApplicationFont(fontsPath.RobotoBold))[0] QToolTip.setFont(QFont(self.RobotoLight, 10))
def configure_qt_app(self): # pragma: no cover self.qt_app = QApplication(sys.argv) self.qt_app.setEffectEnabled(QtCore.Qt.UI_AnimateCombo, False) self.qt_app.setEffectEnabled(QtCore.Qt.UI_AnimateMenu, False) self.qt_app.setEffectEnabled(QtCore.Qt.UI_AnimateToolBox, False) self.qt_app.setEffectEnabled(QtCore.Qt.UI_AnimateTooltip, False) self.font_db = QFontDatabase() for font in (Path(__file__).parent / "resources" / "fonts").glob("*.ttf"): self.font_db.addApplicationFont(str(font)) self.qt_app.setStyleSheet(default_stylesheet())
def __loadFont(self): osFamily = sys.platform if osFamily == 'darwin': fontVariations = ["Thin", "ThinItalic"] self.__defaultFontSize = 14 else: fontVariations = ["Light", "LightItalic"] self.__defaultFontSize = -1 for variation in fontVariations: QFontDatabase.addApplicationFont(self.__path + \ "/PycomStyle/Fonts/RobotoMono-" + variation + ".ttf")
def load_font(self): if QApplication.instance() is None: logger.warning('No QApplication instance found') return font_file = QFile(':font/awesome') if font_file.open(QFile.ReadOnly): idf = QFontDatabase.addApplicationFontFromData( QByteArray(font_file.readAll())) font_file.close() self.font_name = QFontDatabase.applicationFontFamilies(idf)[0]
def __init__(self, parent): super(CColorStraw, self).__init__(parent) QFontDatabase.addApplicationFontFromData(QByteArray.fromBase64(FONT)) font = self.font() or QFont() font.setFamily('iconfont') self.setFont(font) self.setText('') self.setToolTip('吸取屏幕颜色') self._scaleWindow = ScaleWindow() # 一定要先显示再隐藏,否则QDialog情况下第一次会卡死 self._scaleWindow.show() self._scaleWindow.hide()
def __init__(self, parent=None): super(MainWindow, self).__init__(parent) self.setupUi(self) cwd = os.getcwd() img = r'resources\img\packing.ico' font = r'resources\font\*.ttf' self.setWindowIcon(QIcon(os.path.join(cwd, img))) QFontDatabase.addApplicationFont(os.path.join(cwd, font)) self.ms = MySignal() self.signal_action() self.setui()
def display_content(self): # layout_main = QVBoxLayout() layout_main.setAlignment(Qt.AlignCenter) self.setLayout(layout_main) self.layouts.append(layout_main) # fonts = QFontDatabase() fonts.addApplicationFont('Fonts/Raleway/Raleway-ExtraLight.ttf') fonts.addApplicationFont('Fonts/OpenSans/OpenSans-Light.ttf') # title = QLabel("Eight Puzzle") title.setStyleSheet('font-size: 52px; color: #CECFD4;') title.setFont(QFont('Raleway')) layout_main.addWidget(title) layout_main.addSpacerItem(QSpacerItem(0, 12)) # layout_tiles = QGridLayout() layout_tiles.setAlignment(Qt.AlignCenter) layout_main.addLayout(layout_tiles) for index in range(9): tile = QPushButton(str(self.puzzle.state[index])) tile.setStyleSheet('background-color: #879AA4;' 'color: #CECFD4; font-size: 32px;') tile.setFont(QFont('Open Sans')) tile.setFixedSize(75, 75) tile.setEnabled(False) tile.setFocusPolicy(Qt.NoFocus) layout_tiles.addWidget(tile, index / 3, index % 3) if self.puzzle.state[index] is '0': tile.setVisible(False) self.tiles.append(tile) self.layouts.append(layout_tiles) layout_main.addSpacerItem(QSpacerItem(0, 25)) # layout_buttons = QGridLayout() layout_buttons.setAlignment(Qt.AlignCenter) layout_main.addLayout(layout_buttons) for index in range(3): button = QPushButton(['Shuffle', 'Solve', 'Quit'][index]) button.setStyleSheet('background-color: #CECFD4;' 'color: #363B57; font-size: 18px;') button.setFont(QFont('Raleway')) button.setFixedSize(90, 40) button.setFocusPolicy(Qt.NoFocus) layout_buttons.addWidget(button, 0, index) self.buttons.append(button) self.layouts.append(layout_buttons) layout_main.addSpacerItem(QSpacerItem(0, 10))
def setup_ui(self): shadow_effect = QGraphicsDropShadowEffect() shadow_effect.setBlurRadius(1) shadow_effect.setColor(QColor(200, 200, 200)) shadow_effect.setOffset(0, 0) self.shadow_effect = shadow_effect self.setGraphicsEffect(self.shadow_effect) self.setStyleSheet( "MFrame{margin:0px;padding:0px;border:1px solid;" "border-color:rgb(220,220,220);background-color:white}") self.setGeometry(100, 100, 1366, 768) self.top_bar = MFrame(self) self.top_bar.setGeometry(0, 0, 1366, 80) font_id = QFontDatabase.addApplicationFont( "font/Roboto-Regular-14.ttf") font_name = QFontDatabase.applicationFontFamilies(font_id)[0] font = QFont(font_name, 14, 1) config_label = QLabel("Configuration", self.top_bar) config_label.setGeometry(1030, 1, 150, 78) config_label.setStyleSheet("color: rgb(100, 100, 100)") config_label.setFont(font) self.line_label = QLabel(self.top_bar) self.line_label.setStyleSheet("background-color:rgb(80, 80, 80)") self.line_label.setGeometry(50, 76, 200, 4) view_box = MFrame(self) view_box.setGeometry(0, 80, 1000, 688) view_box.setStyleSheet("border-top:none;background-color:#fafafa") self.view_box = view_box self.fillViewBox() self.buildupTopBtns() self.line_label.raise_() options = MFrame(self) options.setGeometry(1000, 80, 366, 688) options.setStyleSheet("border-top:none;border-left:none;") option_label = QLabel("Options", options) option_label.setGeometry(30, 30, 150, 60) font = QFont(font_name, 13, 1) option_label.setStyleSheet("color: rgb(100, 100, 100)") option_label.setFont(font) self.shadow_animation = QPropertyAnimation(self) self.shadow_animation.setTargetObject(self.shadow_effect) self.shadow_animation.setPropertyName(b"blurRadius") self.shadow_animation.setStartValue(1) self.shadow_animation.setEndValue(40) self.shadow_animation.setDuration(500)
def setStyle(self, background_color="#555555", style="mac", height=80, logo=None, title=None): # 设定几何尺寸 width = self._rootFrame.width() self.setGeometry(0, 0, width, height) # 设定属性 minimize_btn = QPushButton(parent=self) minimize_btn.setGeometry(width - 100, int(height / 2 - 12), 24, 24) minimize_btn.setFlat(True) close_btn = QPushButton(parent=self) close_btn.setGeometry(width - 50, int(height / 2 - 12), 24, 24) close_btn.setFlat(True) if style == "mac": minimize_btn.setStyleSheet( "border-image: url('assests/minimize.svg')") close_btn.setStyleSheet("border-image: url('assests/close.svg')") else: # TODO pass self.setStyleSheet( "background-color:{};".format(background_color) + "border-bottom-left-radius:0px;border-bottom-right-radius:0px") if logo: logo_label = QLabel(self) logo_label.setGeometry(20, height / 2 - 24, 48, 48) logo_label.setStyleSheet("border-image: url({})".format(logo)) if not logo and title: title_label = QLabel(title, self) title_label.setGeometry(20, 0, 200, self.height()) title_label.setStyleSheet("color:white;") fontID = QFontDatabase.addApplicationFont( "font/Roboto-Regular-14.ttf") fontName = QFontDatabase.applicationFontFamilies(fontID)[0] font = QFont(fontName, 14, 500) title_label.setFont(font) elif logo and title: title_label = QLabel(title, self) title_label.setGeometry(100, 0, 200, self.height()) title_label.setStyleSheet("color:white;") fontID = QFontDatabase.addApplicationFont( "font/Roboto-Regular-14.ttf") fontName = QFontDatabase.applicationFontFamilies(fontID)[0] font = QFont(fontName, 16, 500) title_label.setFont(font) close_btn.clicked.connect(self._rootFrame.close) minimize_btn.clicked.connect(self._rootFrame.showMinimized)
def findStyles(self, font): fontDatabase = QFontDatabase() currentItem = self.styleCombo.currentText() self.styleCombo.clear() for style in fontDatabase.styles(font.family()): self.styleCombo.addItem(style) styleIndex = self.styleCombo.findText(currentItem) if styleIndex == -1: self.styleCombo.setCurrentIndex(0) else: self.styleCombo.setCurrentIndex(styleIndex)
def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.setDefaultAppLocale() app_exec_name = 'kwCalcGQ' self.setApplicationVersion('0.2.0') self.setWindowIcon(QIcon(os.path.abspath('class_x24.png'))) self.setApplicationName('{} v {}'.format(app_exec_name.lstrip('kw'), self.applicationVersion())) QFontDatabase.addApplicationFont('Hack-Regular.ttf') self.query_access()
def label_listfonts(session): '''Report available fonts.''' has_graphics = session.main_view.render is not None if not has_graphics: from chimerax.core.errors import LimitationError raise LimitationError( "Unable to do list fonts without being able to render images") from PyQt5.QtGui import QFontDatabase fdb = QFontDatabase() fnames = list(fdb.families()) fnames.sort() session.logger.info('%d fonts available:\n%s' % (len(fnames), '\n'.join(fnames)))
def configure_theme(application): application.setWindowIcon(QIcon(":/icons/httprider.ico")) application.setStyle(Theme()) theme_mode = "dark" if is_dark() else "light" application.style().load_stylesheet(theme_mode) font_db = QFontDatabase() font_db.addApplicationFont(":/fonts/JetBrainsMono-Regular.ttf") current_font: QFont = QFont("JetBrains Mono") current_font.setPointSize(12) application.setFont(current_font)
def __init__(self): super(MainWindow, self).__init__() font_id = QFontDatabase.addApplicationFont("fontawesome-webfont.ttf") if font_id is not -1: font_db = QFontDatabase() self.font_styles = font_db.styles('FontAwesome') self.font_families = QFontDatabase.applicationFontFamilies(font_id) print(self.font_styles, self.font_families) for font_family in self.font_families: self.font = font_db.font(font_family, self.font_styles[0], 18) self.home()
def set_theme(app): # dark theme: # https://gist.githubusercontent.com/mstuttgart/37c0e6d8f67a0611674e08294f3daef7/raw/8502123d9bf8ae9a10be880953c7fc0c1a095a21/dark_fusion.py dark_palette = QPalette() # dark_palette.setColor(QPalette.Window, QColor(53, 53, 53)) dark_palette.setColor(QPalette.Window, QColor(49, 52, 64)) dark_palette.setColor(QPalette.WindowText, Qt.white) # dark_palette.setColor(QPalette.Base, QColor(25, 25, 25)) dark_palette.setColor(QPalette.Base, QColor(38, 40, 49)) # dark_palette.setColor(QPalette.AlternateBase, QColor(53, 53, 53)) dark_palette.setColor(QPalette.AlternateBase, QColor(49, 52, 64)) dark_palette.setColor(QPalette.ToolTipBase, Qt.white) dark_palette.setColor(QPalette.ToolTipText, Qt.white) # dark_palette.setColor(QPalette.Text, Qt.white) dark_palette.setColor(QPalette.Text, QColor(222, 226, 247)) # dark_palette.setColor(QPalette.Button, QColor(53, 53, 53)) dark_palette.setColor(QPalette.Button, QColor(49, 52, 64)) dark_palette.setColor(QPalette.ButtonText, Qt.white) dark_palette.setColor(QPalette.BrightText, Qt.red) dark_palette.setColor(QPalette.Link, QColor(42, 130, 218)) # dark_palette.setColor(QPalette.Highlight, QColor(42, 130, 218)) dark_palette.setColor(QPalette.Highlight, QColor(158, 161, 179)) dark_palette.setColor(QPalette.HighlightedText, Qt.black) app.setPalette(dark_palette) app.setStyleSheet( "QToolTip { color: #ffffff; background-color: #2a82da; border: 1px solid white; }" ) app.setStyle("Fusion") # # icon # icon = QIcon() # # icon.addFile('../resources/assets/icon4.ico') # icon.addFile(appctxt.get_resource('assets/icon4.ico')) # # something hacky for windows to show icon in taskbar # myappid = 'biblenavigation.myapp' # arbitrary string # ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID(myappid) # # app.setWindowIcon(icon) # custom font font_db = QFontDatabase() # font_db.addApplicationFont('../assets/Noto_Serif/NotoSerif-Regular.ttf') # font_db.addApplicationFont('../resources/assets/Noto_Sans/NotoSans-Regular.ttf') font_db.addApplicationFont( str(RESOURCE_DIR / 'assets/Noto_Sans/NotoSans-Regular.ttf')) # font = QFont('Noto Serif') font = QFont('Noto Sans') font.setPointSize(10) app.setFont(font)
def __init__(self): self.node = Node(8888, 6768, 'Carbon-Client', protocol='CarbonDock') self.rt = Thread(target=self.refresh, name='Refresher') self.rt.start() self.app = QApplication(['CarbonDock']) self.app.setWindowIcon(QIcon('icon.png')) QFontDatabase.addApplicationFont('main.ttf') self.window = QWidget() self.window.setWindowTitle('CarbonDock') self.window.setGeometry(50, 50, 600, 500) self.window.setStyleSheet( open( os.path.join(os.path.abspath(os.curdir), 'client', 'style.qss'), 'r').read()) self.layout = QVBoxLayout() self.titlebar = QWidget() self.titlebar.setStyleSheet( 'background-color: rgba(0,0,0,0);border-image: null;') self.titlelay = QHBoxLayout() label = QLabel() pixmap = QPixmap('icon.png').scaled(128, 128) label.setPixmap(pixmap) label.setAlignment(Qt.AlignCenter) self.titlelay.addWidget(label) self.title = QLabel('CarbonDock') self.title.setStyleSheet('font: 20pt;') self.title.setAlignment(Qt.AlignCenter) self.titlelay.addWidget(self.title) self.titlebar.setLayout(self.titlelay) self.layout.addWidget(self.titlebar) self.modStats = QWidget() self.modStats.setStyleSheet( 'background-color: rgba(0,0,0,0);border-image: null;') self.modLayout = QVBoxLayout() self.modStats.setLayout(self.modLayout) self.stats = [] self.layout.addWidget(self.modStats) self.window.setLayout(self.layout) self.window.show() self.timer = QTimer() self.timer.setInterval(100) self.timer.setSingleShot(False) self.timer.timeout.connect(self.check_refresh) self.timer.start() self.app.exec_()
def main(): import sys QGuiApplication.setAttribute(Qt.AA_EnableHighDpiScaling) app = QGuiApplication(sys.argv) QFontDatabase.addApplicationFont(":/fonts/fontello.ttf") engine = QQmlApplicationEngine() engine.load(QUrl("qrc:/swipetoremove.qml")) if not engine.rootObjects(): sys.exit(-1) sys.exit(app.exec_())
def createWidget(self): self.setWindowFlag(Qt.FramelessWindowHint) self.setGeometry(self.left, self.top, self.width, self.height) fontDB = QFontDatabase() #fontDB.addApplicationFont("C:/Users/claud/PycharmProjects/BloqAlanna/venv/Scripts/fonts/FakeHope.ttf") fontDB.addApplicationFont("./venv/Scripts/fonts/FakeHope.ttf") ### ******* imprime todas as fontes ****** # # for varriavel in fontDB.families(): # print(varriavel) ### ************************************** ### self.groupBox = QGroupBox("Escolha as Opções") self.groupBox.setFixedHeight(90) self.groupBox.setAlignment(QtCore.Qt.AlignBottom) self.contLabel = QLabel("00:00:00", self) self.contLabel.setAlignment(QtCore.Qt.AlignCenter) self.contLabel.setStyleSheet("QLabel {" "border-radius:20px;" "color: black;background-color: #ffd9b3;" #ffcccc , ffd9b3 "font:45pt 'Fake Hope'}") hboxL = QHBoxLayout() self.pauseButton = QPushButton('&Pause', parent=self) self.pauseButton.setStyleSheet('QPushButton {background-color:"salmon";border-radius:15px}') self.pauseButton.setFixedHeight(40) self.pauseButton.clicked.connect(self.pauseSignal) self.cancelButton = QPushButton("&Close", parent=self) self.cancelButton.setStyleSheet('QPushButton {background-color:#e6e600;border-radius:15px}') self.cancelButton.setFixedHeight(40) self.cancelButton.clicked.connect(self.cancelSignal) self.senhaButton = QPushButton("&Senha", self) self.senhaButton.setStyleSheet('QPushButton {background-color:"pink";border-radius:15px}') self.senhaButton.setFixedHeight(40) self.senhaButton.clicked.connect(self.passSignal) hboxL.addWidget(self.pauseButton) hboxL.addWidget(self.cancelButton) hboxL.addWidget(self.senhaButton) self.groupBox.setLayout(hboxL) vbox = QVBoxLayout() vbox.addWidget(self.contLabel) vbox.addWidget(self.groupBox) self.setLayout(vbox)
def load_font(): dir_path = os.getcwd() + "/src/font/" # robust check, if directory exist if os.path.isdir(dir_path): # read all ttf files within directory font_list = os.listdir(dir_path) font_list = list(filter(lambda x: x.endswith('.ttf'), font_list)) # load font for font in font_list: font_path = dir_path + font db = QFontDatabase() db.addApplicationFont(font_path)
def run_application(config): setup_logging() QCoreApplication.setAttribute(Qt.AA_UseHighDpiPixmaps, True) QCoreApplication.setAttribute(Qt.AA_EnableHighDpiScaling, True) app = QApplication(sys.argv) QFontDatabase.addApplicationFont( resource_path("fonts/Roboto/Roboto-Regular.ttf")) font = QFont("Roboto", FONT_SIZE) QApplication.setFont(font) player = Player(config) player.show() return app.exec_()
def __init__(self, sys_argv): super(App, self).__init__(sys_argv) sys.excepthook = self.handle_exception self.init_logging() self.setAttribute(Qt.AA_EnableHighDpiScaling) QFontDatabase.addApplicationFont(os.path.dirname(os.path.realpath(__file__)) +"\\gui\\misc\\Open_Sans\\OpenSans-Light.ttf") self.setStyle("Fusion") # self.setStyleSheet(CSSThemes().orange_theme()) self.mainModel = MainModel() self.mainWindow = MainWindow(model=self.mainModel) self.mainWindow.setWindowTitle("opt-id") self.mainWindow.show() log.info("This is the MAIN THREAD")
def set_font(font, size=None): if size is None: default_size = 15 size = default_size if font == 'Roboto': id = QFontDatabase.addApplicationFont( "resources/fonts/Roboto-Light.ttf") elif font == 'Antonio': id = QFontDatabase.addApplicationFont( "resource/fonts/Antonio-Regular.ttf") _fontstr = QFontDatabase.applicationFontFamilies(id)[0] font = QFont(_fontstr, size) return font
def materials_theme(): fonts_path = RESOURCE_PATH / 'fonts' / 'roboto' for font in fonts_path.iterdir(): if font.suffix == '.ttf': QFontDatabase.addApplicationFont(str(font)) loader = jinja2.FileSystemLoader(str(RESOURCE_PATH)) env = jinja2.Environment(autoescape=False, loader=loader) stylesheet = env.get_template("material.css") theme = { "font_family": "Roboto", "font_size" : "12pt" } return stylesheet.render(**theme)
def __init__(self, app, parent=None): super().__init__(parent) self._app = app # self.setPlaceholderText('搜索歌曲、歌手、专辑、用户;执行 Python 代码等') self.setPlaceholderText('Search library, exec code, or run command.') self.setToolTip('直接输入文字可以进行过滤,按 Enter 可以搜索\n' '输入 >>> 前缀之后,可以执行 Python 代码\n' '输入 $ 前缀可以执行 fuo 命令(未实现,欢迎 PR)') self.setFont(QFontDatabase.systemFont(QFontDatabase.FixedFont)) # 模拟 QLineEdit self.setTabChangesFocus(True) self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.setWordWrapMode(QTextOption.NoWrap) self.setFixedHeight(self.sizeHint().height()) self.setMinimumHeight(25) self._timer = QTimer(self) self._cmd_text = None self._mode = 'cmd' # 详见 _set_mode 函数 self._timer.timeout.connect(self.__on_timeout) self.textChanged.connect(self.__on_text_edited) self._highlighter = Highlighter(self.document()) # self.textEdited.connect(self.__on_text_edited) self.returnPressed.connect(self.__on_return_pressed)
def __init__(self, name, timeValue): super(QDialog, self).__init__() self.resize(300, 150) timeContainer = QGroupBox() timeContainer.setTitle('Time (ms)') self.lineEdit = QLineEdit() fixedWidthFont = QFontDatabase.systemFont(QFontDatabase.FixedFont) self.lineEdit.setFont(fixedWidthFont) self.lineEdit.setText(str(timeValue)) vLayout = QVBoxLayout() vLayout.addWidget(self.lineEdit) self.cancelButton = QPushButton() self.cancelButton.setText('Cancel') self.cancelButton.clicked.connect(self.cancelClicked) self.acceptButton = QPushButton() self.acceptButton.setText('Accept') self.acceptButton.clicked.connect(self.acceptClicked) buttonContainer = QWidget() hLayout = QHBoxLayout() hLayout.addWidget(self.cancelButton) hLayout.addWidget(self.acceptButton) buttonContainer.setLayout(hLayout) vLayout.addWidget(buttonContainer) timeContainer.setLayout(vLayout) vLayout2 = QVBoxLayout() vLayout2.addWidget(timeContainer) self.setLayout(vLayout2)
def create_signature_tab(self): w = QWidget() layout = QGridLayout(w) message_e = QTextEdit() layout.addWidget(QLabel(_('Message')), 1, 0) layout.addWidget(message_e, 1, 1) layout.setRowStretch(2, 2) encrypted_e = QTextEdit() encrypted_e.setFont(QFontDatabase.systemFont(QFontDatabase.FixedFont)) layout.addWidget(QLabel(_('Signed')), 2, 0) layout.addWidget(encrypted_e, 2, 1) layout.setRowStretch(2, 2) hbox = QHBoxLayout() b = QPushButton(_('Sign')) b.clicked.connect(lambda: self.do_sign(message_e, encrypted_e)) hbox.addWidget(b) b = QPushButton(_('Verify')) b.clicked.connect(lambda: self.do_verify(encrypted_e, message_e)) hbox.addWidget(b) layout.addLayout(hbox, 3, 1) return w
def wn_init(self): JC_LOG.info(self.tm_wai('Initializing ...')) self.wu_mw = QMainWindow() self.wu_mw.setWindowTitle(GC_APP_NM) self.wu_mw.showEvent = lambda _: self.wn_shown() self.wu_mw.closeEvent = lambda _: self.wn_quit() self.wu_cw = QWidget() self.wu_lo = QVBoxLayout() self.wu_pb = QPushButton() self.wu_pb.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed) self.wu_pb.pressed.connect(self.wn_change_font) self.wu_lb = QLabel() self.wu_lb.setAlignment(Qt.AlignCenter) for bu2_qo in [QWidget(), self.wu_pb, self.wu_lb]: self.wu_lo.addWidget(bu2_qo) self.wu_cw.setLayout(self.wu_lo) self.wu_fnt_families = QFontDatabase().families() self.wv_fnt_idx = len(self.wu_fnt_families) - 1 self.wv_msg = '' self.wu_mw.setCentralWidget(self.wu_cw) self.wu_mw.resize(650, 200) self.wu_mw.show() self.wu_mw.raise_() self.wn_move_center() self.wn_change_font() self.startTimer(100)
def __init__(self, parent): super().__init__(parent) font = QFontDatabase.systemFont(QFontDatabase.FixedFont) font.setPointSize(8) self.setFont(font) self.setPlainText("...")
def drawWindow(self): if self.layout() is not None: tempWidget = QWidget() tempWidget.setLayout(self.layout()) gridLayout = QGridLayout() # add header gridLayout.addWidget(QLabel('Libraries'), 0, 0) gridLayout.addWidget(QLabel(''), 0, 1) # add new library edit box self.libraryNameEdit = QLineEdit() fixedWidthFont = QFontDatabase.systemFont(QFontDatabase.FixedFont) self.libraryNameEdit.setFont(fixedWidthFont) gridLayout.addWidget(self.libraryNameEdit, 1, 0) self.addButton = QPushButton('Add') self.addButton.clicked.connect(self.addClicked) gridLayout.addWidget(self.addButton, 1, 1) self.buttons = {} row = 2 for lib in self.libraries: gridLayout.addWidget(QLabel(lib), row, 0) deleteButton = QPushButton() deleteButton.setObjectName(lib) deleteButton.setText('Delete') deleteButton.clicked.connect(self.deleteButtonClicked) gridLayout.addWidget(deleteButton, row, 1) row += 1 self.buttons[deleteButton] = lib self.resize(300, 100) self.setLayout(gridLayout)
def __init__(self, app, parent=None): super().__init__(parent) self._app = app self.setPlaceholderText('搜索歌曲、歌手、专辑、用户') self.setToolTip('直接输入文字可以进行过滤,按 Enter 可以搜索\n' '输入 >>> 前缀之后,可以执行 Python 代码\n' '输入 # 前缀之后,可以过滤表格内容\n' '输入 > 前缀可以执行 fuo 命令(未实现,欢迎 PR)') self.setFont(QFontDatabase.systemFont(QFontDatabase.FixedFont)) self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed) self.setFixedHeight(32) self.setFrame(False) self.setAttribute(Qt.WA_MacShowFocusRect, 0) self.setTextMargins(5, 0, 0, 0) self._timer = QTimer(self) self._cmd_text = None self._mode = 'cmd' # 详见 _set_mode 函数 self._timer.timeout.connect(self.__on_timeout) self.textChanged.connect(self.__on_text_edited) # self.textEdited.connect(self.__on_text_edited) self.returnPressed.connect(self.__on_return_pressed) self._app.hotkey_mgr.register( [QKeySequence('Ctrl+F'), QKeySequence(':'), QKeySequence('Alt+x')], self.setFocus)
def __init__(self, buf, parent=None): super(HexViewWidget, self).__init__() self.setupUi(self) self._buf = buf self._model = HexTableModel(self._buf) self._colored_regions = intervaltree.IntervalTree() self._origins = [] # ripped from pyuic5 ui/hexview.ui # at commit 6c9edffd32706097d7eba8814d306ea1d997b25a # so we can add our custom HexTableView instance self.view = HexTableView(self) sizePolicy = QSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.Expanding) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.view.sizePolicy().hasHeightForWidth()) self.view.setSizePolicy(sizePolicy) self.view.setMinimumSize(QSize(660, 0)) self.view.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOn) self.view.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff) self.view.setSelectionMode(QAbstractItemView.NoSelection) self.view.setShowGrid(False) self.view.setWordWrap(False) self.view.setObjectName("view") self.view.horizontalHeader().setDefaultSectionSize(25) self.view.horizontalHeader().setMinimumSectionSize(25) self.view.verticalHeader().setDefaultSectionSize(21) self.mainLayout.insertWidget(0, self.view) # end rip # TODO: provide a HexViewWidget.setModel method, and don't build it ourselves self.view.setModel(self._model) for i in range(0x10): self.view.setColumnWidth(i, 25) self.view.setColumnWidth(0x10, 12) for i in range(0x11, 0x22): self.view.setColumnWidth(i, 11) self._hsm = HexItemSelectionModel(self._model, self.view) self.view.setSelectionModel(self._hsm) self.view.setContextMenuPolicy(Qt.CustomContextMenu) self.view.customContextMenuRequested.connect(self._handle_context_menu_requested) self._hsm.selectionRangeChanged.connect(self._handle_selection_range_changed) self.originsChanged.connect(self._handle_origins_changed) self.view.moveKeyPressed.connect(self._hsm.handle_move_key) self.view.selectKeyPressed.connect(self._hsm.handle_select_key) f = QFontDatabase.systemFont(QFontDatabase.FixedFont) self.view.setFont(f) self.statusLabel.setFont(f) self.view.setItemDelegate(HexItemDelegate(self._model, self)) self.statusLabel.setText("")
def family(self): return idaapi.reg_read_string( 'Name', self._key, 'Consolas' if os.name == 'nt' else QFontDatabase.systemFont(QFontDatabase.FixedFont).family().encode() )
def __init__(self, name): super(QDialog, self).__init__() self.setWindowTitle(name) self.config = None self.gridLayout = QGridLayout() # add header self.gridLayout.addWidget(QLabel('Server Type'), 0, 0) self.gridLayout.addWidget(QLabel('Name'), 0, 1) self.gridLayout.addWidget(QLabel('Topic'), 0, 2) self.gridLayout.addWidget(QLabel('Proxy Name'), 0, 3) self.gridLayout.addWidget(QLabel('IP'), 0, 4) self.gridLayout.addWidget(QLabel('Port'), 0, 5) self.gridLayout.addWidget(QLabel('Interface'), 0, 6) self.gridLayout.addWidget(QLabel(''), 0, 7) # add new config input fields fixedWidthFont = QFontDatabase.systemFont(QFontDatabase.FixedFont) self.serverTypeCombo = QComboBox() self.serverTypeCombo.setFont(fixedWidthFont) self.gridLayout.addWidget(self.serverTypeCombo, 1, 0) self.nameEdit = QLineEdit() self.nameEdit.setFont(fixedWidthFont) self.gridLayout.addWidget(self.nameEdit, 1, 1) self.topicEdit = QLineEdit() self.topicEdit.setFont(fixedWidthFont) self.topicEdit.setEnabled(False) self.gridLayout.addWidget(self.topicEdit, 1, 2) self.proxyNameEdit = QLineEdit() self.proxyNameEdit.setFont(fixedWidthFont) self.gridLayout.addWidget(self.proxyNameEdit, 1, 3) self.ipEdit = QLineEdit() self.ipEdit.setFont(fixedWidthFont) self.gridLayout.addWidget(self.ipEdit, 1, 4) self.portEdit = QLineEdit() self.portEdit.setFont(fixedWidthFont) self.gridLayout.addWidget(self.portEdit, 1, 5) self.interfaceCombo = QComboBox() self.gridLayout.addWidget(self.interfaceCombo, 1, 6) self.addButton = QPushButton('Add') self.gridLayout.addWidget(self.addButton, 1, 7) self.addButton.clicked.connect(self.addClicked) self.rowCount = 2 # add server types to the combobox self.serverTypeCombo.addItem('ICE', 'ice') self.serverTypeCombo.addItem('ROS', 'ros') self.serverTypeCombo.currentIndexChanged.connect(self.serverTypeChanged) # add interfaces to the combobox interfaces = Interfaces.getInterfaces() for interfaceName in interfaces: self.interfaceCombo.addItem(interfaceName, interfaceName) self.resize(700, 100) self.setLayout(self.gridLayout)
def __init__(self, title, config): QDialog.__init__(self) if config is not None: self.type = config.type else: self.type = JDEROBOTCOMM self.setWindowTitle(title) commSelectionBox = QGroupBox('Select Communication Interface') commSelectionBox.setObjectName('commInterface') # add new config input fields fixedWidthFont = QFontDatabase.systemFont(QFontDatabase.FixedFont) self.commTypeCombo = QComboBox() self.commTypeCombo.setFont(fixedWidthFont) self.commTypeCombo.setMaximumWidth(220) boxLayout = QVBoxLayout() boxLayout.addWidget(self.commTypeCombo) commSelectionBox.setLayout(boxLayout) vLayout = QFormLayout() vLayout.addWidget(commSelectionBox) self.configsLayout = QVBoxLayout() self.configsBox = QGroupBox('') self.configsBox.setLayout(self.configsLayout) vLayout.addWidget(self.configsBox) self.setLayout(vLayout) self.resize(700, 500) #self.setStyleSheet('QGroupBox#commInterface { border: 1px solid black; border-radius: 4px; padding:15px;} QGroupBox::title#commInterface {background-color:transparent; padding-left:25px; padding-top:5px;} ') self.rosConfigsUI = RosConfigDialog('ROS Communication') self.rosConfigsUI.configChanged.connect(self.configChangedHandler) self.configsLayout.addWidget(self.rosConfigsUI) self.rosConfigsUI.setVisible(False) self.jderobotCommConfigsUI = JdeRobotCommConfigDialog('JdeRobot Communication') self.jderobotCommConfigsUI.configChanged.connect(self.configChangedHandler) self.configsLayout.addWidget(self.jderobotCommConfigsUI) self.jderobotCommConfigsUI.setVisible(True) self.rosConfig = None self.jdeRobotCommConfig = None self.commTypeCombo.addItem('JdeRobot Communication', 'jderobotcomm') self.commTypeCombo.addItem('ROS Node', 'ros') self.commTypeCombo.currentIndexChanged.connect(self.commTypeComboChanged) if config is not None: if config.type == ROS: self.rosConfig = config self.commTypeCombo.setCurrentIndex(1) self.loadRosConfigs() elif config.type == JDEROBOTCOMM: self.jdeRobotCommConfig = config self.commTypeCombo.setCurrentIndex(0) self.loadJdeRobotCommConfigs() else: self.loadJdeRobotCommConfigs()
def __init__(self): super(Report, self).__init__() self.status_view = "window" self.status_colors = "light" self.font_size = 22 self.font_database = QFontDatabase() # add font cmtex9 self.font_file_cmtex9 = "cmtex9.ttf" self.font_identifier_cmtex9 = QFontDatabase.addApplicationFont( self.font_file_cmtex9 ) self.fontFamilyName_cmtex9 = self.font_database.applicationFontFamilies( self.font_identifier_cmtex9 )[0] self.update_font() self.initialise_UI()
def load_font(self, prefix, ttf_filename, charmap_filename, directory=None): """Loads a font file and the associated charmap If `directory` is None, the files will be looked up in ./fonts/ Arguments --------- prefix: str prefix string to be used when accessing a given font set ttf_filename: str ttf font filename charmap_filename: str charmap filename directory: str or None, optional directory for font and charmap files """ def hook(obj): result = {} for key in obj: result[key] = unichr(int(obj[key], 16)) return result if directory is None: directory = os.path.join( os.path.dirname(os.path.realpath(__file__)), 'fonts') with open(os.path.join(directory, charmap_filename), 'r') as codes: self.charmap[prefix] = json.load(codes, object_hook=hook) id_ = QFontDatabase.addApplicationFont(os.path.join(directory, ttf_filename)) loadedFontFamilies = QFontDatabase.applicationFontFamilies(id_) if loadedFontFamilies: self.fontname[prefix] = loadedFontFamilies[0] else: print('Font is empty')
def __init__(self, parent): super().__init__(parent) self.setFont(QFontDatabase.systemFont(QFontDatabase.FixedFont)) self.setAcceptRichText(False) self.setTabChangesFocus(True) self._highlighter = RulesEditorHighlighter(self.document()) self._quiescence_timer = QTimer(self) self._quiescence_timer.setSingleShot(True) self._quiescence_timer.setInterval(self.QUIESCENCE_TIME_MSEC) self._quiescence_timer.timeout.connect(self._on_quiescence_timer_timeout) self.document().contentsChanged.connect(self._on_contents_changed)
def create_key_info_tab(self): w = QWidget() layout = QGridLayout(w) layout.addWidget(QLabel(_('GPG public key')), 1, 1) data_e = QTextEdit() data_e.setReadOnly(True) data_e.setFont(QFontDatabase.systemFont(QFontDatabase.FixedFont)) layout.addWidget(data_e, 2, 1) data_e.setPlainText(self.gpgw.export_pubkey()) return w
def _initializeDefaults(self) -> None: self._fonts = { "system": QCoreApplication.instance().font(), "fixed": QFontDatabase.systemFont(QFontDatabase.FixedFont) } palette = QCoreApplication.instance().palette() self._colors = { "system_window": palette.window(), "system_text": palette.text() } self._sizes = { "line": QSizeF(self._em_width, self._em_height) }
def fixedFont(): """ Returns a default fixed-pitch QFont_ for each supported platform. Returns "Consolas" instead of the default "Courier New" on Windows. TODO: test more .. _QFont: http://doc.qt.io/qt-5/qfont.html """ font = QFontDatabase.systemFont(QFontDatabase.FixedFont) if sys.platform == "win32": # pick Consolas instead of Courier New font.setFamily("Consolas") elif sys.platform == "darwin": # pick Menlo instead of Monaco font.setFamily("Menlo") font.setPointSize(11) return font
def __init__(self, parent, connection, terminal): super(TerminalDialog, self).__init__(None, Qt.WindowCloseButtonHint) self.setupUi(self) self.setWindowFlags(Qt.Window) geometry = Settings().retrieve_geometry("terminal") if geometry: self.restoreGeometry(geometry) self.connection = connection self.terminal = terminal self._auto_scroll = True # TODO: Settings? self.terminal_listener = Listener(self.emit_update_content) self._update_content_signal.connect(self.update_content) self.terminal.add_event.connect(self.terminal_listener) self.outputTextEdit.installEventFilter(self) self.outputTextEdit.verticalScrollBar().sliderPressed.connect(self._stop_scrolling) self.outputTextEdit.verticalScrollBar().sliderReleased.connect(self._scroll_released) self.outputTextEdit.verticalScrollBar().installEventFilter(self) self.inputTextBox.installEventFilter(self) self.clearButton.clicked.connect(self.clear_content) self.sendButton.clicked.connect(self.send_input) self.ctrlaButton.clicked.connect(lambda: self.send_control("a")) self.ctrlbButton.clicked.connect(lambda: self.send_control("b")) self.ctrlcButton.clicked.connect(lambda: self.send_control("c")) self.ctrldButton.clicked.connect(lambda: self.send_control("d")) self.ctrleButton.clicked.connect(lambda: self.send_control("e")) fixed_font = QFontDatabase.systemFont(QFontDatabase.FixedFont) self.outputTextEdit.setFont(fixed_font) self.inputTextBox.setFont(fixed_font) self.autoscrollCheckBox.setChecked(self._auto_scroll) self.autoscrollCheckBox.stateChanged.connect(self._auto_scroll_changed) self.terminal.read() self.outputTextEdit.setText(TerminalDialog.process_backspaces(self.terminal.history)) self._input_history_index = 0
def __init__(self): super(MainWindow, self).__init__() uiPath = resourceFileName('uis:main.ui') loadUi(uiPath, baseinstance=self, package='crispy.gui') # Main window. self.statusbar.showMessage('Ready') # Logger widget. font = QFontDatabase.systemFont(QFontDatabase.FixedFont) if sys.platform == 'darwin': font.setPointSize(font.pointSize() + 1) self.loggerWidget.setFont(font) self.loggerWidget.setLineWrapMode(QPlainTextEdit.NoWrap) # About dialog. self.aboutDialog = AboutDialog(parent=self) self.openAboutDialogAction.triggered.connect(self.openAboutDialog) # Quanty module. self.quantyModuleInit()
def __init__(self, parent, connection): super(CodeEditDialog, self).__init__(None, Qt.WindowCloseButtonHint) self.setupUi(self) geometry = Settings().retrieve_geometry("editor") if geometry: self.restoreGeometry(geometry) self._connection = connection self.saveLocalButton.clicked.connect(self._save_local) self.saveMcuButton.clicked.connect(self._save_to_mcu) #self.runButton.clicked.connect(self._run_file) self.runButton.hide() fixed_font = QFontDatabase.systemFont(QFontDatabase.FixedFont) self.codeEdit.setFont(fixed_font) if connection and connection.is_connected(): self.connected(connection) else: self.disconnected()
def findSizes(self, font): fontDatabase = QFontDatabase() currentSize = self.sizeCombo.currentText() self.sizeCombo.blockSignals(True) self.sizeCombo.clear() if fontDatabase.isSmoothlyScalable(font.family(), fontDatabase.styleString(font)): for size in QFontDatabase.standardSizes(): self.sizeCombo.addItem(str(size)) self.sizeCombo.setEditable(True) else: for size in fontDatabase.smoothSizes(font.family(), fontDatabase.styleString(font)): self.sizeCombo.addItem(str(size)) self.sizeCombo.setEditable(False) self.sizeCombo.blockSignals(False) sizeIndex = self.sizeCombo.findText(currentSize) if sizeIndex == -1: self.sizeCombo.setCurrentIndex(max(0, self.sizeCombo.count() / 3)) else: self.sizeCombo.setCurrentIndex(sizeIndex)
# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= # # Static globals and functions to manage them. # # Generate a font database and make sure it contains Liberation Mono # and Cousine, loading them from our resources module. # from PyQt5.QtGui import ( QFont, QFontDatabase ) from PyQt5.QtWidgets import QFontDialog _FONT_DB = QFontDatabase() _FONT_DB.addApplicationFont(':/liberation_mono.ttf') _FONT_DB.addApplicationFont(':/cousine.ttf') # Return a list of available monospaced families for use in the preferences # dialog. Because for some stupid reason the font database refuses to # acknowledge that liberation mono and cousine are in fact, monospaced, # insert those names too. def list_of_good_families(): selection = _FONT_DB.families() # all known family names short_list = [family for family in selection if _FONT_DB.isFixedPitch(family) ] short_list.insert(0,'Liberation Mono') short_list.insert(0,'Cousine') return short_list
def get_monospace_font() -> QFont: fixed_font = QFontDatabase.systemFont(QFontDatabase.FixedFont) fixed_font.setPointSize(QApplication.instance().font().pointSize()) return fixed_font
def load(self, path): self._path = path with open(os.path.join(self._path, "theme.json")) as f: data = json.load(f) self._initializeDefaults() if "colors" in data: for name, color in data["colors"].items(): c = QColor(color[0], color[1], color[2], color[3]) self._colors[name] = c fontsdir = os.path.join(self._path, "fonts") if os.path.isdir(fontsdir): for file in os.listdir(fontsdir): if "ttf" in file: QFontDatabase.addApplicationFont(os.path.join(fontsdir, file)) if "fonts" in data: for name, font in data["fonts"].items(): f = QFont() if not sys.platform == "win32": # Excluding windows here as a workaround for bad font rendering f.setFamily(font.get("family", QCoreApplication.instance().font().family())) f.setStyleName(font.get("style", "Regular")) f.setBold(font.get("bold", False)) f.setItalic(font.get("italic", False)) f.setPixelSize(font.get("size", 1) * self._em_height) f.setCapitalization(QFont.AllUppercase if font.get("capitalize", False) else QFont.MixedCase) self._fonts[name] = f if "sizes" in data: for name, size in data["sizes"].items(): s = QSizeF() s.setWidth(size[0] * self._em_width) s.setHeight(size[1] * self._em_height) self._sizes[name] = s styles = os.path.join(self._path, "styles.qml") if os.path.isfile(styles): c = QQmlComponent(self._engine, styles) self._styles = c.create() if c.isError(): for error in c.errors(): Logger.log("e", error.toString()) iconsdir = os.path.join(self._path, "icons") if os.path.isdir(iconsdir): for icon in os.listdir(iconsdir): name = os.path.splitext(icon)[0] self._icons[name] = QUrl.fromLocalFile(os.path.join(iconsdir, icon)) imagesdir = os.path.join(self._path, "images") if os.path.isdir(imagesdir): for image in os.listdir(imagesdir): name = os.path.splitext(image)[0] self._images[name] = QUrl.fromLocalFile(os.path.join(imagesdir, image)) Logger.log("d", "Loaded theme %s", self._path) self.themeLoaded.emit()
def loadFont(cls): """加载外部字体""" path = os.path.join(Settings().dataDir, "fonts") for font in os.listdir(path): QFontDatabase.addApplicationFont(os.path.join(path, font))