Python PyQt5.QtGui.QFontDatabase.systemFont() Examples

The following are 10 code examples of PyQt5.QtGui.QFontDatabase.systemFont(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module PyQt5.QtGui.QFontDatabase , or try the search function .
Example #1
Source File: code_edit_dialog.py    From uPyLoader with MIT License 6 votes vote down vote up
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() 
Example #2
Source File: __init__.py    From binja_dynamics with Apache License 2.0 6 votes vote down vote up
def __init__(self):
        super(TracebackWindow, self).__init__()
        self.framelist = []
        self.ret_add = 0x0
        self.setWindowTitle("Traceback")
        self.setLayout(QtWidgets.QVBoxLayout())
        self._layout = self.layout()

        # Creates the rich text viewer that displays the traceback
        self._textBrowser = QtWidgets.QTextBrowser()
        self._textBrowser.setOpenLinks(False)
        self._textBrowser.setFont(QFontDatabase.systemFont(QFontDatabase.FixedFont))
        self._layout.addWidget(self._textBrowser)

        # Creates the button that displays the return address
        self._ret = QtWidgets.QPushButton()
        self._ret.setFlat(True)
        self._layout.addWidget(self._ret)

        self.resize(self.width(), int(self.height() * 0.5))

        self.setObjectName('Traceback_Window') 
Example #3
Source File: terminal_dialog.py    From uPyLoader with MIT License 5 votes vote down vote up
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 
Example #4
Source File: idafontconfig.py    From IDASkins with MIT License 5 votes vote down vote up
def family(self):
        return idaapi.reg_read_string(
            'Name',
            self._key,
            'Consolas'
            if os.name == 'nt' else 
            QFontDatabase.systemFont(QFontDatabase.FixedFont).family().encode()    
        ) 
Example #5
Source File: Theme.py    From Uranium with GNU Lesser General Public License v3.0 5 votes vote down vote up
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)
        } 
Example #6
Source File: magicbox.py    From FeelUOwn with GNU General Public License v3.0 5 votes vote down vote up
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
        ) 
Example #7
Source File: util.py    From urh with GNU General Public License v3.0 5 votes vote down vote up
def get_monospace_font() -> QFont:
    fixed_font = QFontDatabase.systemFont(QFontDatabase.FixedFont)
    fixed_font.setPointSize(QApplication.instance().font().pointSize())
    return fixed_font 
Example #8
Source File: UnlabeledRangeItem.py    From urh with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, parent):
        super().__init__(parent)

        font = QFontDatabase.systemFont(QFontDatabase.FixedFont)
        font.setPointSize(8)
        self.setFont(font)
        self.setPlainText("...") 
Example #9
Source File: configtypes.py    From qutebrowser with GNU General Public License v3.0 4 votes vote down vote up
def set_defaults(cls, default_family: typing.List[str],
                     default_size: str) -> None:
        """Make sure default_family/default_size are available.

        If the given family value (fonts.default_family in the config) is
        unset, a system-specific default monospace font is used.

        Note that (at least) three ways of getting the default monospace font
        exist:

        1) f = QFont()
           f.setStyleHint(QFont.Monospace)
           print(f.defaultFamily())

        2) f = QFont()
           f.setStyleHint(QFont.TypeWriter)
           print(f.defaultFamily())

        3) f = QFontDatabase.systemFont(QFontDatabase.FixedFont)
           print(f.family())

        They yield different results depending on the OS:

                   QFont.Monospace  | QFont.TypeWriter    | QFontDatabase
                   ------------------------------------------------------
        Windows:   Courier New      | Courier New         | Courier New
        Linux:     DejaVu Sans Mono | DejaVu Sans Mono    | monospace
        macOS:     Menlo            | American Typewriter | Monaco

        Test script: https://p.cmpl.cc/d4dfe573

        On Linux, it seems like both actually resolve to the same font.

        On macOS, "American Typewriter" looks like it indeed tries to imitate a
        typewriter, so it's not really a suitable UI font.

        Looking at those Wikipedia articles:

        https://en.wikipedia.org/wiki/Monaco_(typeface)
        https://en.wikipedia.org/wiki/Menlo_(typeface)

        the "right" choice isn't really obvious. Thus, let's go for the
        QFontDatabase approach here, since it's by far the simplest one.
        """
        if default_family:
            families = configutils.FontFamilies(default_family)
        else:
            assert QApplication.instance() is not None
            font = QFontDatabase.systemFont(QFontDatabase.FixedFont)
            families = configutils.FontFamilies([font.family()])

        cls.default_family = families.to_str(quote=True)
        cls.default_size = default_size 
Example #10
Source File: editor.py    From CQ-editor with Apache License 2.0 4 votes vote down vote up
def __init__(self,parent=None):

        super(Editor,self).__init__(parent)
        ComponentMixin.__init__(self)

        self._filename = ''

        self.setup_editor(linenumbers=True,
                          markers=True,
                          edge_line=False,
                          tab_mode=False,
                          show_blanks=True,
                          font=QFontDatabase.systemFont(QFontDatabase.FixedFont),
                          language='Python')

        self._actions =  \
                {'File' : [QAction(icon('new'),
                                  'New',
                                  self,
                                  shortcut='ctrl+N',
                                  triggered=self.new),
                          QAction(icon('open'),
                                  'Open',
                                  self,
                                  shortcut='ctrl+O',
                                  triggered=self.open),
                          QAction(icon('save'),
                                  'Save',
                                  self,
                                  shortcut='ctrl+S',
                                  triggered=self.save),
                          QAction(icon('save_as'),
                                  'Save as',
                                  self,
                                  shortcut='ctrl+shift+S',
                                  triggered=self.save_as),
                          QAction(icon('autoreload'),
                                  'Automatic reload and preview',
                                  self,triggered=self.autoreload,
                                  checkable=True,
                                  checked=False,
                                  objectName='autoreload'),
                          ]}

        for a in self._actions.values():
            self.addActions(a)


        self._fixContextMenu()
        self.updatePreferences()

        # autoreload support
        self._file_watcher = QFileSystemWatcher(self)
        self._watched_file = None
        # we wait for 50ms after a file change for the file to be written completely
        self._file_watch_timer = QTimer(self)
        self._file_watch_timer.setInterval(50)
        self._file_watch_timer.setSingleShot(True)
        self._file_watcher.fileChanged.connect(
                lambda val: self._file_watch_timer.start())
        self._file_watch_timer.timeout.connect(self._file_changed)