本文整理汇总了Python中PyQt5.QtGui.QFontDatabase.addApplicationFont方法的典型用法代码示例。如果您正苦于以下问题:Python QFontDatabase.addApplicationFont方法的具体用法?Python QFontDatabase.addApplicationFont怎么用?Python QFontDatabase.addApplicationFont使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtGui.QFontDatabase
的用法示例。
在下文中一共展示了QFontDatabase.addApplicationFont方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: seed_img
# 需要导入模块: from PyQt5.QtGui import QFontDatabase [as 别名]
# 或者: from PyQt5.QtGui.QFontDatabase import addApplicationFont [as 别名]
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
示例2: display_content
# 需要导入模块: from PyQt5.QtGui import QFontDatabase [as 别名]
# 或者: from PyQt5.QtGui.QFontDatabase import addApplicationFont [as 别名]
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))
示例3: __init__
# 需要导入模块: from PyQt5.QtGui import QFontDatabase [as 别名]
# 或者: from PyQt5.QtGui.QFontDatabase import addApplicationFont [as 别名]
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()
示例4: __init__
# 需要导入模块: from PyQt5.QtGui import QFontDatabase [as 别名]
# 或者: from PyQt5.QtGui.QFontDatabase import addApplicationFont [as 别名]
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()
示例5: load_font
# 需要导入模块: from PyQt5.QtGui import QFontDatabase [as 别名]
# 或者: from PyQt5.QtGui.QFontDatabase import addApplicationFont [as 别名]
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')
示例6: __init__
# 需要导入模块: from PyQt5.QtGui import QFontDatabase [as 别名]
# 或者: from PyQt5.QtGui.QFontDatabase import addApplicationFont [as 别名]
def __init__(self, *args, mode=None):
QApplication.__init__(self, *args)
# Log some basic system info
try:
v = openshot.GetVersion()
log.info("openshot-qt version: %s" % info.VERSION)
log.info("libopenshot version: %s" % v.ToString())
log.info("platform: %s" % platform.platform())
log.info("processor: %s" % platform.processor())
log.info("machine: %s" % platform.machine())
log.info("python version: %s" % platform.python_version())
log.info("qt5 version: %s" % QT_VERSION_STR)
log.info("pyqt5 version: %s" % PYQT_VERSION_STR)
except:
pass
# Setup application
self.setApplicationName('openshot')
self.setApplicationVersion(info.SETUP['version'])
# Init settings
self.settings = settings.SettingStore()
self.settings.load()
# Init and attach exception handler
from classes import exceptions
sys.excepthook = exceptions.ExceptionHandler
# Init translation system
language.init_language()
# Detect minimum libopenshot version
_ = self._tr
libopenshot_version = openshot.GetVersion().ToString()
if mode != "unittest" and libopenshot_version < info.MINIMUM_LIBOPENSHOT_VERSION:
QMessageBox.warning(None, _("Wrong Version of libopenshot Detected"),
_("<b>Version %(minimum_version)s is required</b>, but %(current_version)s was detected. Please update libopenshot or download our latest installer.") %
{"minimum_version": info.MINIMUM_LIBOPENSHOT_VERSION, "current_version": libopenshot_version})
# Stop launching and exit
sys.exit()
# Tests of project data loading/saving
self.project = project_data.ProjectDataStore()
# Init Update Manager
self.updates = updates.UpdateManager()
# It is important that the project is the first listener if the key gets update
self.updates.add_listener(self.project)
# Load ui theme if not set by OS
ui_util.load_theme()
# Start libopenshot logging thread
self.logger_libopenshot = logger_libopenshot.LoggerLibOpenShot()
self.logger_libopenshot.start()
# Track which dockable window received a context menu
self.context_menu_object = None
# Set Font for any theme
if self.settings.get("theme") != "No Theme":
# Load embedded font
try:
log.info("Setting font to %s" % os.path.join(info.IMAGES_PATH, "fonts", "Ubuntu-R.ttf"))
font_id = QFontDatabase.addApplicationFont(os.path.join(info.IMAGES_PATH, "fonts", "Ubuntu-R.ttf"))
font_family = QFontDatabase.applicationFontFamilies(font_id)[0]
font = QFont(font_family)
font.setPointSizeF(10.5)
QApplication.setFont(font)
except Exception as ex:
log.error("Error setting Ubuntu-R.ttf QFont: %s" % str(ex))
# Set Experimental Dark Theme
if self.settings.get("theme") == "Humanity: Dark":
# Only set if dark theme selected
log.info("Setting custom dark theme")
self.setStyle(QStyleFactory.create("Fusion"))
darkPalette = self.palette()
darkPalette.setColor(QPalette.Window, QColor(53, 53, 53))
darkPalette.setColor(QPalette.WindowText, Qt.white)
darkPalette.setColor(QPalette.Base, QColor(25, 25, 25))
darkPalette.setColor(QPalette.AlternateBase, QColor(53, 53, 53))
darkPalette.setColor(QPalette.ToolTipBase, Qt.white)
darkPalette.setColor(QPalette.ToolTipText, Qt.white)
darkPalette.setColor(QPalette.Text, Qt.white)
darkPalette.setColor(QPalette.Button, QColor(53, 53, 53))
darkPalette.setColor(QPalette.ButtonText, Qt.white)
darkPalette.setColor(QPalette.BrightText, Qt.red)
darkPalette.setColor(QPalette.Highlight, QColor(42, 130, 218))
darkPalette.setColor(QPalette.HighlightedText, Qt.black)
darkPalette.setColor(QPalette.Disabled, QPalette.Text, QColor(104, 104, 104))
self.setPalette(darkPalette)
self.setStyleSheet("QToolTip { color: #ffffff; background-color: #2a82da; border: 0px solid white; }")
# Create main window
from windows.main_window import MainWindow
self.window = MainWindow(mode)
#.........这里部分代码省略.........
示例7: __init__
# 需要导入模块: from PyQt5.QtGui import QFontDatabase [as 别名]
# 或者: from PyQt5.QtGui.QFontDatabase import addApplicationFont [as 别名]
def __init__(self, *args):
QApplication.__init__(self, *args)
# Setup appication
self.setApplicationName('openshot')
self.setApplicationVersion(info.SETUP['version'])
# Init settings
self.settings = settings.SettingStore()
try:
self.settings.load()
except Exception as ex:
log.error("Couldn't load user settings. Exiting.\n{}".format(ex))
exit()
# Init translation system
language.init_language()
# Tests of project data loading/saving
self.project = project_data.ProjectDataStore()
# Init Update Manager
self.updates = updates.UpdateManager()
# It is important that the project is the first listener if the key gets update
self.updates.add_listener(self.project)
# Load ui theme if not set by OS
ui_util.load_theme()
# Track which dockable window received a context menu
self.context_menu_object = None
# Set Font for any theme
if self.settings.get("theme") != "No Theme":
# Load embedded font
log.info("Setting font to %s" % os.path.join(info.IMAGES_PATH, "fonts", "Ubuntu-R.ttf"))
font_id = QFontDatabase.addApplicationFont(os.path.join(info.IMAGES_PATH, "fonts", "Ubuntu-R.ttf"))
font_family = QFontDatabase.applicationFontFamilies(font_id)[0]
font = QFont(font_family)
font.setPointSizeF(10.5)
QApplication.setFont(font)
# Set Experimental Dark Theme
if self.settings.get("theme") == "Humanity: Dark":
# Only set if dark theme selected
log.info("Setting custom dark theme")
self.setStyle(QStyleFactory.create("Fusion"))
darkPalette = self.palette()
darkPalette.setColor(QPalette.Window, QColor(53, 53, 53))
darkPalette.setColor(QPalette.WindowText, Qt.white)
darkPalette.setColor(QPalette.Base, QColor(25, 25, 25))
darkPalette.setColor(QPalette.AlternateBase, QColor(53, 53, 53))
darkPalette.setColor(QPalette.ToolTipBase, Qt.white)
darkPalette.setColor(QPalette.ToolTipText, Qt.white)
darkPalette.setColor(QPalette.Text, Qt.white)
darkPalette.setColor(QPalette.Button, QColor(53, 53, 53))
darkPalette.setColor(QPalette.ButtonText, Qt.white)
darkPalette.setColor(QPalette.BrightText, Qt.red)
darkPalette.setColor(QPalette.Highlight, QColor(42, 130, 218))
darkPalette.setColor(QPalette.HighlightedText, Qt.black)
self.setPalette(darkPalette)
self.setStyleSheet("QToolTip { color: #ffffff; background-color: #2a82da; border: 0px solid white; }")
# Create main window
from windows.main_window import MainWindow
self.window = MainWindow()
self.window.show()
# Load new/blank project (which sets default profile)
self.project.load("")
log.info('Process command-line arguments: %s' % args)
if len(args[0]) == 2:
path = args[0][1]
if ".osp" in path:
# Auto load project passed as argument
self.window.open_project(path)
else:
# Auto import media file
self.window.filesTreeView.add_file(path)
示例8: load_font
# 需要导入模块: from PyQt5.QtGui import QFontDatabase [as 别名]
# 或者: from PyQt5.QtGui.QFontDatabase import addApplicationFont [as 别名]
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 for in ``./fonts/``.
Parameters
----------
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')
# Load font
if QApplication.instance() is not None:
id_ = QFontDatabase.addApplicationFont(os.path.join(directory,
ttf_filename))
loadedFontFamilies = QFontDatabase.applicationFontFamilies(id_)
if(loadedFontFamilies):
self.fontname[prefix] = loadedFontFamilies[0]
else:
raise FontError(u"Font at '{0}' appears to be empty. "
"If you are on Windows 10, please read "
"https://support.microsoft.com/"
"en-us/kb/3053676 "
"to know how to prevent Windows from blocking "
"the fonts that come with QtAwesome.".format(
os.path.join(directory, ttf_filename)))
with open(os.path.join(directory, charmap_filename), 'r') as codes:
self.charmap[prefix] = json.load(codes, object_hook=hook)
# Verify that vendorized fonts are not corrupt
if not SYSTEM_FONTS:
md5_hashes = {'fontawesome-webfont.ttf':
'b06871f281fee6b241d60582ae9369b9',
'elusiveicons-webfont.ttf':
'207966b04c032d5b873fd595a211582e'}
ttf_hash = md5_hashes.get(ttf_filename, None)
if ttf_hash is not None:
hasher = hashlib.md5()
with open(os.path.join(directory, ttf_filename),
'rb') as f:
content = f.read()
hasher.update(content)
ttf_calculated_hash_code = hasher.hexdigest()
if ttf_calculated_hash_code != ttf_hash:
raise FontError(u"Font is corrupt at: '{0}'".format(
os.path.join(directory, ttf_filename)))
示例9: __init__
# 需要导入模块: from PyQt5.QtGui import QFontDatabase [as 别名]
# 或者: from PyQt5.QtGui.QFontDatabase import addApplicationFont [as 别名]
def __init__(self, *args, mode=None):
QApplication.__init__(self, *args)
# Log some basic system info
try:
v = openshot.GetVersion()
log.info("openshot-qt version: %s" % info.VERSION)
log.info("libopenshot version: %s" % v.ToString())
log.info("platform: %s" % platform.platform())
log.info("processor: %s" % platform.processor())
log.info("machine: %s" % platform.machine())
log.info("python version: %s" % platform.python_version())
log.info("qt5 version: %s" % QT_VERSION_STR)
log.info("pyqt5 version: %s" % PYQT_VERSION_STR)
except:
pass
# Setup appication
self.setApplicationName('openshot')
self.setApplicationVersion(info.SETUP['version'])
# Init settings
self.settings = settings.SettingStore()
try:
self.settings.load()
except Exception as ex:
log.error("Couldn't load user settings. Exiting.\n{}".format(ex))
exit()
# Init translation system
language.init_language()
# Tests of project data loading/saving
self.project = project_data.ProjectDataStore()
# Init Update Manager
self.updates = updates.UpdateManager()
# It is important that the project is the first listener if the key gets update
self.updates.add_listener(self.project)
# Load ui theme if not set by OS
ui_util.load_theme()
# Start libopenshot logging thread
self.logger_libopenshot = logger_libopenshot.LoggerLibOpenShot()
self.logger_libopenshot.start()
# Track which dockable window received a context menu
self.context_menu_object = None
# Set unique install id (if blank)
if not self.settings.get("unique_install_id"):
self.settings.set("unique_install_id", str(uuid4()))
# Track 1st launch metric
import classes.metrics
classes.metrics.track_metric_screen("initial-launch-screen")
# Set Font for any theme
if self.settings.get("theme") != "No Theme":
# Load embedded font
try:
log.info("Setting font to %s" % os.path.join(info.IMAGES_PATH, "fonts", "Ubuntu-R.ttf"))
font_id = QFontDatabase.addApplicationFont(os.path.join(info.IMAGES_PATH, "fonts", "Ubuntu-R.ttf"))
font_family = QFontDatabase.applicationFontFamilies(font_id)[0]
font = QFont(font_family)
font.setPointSizeF(10.5)
QApplication.setFont(font)
except Exception as ex:
log.error("Error setting Ubuntu-R.ttf QFont: %s" % str(ex))
# Set Experimental Dark Theme
if self.settings.get("theme") == "Humanity: Dark":
# Only set if dark theme selected
log.info("Setting custom dark theme")
self.setStyle(QStyleFactory.create("Fusion"))
darkPalette = self.palette()
darkPalette.setColor(QPalette.Window, QColor(53, 53, 53))
darkPalette.setColor(QPalette.WindowText, Qt.white)
darkPalette.setColor(QPalette.Base, QColor(25, 25, 25))
darkPalette.setColor(QPalette.AlternateBase, QColor(53, 53, 53))
darkPalette.setColor(QPalette.ToolTipBase, Qt.white)
darkPalette.setColor(QPalette.ToolTipText, Qt.white)
darkPalette.setColor(QPalette.Text, Qt.white)
darkPalette.setColor(QPalette.Button, QColor(53, 53, 53))
darkPalette.setColor(QPalette.ButtonText, Qt.white)
darkPalette.setColor(QPalette.BrightText, Qt.red)
darkPalette.setColor(QPalette.Highlight, QColor(42, 130, 218))
darkPalette.setColor(QPalette.HighlightedText, Qt.black)
darkPalette.setColor(QPalette.Disabled, QPalette.Text, QColor(104, 104, 104))
self.setPalette(darkPalette)
self.setStyleSheet("QToolTip { color: #ffffff; background-color: #2a82da; border: 0px solid white; }")
# Create main window
from windows.main_window import MainWindow
self.window = MainWindow(mode)
log.info('Process command-line arguments: %s' % args)
#.........这里部分代码省略.........
示例10: QApplication
# 需要导入模块: from PyQt5.QtGui import QFontDatabase [as 别名]
# 或者: from PyQt5.QtGui.QFontDatabase import addApplicationFont [as 别名]
@site: irony.iask.in , mzone.iask.in
@email: [email protected]
@file: test.test_font.py
@description:
"""
from PyQt5.QtGui import QFontDatabase
from PyQt5.QtWidgets import QApplication, QPushButton
__Author__ = "By: Irony.\"[讽刺]\nQQ: 892768447\nEmail: [email protected]"
__Copyright__ = "Copyright (c) 2015 Irony.\"[讽刺]"
__Version__ = 1.0
app = QApplication([])
QFontDatabase.addApplicationFont("../data/fonts/webdings.ttf")
QFontDatabase.addApplicationFont("../data/fonts/fontawesome-webfont.ttf")
btn = QPushButton()
btn.setObjectName("blog_up_button")
btn.show()
# 圆形进度 \uf110
# 搜索 \uf002
app.setStyleSheet("""
#blog_up_button {
qproperty-text: "\uf002";
font-family: "FontAwesome";
}
""")
示例11: loadFont
# 需要导入模块: from PyQt5.QtGui import QFontDatabase [as 别名]
# 或者: from PyQt5.QtGui.QFontDatabase import addApplicationFont [as 别名]
def loadFont(cls):
"""加载外部字体"""
path = os.path.join(Settings().dataDir, "fonts")
for font in os.listdir(path):
QFontDatabase.addApplicationFont(os.path.join(path, font))
示例12: set_gui_constants
# 需要导入模块: from PyQt5.QtGui import QFontDatabase [as 别名]
# 或者: from PyQt5.QtGui.QFontDatabase import addApplicationFont [as 别名]
def set_gui_constants(parent):
# TODO: after the design is settled, remove unnecessary font files
weights = {'ExtraLight', 'Light', 'Semibold', 'Bold', 'Black'}
weights ^= set(s + 'It' for s in copy(weights))
weights ^= {'Regular', 'It'}
# Load fonts
fonts = QFontDatabase()
for weight in weights:
fonts.addApplicationFont(os_path_join(_FONT_PATH,
'SourceSansPro-{}.ttf'.format(weight)))
# TODO: distinguish in names:
# type_palette_property and type_color_property
# Palettes
CONSTANTS['text_color_dark'] = _palette(parent, FOREGROUND, '000000', 45)
CONSTANTS['text_color_light'] = _palette(parent, FOREGROUND, 'ffffff', 30)
CONSTANTS['text_color_light_selected'] = _palette(parent, FOREGROUND, 'ffffff', 85)
# CONSTANTS['panel_color_light'] = _palette(parent, BACKGROUND, '808080')
CONSTANTS['panel_color_dark'] = _palette(parent, BACKGROUND, '303030')
CONSTANTS['panel_color_darker'] = _palette(parent, BACKGROUND, '101010')
CONSTANTS['panel_color_error'] = _palette(parent, BACKGROUND, '000000', 35)
# Colors
CONSTANTS['shadow_color'] = _color('000000', 70)
CONSTANTS['panel_color_light'] = _color('808080')
DEBUG_ALPHA = 40
CONSTANTS['debug1'] = _color('ffff00', DEBUG_ALPHA)
CONSTANTS['debug2'] = _color('00ffff', DEBUG_ALPHA)
CONSTANTS['debug3'] = _color('ff00ff', DEBUG_ALPHA)
CONSTANTS['debug4'] = _color('ff0000', DEBUG_ALPHA)
CONSTANTS['debug5'] = _color('00ff00', DEBUG_ALPHA)
CONSTANTS['debug6'] = _color('0000ff', DEBUG_ALPHA)
# Fonts
CONSTANTS['text_font_title'] = QFont(_SANS, 16, QFont.Light)
CONSTANTS['text_font_author'] = QFont(_SANS, 10, QFont.Normal, italic=True)
CONSTANTS['text_font_numbers'] = QFont(_SANS, 12, QFont.Normal)
CONSTANTS['text_font_generic'] = QFont(_SANS, 10, QFont.Normal)
# Icons
CONSTANTS['icon_scroll_up'] = _icon('icons_scroll.png')
CONSTANTS['icon_scroll_down'] = _icon('icons_scroll.png', rotate=180)
CONSTANTS['icon_recoub'] = _icon('icons_share.png')
CONSTANTS['icon_like'] = _icon('icons_like.png')
CONSTANTS['icon_featured'] = _icon('icons_featured.png')
CONSTANTS['icon_newest'] = _icon('icons_newest.png')
CONSTANTS['icon_random'] = _icon('icons_random.png')
CONSTANTS['icon_hot'] = _icon('icons_hot.png')
CONSTANTS['icon_featured_selected'] = _icon('icons_featured_selected.png')
CONSTANTS['icon_newest_selected'] = _icon('icons_newest_selected.png')
CONSTANTS['icon_random_selected'] = _icon('icons_random_selected.png')
CONSTANTS['icon_hot_selected'] = _icon('icons_hot_selected.png')
# Other images
CONSTANTS['icon_no_avatar'] = _static('no_avatar.png')
CONSTANTS['other_separator'] = _static('separator.png')
# Animation
CONSTANTS['anim_busy_dark'] = os_path_join(_BASE_PATH, 'motion', 'dark_loader.gif')
CONSTANTS['anim_busy_light'] = os_path_join(_BASE_PATH, 'motion', 'light_loader.gif')
示例13: load
# 需要导入模块: from PyQt5.QtGui import QFontDatabase [as 别名]
# 或者: from PyQt5.QtGui.QFontDatabase import addApplicationFont [as 别名]
def load(self, path):
if path == self._path:
return
self._path = path
with open(os.path.join(self._path, "theme.json")) as f:
Logger.log("d", "Loading theme file: %s", os.path.join(self._path, "theme.json"))
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()
f.setFamily(font.get("family", QCoreApplication.instance().font().family()))
f.setBold(font.get("bold", False))
f.setLetterSpacing(QFont.AbsoluteSpacing, font.get("letterSpacing", 0))
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(round(size[0] * self._em_width))
s.setHeight(round(size[1] * self._em_height))
self._sizes[name] = s
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))
styles = os.path.join(self._path, "styles.qml")
if os.path.isfile(styles):
c = QQmlComponent(self._engine, styles)
context = QQmlContext(self._engine, self._engine)
context.setContextProperty("Theme", self)
self._styles = c.create(context)
if c.isError():
for error in c.errors():
Logger.log("e", error.toString())
Logger.log("d", "Loaded theme %s", self._path)
self.themeLoaded.emit()
示例14: run
# 需要导入模块: from PyQt5.QtGui import QFontDatabase [as 别名]
# 或者: from PyQt5.QtGui.QFontDatabase import addApplicationFont [as 别名]
def run():
app = QApplication(sys.argv)
QFontDatabase.addApplicationFont('./style/' + style.style_loader.FONT + '.ttf')
to_window = TournamentOrganizerWindow()
sys.exit(app.exec_())
示例15: getattr
# 需要导入模块: from PyQt5.QtGui import QFontDatabase [as 别名]
# 或者: from PyQt5.QtGui.QFontDatabase import addApplicationFont [as 别名]
if __name__ == '__main__':
import sys
if getattr(sys, 'frozen', False):
# we are running in a bundle
frozen = 'ever so'
bundle_dir = sys._MEIPASS
else:
# we are running in a normal Python environment
bundle_dir = os.path.dirname(os.path.abspath(__file__))
os.chdir(bundle_dir)
app = QApplication(sys.argv)
QFontDatabase.addApplicationFont("font/FiraSans-Regular.otf")
QFontDatabase.addApplicationFont("font/FiraSans-Medium.otf")
QFontDatabase.addApplicationFont("font/FiraSans-SemiBold.otf")
translator = QTranslator()
translator.load(QLocale.system(), "", "", "lang")
app.installTranslator(translator)
app.setWindowIcon(QIcon('icon.ico'))
player = Player()
player.show()
sys.exit(app.exec_())