Python PyQt5.QtGui 模块,QFontDatabase() 实例源码

我们从Python开源项目中,提取了以下6个代码示例,用于说明如何使用PyQt5.QtGui.QFontDatabase()

项目:git-annex-metadata-gui    作者:alpernebbi    | 项目源码 | 文件源码
def __init__(self, key_obj):
        super().__init__()
        self._obj = key_obj

        self.setText(self.key)
        self.setToolTip(self.key)

        font = QtGui.QFontDatabase.FixedFont
        font = QtGui.QFontDatabase().systemFont(font)
        self.setFont(font)

        icon = QtWidgets.QFileIconProvider.File
        icon = QtWidgets.QFileIconProvider().icon(icon)
        self.setIcon(icon)

        self.setSelectable(True)
        self.setEditable(False)
        self.setEnabled(True)
        self.setFlags(self.flags() | Qt.Qt.ItemNeverHasChildren)
项目:brown    作者:ajyoon    | 项目源码 | 文件源码
def __init__(self, document):
        """
        Args:
            document (Document):
        """
        super().__init__(None)  # no brown object exists for this
                                # TODO: make one
        self.document = document
        self.app = QtWidgets.QApplication([])
        self.main_window = MainWindow()
        self.scene = QtWidgets.QGraphicsScene()
        self.view = self.main_window.graphicsView
        self.view.setScene(self.scene)
        self.registered_music_fonts = {}
        self.font_database = QtGui.QFontDatabase()

    ######## PUBLIC METHODS ########
项目:PyQt5-CWidgets    作者:ArmPitPerson    | 项目源码 | 文件源码
def __init__(self, parent=None, title="Console Output"):
        """Constructor for QConsoleOutputWidget.

        Keyword Arguments:
        parent -- parent widget for this widget (default: None)
        title -- Title for the window (default: "Console Output")

        Example:
        QConsoleOutputWidget()
        QConsoleOutputWidget(title="Program Output")
        """
        super().__init__(parent)
        self.setWindowTitle(str(title))
        self.setGeometry(800, 400, 600, 200)

        QtGui.QFontDatabase().addApplicationFont(Resources.monspaceFont)

        self.messageQueue = []
        self.__processes = []
        self.__processThreads = []
        self.__printLock = threading.Lock()

        self.__initUI()
项目:PyQt5-CWidgets    作者:ArmPitPerson    | 项目源码 | 文件源码
def __init__(self, process, parent=None):
        """Constructor for QConsoleInputWidget

        Arguments:
        process -- process to send stdin to

        Keyword Arguments:
        parent -- parent widget for this widget (default: None)

        Example:
        QConsoleInputWidget()
        """
        super().__init__(parent)
        QtGui.QFontDatabase().addApplicationFont(Resources.monspaceFont)
        self.__initUI()
        self.process = process
项目:bubblesub    作者:rr-    | 项目源码 | 文件源码
def __init__(self, parent):
        super().__init__('Font', parent)
        self.font_name_edit = QtWidgets.QComboBox(
            self,
            editable=False,
            sizePolicy=QtWidgets.QSizePolicy(
                QtWidgets.QSizePolicy.Expanding,
                QtWidgets.QSizePolicy.Preferred),
            insertPolicy=QtWidgets.QComboBox.NoInsert)
        self.font_size_edit = QtWidgets.QSpinBox(self, minimum=0)
        self.bold_checkbox = QtWidgets.QCheckBox('Bold', self)
        self.italic_checkbox = QtWidgets.QCheckBox('Italic', self)
        self.underline_checkbox = QtWidgets.QCheckBox('Underline', self)
        self.strike_out_checkbox = QtWidgets.QCheckBox('Strike-out', self)

        all_fonts = QtGui.QFontDatabase().families()
        self.font_name_edit.addItems(all_fonts)

        layout = QtWidgets.QGridLayout(self)
        layout.setColumnStretch(0, 1)
        layout.setColumnStretch(1, 2)
        layout.addWidget(QtWidgets.QLabel('Name:', self), 0, 0)
        layout.addWidget(self.font_name_edit, 0, 1)
        layout.addWidget(QtWidgets.QLabel('Size:', self), 1, 0)
        layout.addWidget(self.font_size_edit, 1, 1)
        layout.addWidget(QtWidgets.QLabel('Style:', self), 2, 0)
        layout.addWidget(self.bold_checkbox, 2, 1)
        layout.addWidget(self.italic_checkbox, 3, 1)
        layout.addWidget(self.underline_checkbox, 4, 1)
        layout.addWidget(self.strike_out_checkbox, 5, 1)
项目:BATS-Bayesian-Adaptive-Trial-Simulator    作者:ContaTP    | 项目源码 | 文件源码
def main():

    # Set a unique id to BATS
    import ctypes
    appid = 'bats.1.1.0'
    # Check the platform. If windows, set an ID so it will be in the task bar.
    if sys.platform == 'win32':

       ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID(appid)

    elif sys.platform == 'linux':

       pass

    elif sys.platform == 'darwin':

        pass

    else:

      sys.stdout.write("The application is not supported in this system")
      pass

    # Create the application
    app = QtWidgets.QApplication(['Bayesian Adaptive Trial Simulator'])
    # Add icon for the application
    app_icon = QtGui.QIcon()
    app_icon.addFile(":/resources/bcts.png", QtCore.QSize(16,16))
    app_icon.addFile(":/resources/bcts.png", QtCore.QSize(24,24))
    app_icon.addFile(":/resources/bcts.png", QtCore.QSize(32,32))
    app_icon.addFile(":/resources/bcts.png", QtCore.QSize(48,48))
    app_icon.addFile(":/resources/bcts.png", QtCore.QSize(256,256))
    app.setWindowIcon(app_icon)
    # Add font to the font database
    QtGui.QFontDatabase().addApplicationFont(":/resources/font/Caviar_Dreams_Bold.ttf")
    QtGui.QFontDatabase().addApplicationFont(":/resources/font/PTsans.ttf")
    # Initialize the GUI
    window = BATSWindow()
    window.show()
    # Run the app
    sys.exit(app.exec_())



# Initialize of the app