本文整理汇总了Python中PyQt5.QtCore.QLibraryInfo类的典型用法代码示例。如果您正苦于以下问题:Python QLibraryInfo类的具体用法?Python QLibraryInfo怎么用?Python QLibraryInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QLibraryInfo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: config
def config(self):
if self.packages is not None:
print("packages", self.packages)
return self.packages
import sipconfig, os
try:
from PyQt4 import pyqtconfig
cfg = pyqtconfig.Configuration()
qtdir = cfg.qt_lib_dir
sipdir = os.path.dirname(cfg.pyqt_mod_dir)
self.plugin_dir = os.path.join(cfg.qt_dir, 'plugins')
except ImportError:
from PyQt5.QtCore import QLibraryInfo
qtdir = QLibraryInfo.location(QLibraryInfo.LibrariesPath)
self.plugin_dir = QLibraryInfo.location(QLibraryInfo.PluginsPath)
sipdir = os.path.dirname(sipconfig.__file__)
if not os.path.exists(qtdir):
print("sip: Qtdir %r does not exist"%(qtdir))
# half-broken installation? ignore.
raise ImportError
# Qt is GHETTO!
dyld_library_path = os.environ.get('DYLD_LIBRARY_PATH', '').split(':')
if qtdir not in dyld_library_path:
dyld_library_path.insert(0, qtdir)
os.environ['DYLD_LIBRARY_PATH'] = ':'.join(dyld_library_path)
self.packages = set()
for fn in os.listdir(sipdir):
fullpath = os.path.join(sipdir, fn)
if os.path.isdir(fullpath):
self.packages.add(fn)
if fn in ('PyQt4', 'PyQt5'):
# PyQt4 and later has a nested structure, also import
# subpackage to ensure everything get seen.
for sub in os.listdir(fullpath):
if ".py" not in sub:
self.packages.add('%s.%s'%(fn, sub.replace(".so","")))
# Causes a python3-related syntax error (metaclass keyword),
# and you probably don't need it:
#if "PyQt4.uic" in self.packages and sys.version_info.major != 3:
# print("WARNING: PyQt uic module found.")
# print("avoid python3 metaclass syntax errors by adding 'PyQt4.uic' to your excludes option.")
print("sip: packages: %s"%(self.packages,))
return self.packages
示例2: version
def version():
"""Return a string with various version informations."""
lines = ["qutebrowser v{}".format(qutebrowser.__version__)]
gitver = _git_str()
if gitver is not None:
lines.append("Git commit: {}".format(gitver))
lines.append("Backend: {}".format(_backend()))
lines += [
'',
'{}: {}'.format(platform.python_implementation(),
platform.python_version()),
'Qt: {}'.format(qt_version()),
'PyQt: {}'.format(PYQT_VERSION_STR),
'',
]
lines += _module_versions()
lines += ['pdf.js: {}'.format(_pdfjs_version())]
lines += [
'SSL: {}'.format(QSslSocket.sslLibraryVersionString()),
'',
]
qapp = QApplication.instance()
if qapp:
style = qapp.style()
lines.append('Style: {}'.format(style.metaObject().className()))
importpath = os.path.dirname(os.path.abspath(qutebrowser.__file__))
lines += [
'Platform: {}, {}'.format(platform.platform(),
platform.architecture()[0]),
'Frozen: {}'.format(hasattr(sys, 'frozen')),
"Imported from {}".format(importpath),
"Qt library executable path: {}, data path: {}".format(
QLibraryInfo.location(QLibraryInfo.LibraryExecutablesPath),
QLibraryInfo.location(QLibraryInfo.DataPath)
)
]
lines += _os_info()
lines += [
'',
'Paths:',
]
for name, path in _path_info().items():
lines += ['{}: {}'.format(name, path)]
return '\n'.join(lines)
示例3: __init__
def __init__(self, parent=None):
super(Window, self).__init__(parent)
model = FileListModel(self)
model.setDirPath(QLibraryInfo.location(QLibraryInfo.PrefixPath))
label = QLabel("Directory")
lineEdit = QLineEdit()
label.setBuddy(lineEdit)
view = QListView()
view.setModel(model)
self.logViewer = QTextBrowser()
self.logViewer.setSizePolicy(QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred))
lineEdit.textChanged.connect(model.setDirPath)
lineEdit.textChanged.connect(self.logViewer.clear)
model.numberPopulated.connect(self.updateLog)
layout = QGridLayout()
layout.addWidget(label, 0, 0)
layout.addWidget(lineEdit, 0, 1)
layout.addWidget(view, 1, 0, 1, 2)
layout.addWidget(self.logViewer, 2, 0, 1, 2)
self.setLayout(layout)
self.setWindowTitle("Fetch More Example")
示例4: main
def main():
"""Main app function."""
import sys
from os.path import dirname, realpath, exists
app = QApplication(sys.argv)
filePath = dirname(realpath(__file__))
locale = QLocale.system().name()
if locale == 'es_CU':
locale = 'es_ES'
# locale = 'es_ES'
appTranslator = QTranslator()
if exists(filePath + '/translations/'):
appTranslator.load(filePath + "/translations/videomorph_" + locale)
else:
appTranslator.load(
"/usr/share/videomorph/translations/videomorph_" + locale)
app.installTranslator(appTranslator)
qtTranslator = QTranslator()
qtTranslator.load("qt_" + locale,
QLibraryInfo.location(QLibraryInfo.TranslationsPath))
app.installTranslator(qtTranslator)
mainWin = MMWindow()
if mainWin.check_conversion_lib():
mainWin.show()
sys.exit(app.exec_())
示例5: run
def run():
"""start GUI
The function will create the main thread for Qt Gui. It will set the
language to system locals an start an instance of the main window.
"""
def install_translator(filename, folder, app):
locale = QtCore.QLocale.system().name()
translator = QtCore.QTranslator()
if translator.load(filename.format(locale), folder):
app.installTranslator(translator)
return translator
args = handle_cli_args()
sys.excepthook = handle_exception
multiprocessing.freeze_support()
app = QtWidgets.QApplication(sys.argv)
# set translation language
folder = godirec.resource_filename("godirec", 'data/language')
translator1 = install_translator("godirec_{}", folder, app)
if hasattr(sys, "frozen"):
qt_folder = godirec.resource_filename("godirec", "translations")
else:
qt_folder = QLibraryInfo.location(QLibraryInfo.TranslationsPath)
translator2 = install_translator("qtbase_{}", qt_folder, app)
window = main.GodiRecWindow()
window.show()
if "gdr_file" in args:
window.setupProject(args["gdr_file"], False)
else:
audio.WaveConverter.confirm_converter_backend()
if window.isNewProjectCreatedDialog():
window.createNewProject()
sys.exit(app.exec_())
示例6: dictionary_dir
def dictionary_dir(old=False):
"""Return the path (str) to the QtWebEngine's dictionaries directory."""
if qtutils.version_check('5.10', compiled=False) and not old:
datapath = standarddir.data()
else:
datapath = QLibraryInfo.location(QLibraryInfo.DataPath)
return os.path.join(datapath, 'qtwebengine_dictionaries')
示例7: simpleAppStartup
def simpleAppStartup(
argv, appinfo, mwFactory, quitOnLastWindowClosed=True, app=None, raiseIt=True, installErrorHandler=False
):
"""
Module function to start up an application that doesn't need a specialized
start up.
This function is used by all of eric6's helper programs.
@param argv list of commandline parameters (list of strings)
@param appinfo dictionary describing the application
@param mwFactory factory function generating the main widget. This
function must accept the following parameter.
<dl>
<dt>argv</dt>
<dd>list of commandline parameters (list of strings)</dd>
</dl>
@keyparam quitOnLastWindowClosed flag indicating to quit the application,
if the last window was closed (boolean)
@keyparam app reference to the application object (QApplication or None)
@keyparam raiseIt flag indicating to raise the generated application
window (boolean)
@keyparam installErrorHandler flag indicating to install an error
handler dialog (boolean)
@return exit result (integer)
"""
handleArgs(argv, appinfo)
if app is None:
# set the library paths for plugins
setLibraryPaths()
app = E5Application(argv)
app.setQuitOnLastWindowClosed(quitOnLastWindowClosed)
# the following code depends upon a valid application object
import Preferences
initializeResourceSearchPath()
QApplication.setWindowIcon(UI.PixmapCache.getIcon("eric.png"))
qt4TransDir = Preferences.getQt4TranslationsDir()
if not qt4TransDir:
qt4TransDir = QLibraryInfo.location(QLibraryInfo.TranslationsPath)
loadTranslators(qt4TransDir, app)
w = mwFactory(argv)
if quitOnLastWindowClosed:
app.lastWindowClosed.connect(app.quit)
w.show()
if raiseIt:
w.raise_()
if installErrorHandler:
# generate a graphical error handler
from E5Gui import E5ErrorMessage
eMsg = E5ErrorMessage.qtHandler()
eMsg.setMinimumSize(600, 400)
return app.exec_()
示例8: main
def main():
global app
# register representation factories
baseRepresentationFactories.registerAllFactories()
representationFactories.registerAllFactories()
# initialize the app
app = Application(sys.argv)
app.setOrganizationName("TruFont")
app.setOrganizationDomain("trufont.github.io")
app.setApplicationName("TruFont")
app.setApplicationVersion(__version__)
app.setWindowIcon(QIcon(":app.png"))
app.setAttribute(Qt.AA_UseHighDpiPixmaps, True)
# Install stream redirection
app.outputWindow = OutputWindow()
# Exception handling
sys.excepthook = exceptionCallback
# Qt's translation for itself. May not be installed.
qtTranslator = QTranslator()
qtTranslator.load("qt_" + QLocale.system().name(),
QLibraryInfo.location(QLibraryInfo.TranslationsPath))
app.installTranslator(qtTranslator)
appTranslator = QTranslator()
appTranslator.load("trufont_" + QLocale.system().name(),
os.path.dirname(os.path.realpath(__file__)) +
"/resources")
app.installTranslator(appTranslator)
# parse options and open fonts
parser = QCommandLineParser()
parser.setApplicationDescription(QApplication.translate(
"Command-line parser", "The TruFont font editor."))
parser.addHelpOption()
parser.addVersionOption()
parser.addPositionalArgument(QApplication.translate(
"Command-line parser", "files"), QApplication.translate(
"Command-line parser", "The UFO files to open."))
parser.process(app)
args = parser.positionalArguments()
if not args:
fontPath = None
# maybe load recent file
settings = QSettings()
loadRecentFile = settings.value("misc/loadRecentFile", False, bool)
if loadRecentFile:
recentFiles = settings.value("core/recentFiles", [], type=str)
if len(recentFiles) and os.path.exists(recentFiles[0]):
fontPath = recentFiles[0]
app.openFile(fontPath)
# otherwise, create a new file
if fontPath is None:
app.newFile()
else:
for fontPath in args:
app.openFile(fontPath)
sys.exit(app.exec_())
示例9: copy_qt_plugins
def copy_qt_plugins(folder_names, dest): # This is only for Windows
from PyQt5.QtCore import QLibraryInfo
qt_plugin_dir = QLibraryInfo.location(QLibraryInfo.PluginsPath)
def ignore(path, names):
if path == qt_plugin_dir:
return [n for n in names if n not in folder_names]
else:
return [n for n in names if not n.endswith('.dll')]
shutil.copytree(qt_plugin_dir, dest, ignore=ignore)
示例10: getSystemTranslationsPath
def getSystemTranslationsPath():
res = ""
if platform.system() == 'Darwin':
if inBundle():
res = QApplication.applicationDirPath() + "/../Resources/translations/"
else:
res = QLibraryInfo.location(QLibraryInfo.TranslationsPath)
elif platform.system() == "Linux":
if isFrozen():
res = QApplication.applicationDirPath() + "/translations/"
else:
res = QLibraryInfo.location(QLibraryInfo.TranslationsPath)
else:
if main_is_frozen():
res = os.path.dirname(sys.executable) + "\\translations\\"
else:
res = QLibraryInfo.location(QLibraryInfo.TranslationsPath)
return res
示例11: install_qt_trans
def install_qt_trans():
# So, we install the gettext locale, great, but we also should try to install qt_*.qm if
# available so that strings that are inside Qt itself over which I have no control are in the
# right language.
from PyQt5.QtCore import QCoreApplication, QTranslator, QLocale, QLibraryInfo
lang = str(QLocale.system().name())[:2]
qmname = 'qt_%s' % lang
qtr = QTranslator(QCoreApplication.instance())
qtr.load(qmname, QLibraryInfo.location(QLibraryInfo.TranslationsPath))
QCoreApplication.installTranslator(qtr)
示例12: main
def main():
if markups.__version_tuple__ < (2, ):
sys.exit('Error: ReText needs PyMarkups 2.0 or newer to run.')
# If we're running on Windows without a console, then discard stdout
# and save stderr to a file to facilitate debugging in case of crashes.
if sys.executable.endswith('pythonw.exe'):
sys.stdout = open(devnull, 'w')
sys.stderr = open('stderr.log', 'w')
app = QApplication(sys.argv)
app.setOrganizationName("ReText project")
app.setApplicationName("ReText")
app.setApplicationDisplayName("ReText")
app.setApplicationVersion(app_version)
app.setOrganizationDomain('mitya57.me')
if hasattr(app, 'setDesktopFileName'): # available since Qt 5.7
app.setDesktopFileName('me.mitya57.ReText.desktop')
QNetworkProxyFactory.setUseSystemConfiguration(True)
RtTranslator = QTranslator()
for path in datadirs:
if RtTranslator.load('retext_' + globalSettings.uiLanguage,
join(path, 'locale')):
break
QtTranslator = QTranslator()
QtTranslator.load("qt_" + globalSettings.uiLanguage,
QLibraryInfo.location(QLibraryInfo.TranslationsPath))
app.installTranslator(RtTranslator)
app.installTranslator(QtTranslator)
print('Using configuration file:', settings.fileName())
if globalSettings.appStyleSheet:
sheetfile = QFile(globalSettings.appStyleSheet)
sheetfile.open(QIODevice.ReadOnly)
app.setStyleSheet(QTextStream(sheetfile).readAll())
sheetfile.close()
window = ReTextWindow()
window.show()
# ReText can change directory when loading files, so we
# need to have a list of canonical names before loading
fileNames = list(map(canonicalize, sys.argv[1:]))
previewMode = False
for fileName in fileNames:
if QFile.exists(fileName):
window.openFileWrapper(fileName)
if previewMode:
window.actionPreview.setChecked(True)
window.preview(True)
elif fileName == '--preview':
previewMode = True
inputData = '' if (sys.stdin is None or sys.stdin.isatty()) else sys.stdin.read()
if inputData or not window.tabWidget.count():
window.createNew(inputData)
signal.signal(signal.SIGINT, lambda sig, frame: window.close())
sys.exit(app.exec())
示例13: init_language
def init_language():
""" Find the current locale, and install the correct translators """
# Get app instance
app = QCoreApplication.instance()
# Setup of our list of translators and paths
translator_types = (
{"type": "QT", "pattern": "qt_%s", "path": QLibraryInfo.location(QLibraryInfo.TranslationsPath)},
{
"type": "OpenShot",
"pattern": os.path.join("%s", "LC_MESSAGES", "OpenShot"),
"path": os.path.join(info.PATH, "locale"),
},
)
# Determine the environment locale, or default to system locale name
locale_names = [
os.environ.get("LANG", QLocale().system().name()),
os.environ.get("LOCALE", QLocale().system().name()),
]
# Output all system languages detected
log.info("Qt Detected Languages: {}".format(QLocale().system().uiLanguages()))
log.info("LANG Environment Variable: {}".format(os.environ.get("LANG", QLocale().system().name())))
log.info("LOCALE Environment Variable: {}".format(os.environ.get("LOCALE", QLocale().system().name())))
# Default the locale to C, for number formatting
locale.setlocale(locale.LC_ALL, "C")
# Loop through environment variables
found_language = False
for locale_name in locale_names:
# Don't try on default locale, since it fails to load what is the default language
if "en_US" in locale_name:
log.info("Skipping English language (no need for translation): {}".format(locale_name))
continue
# Go through each translator and try to add for current locale
for type in translator_types:
trans = QTranslator(app)
if find_language_match(type["pattern"], type["path"], trans, locale_name):
# Install translation
app.installTranslator(trans)
found_language = True
# Exit if found language
if found_language:
log.info("Exiting translation system (since we successfully loaded: {})".format(locale_name))
break
示例14: main
def main():
app = QApplication(sys.argv)
app.setQuitOnLastWindowClosed(False)
app.setOrganizationName('meteo-qt')
app.setOrganizationDomain('meteo-qt')
app.setApplicationName('meteo-qt')
app.setWindowIcon(QIcon(':/logo'))
filePath = os.path.dirname(os.path.realpath(__file__))
settings = QSettings()
locale = settings.value('Language')
if locale is None or locale == '':
locale = QLocale.system().name()
appTranslator = QTranslator()
if os.path.exists(filePath + '/translations/'):
appTranslator.load(filePath + "/translations/meteo-qt_" + locale)
else:
appTranslator.load("/usr/share/meteo_qt/translations/meteo-qt_" +
locale)
app.installTranslator(appTranslator)
qtTranslator = QTranslator()
qtTranslator.load("qt_" + locale,
QLibraryInfo.location(QLibraryInfo.TranslationsPath))
app.installTranslator(qtTranslator)
log_level = settings.value('Logging/Level')
if log_level == '' or log_level is None:
log_level = 'INFO'
settings.setValue('Logging/Level', 'INFO')
log_filename = os.path.dirname(settings.fileName())
if not os.path.exists(log_filename):
os.makedirs(log_filename)
log_filename = log_filename + '/meteo-qt.log'
logging.basicConfig(format='%(asctime)s %(levelname)s: %(message)s - %(module)s - %(name)s',
datefmt='%m/%d/%Y %H:%M:%S',
filename=log_filename, level=log_level)
logger = logging.getLogger('meteo-qt')
logger.setLevel(log_level)
handler = logging.handlers.RotatingFileHandler(
log_filename, maxBytes=20, backupCount=5)
logger1 = logging.getLogger()
handler1 = logging.StreamHandler()
logger1Formatter = logging.Formatter('%(levelname)s: %(message)s - %(module)s')
handler1.setFormatter(logger1Formatter)
logger.addHandler(handler)
logger1.addHandler(handler1)
m = SystemTrayIcon()
app.exec_()
示例15: launchQml
def launchQml(self, name):
import_path = self.resolveDataDir(name)
qml = self.resolveQmlFile(name)
process = QProcess(self)
process.error.connect(self.launchError)
env = QProcessEnvironment.systemEnvironment()
env.insert('QML2_IMPORT_PATH', import_path)
process.setProcessEnvironment(env)
executable = QLibraryInfo.location(QLibraryInfo.BinariesPath) + '/qmlscene'
Colors.debug("Launching:", executable)
process.start(executable, [qml])