本文整理汇总了Python中PyQt4.QtCore.QLibraryInfo类的典型用法代码示例。如果您正苦于以下问题:Python QLibraryInfo类的具体用法?Python QLibraryInfo怎么用?Python QLibraryInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QLibraryInfo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: process_designer_plugins
def process_designer_plugins(self, attrs):
if "qt_designer_plugins" not in attrs:
return attrs
plugins = attrs["qt_designer_plugins"]
del attrs["qt_designer_plugins"]
if "install" not in attrs["script_args"]:
return attrs
from PyQt4.QtCore import QLibraryInfo
info = QLibraryInfo.location(QLibraryInfo.PluginsPath)
plugins_path = os.path.join(unicode(info), "designer", "python")
if not os.path.exists(plugins_path):
os.makedirs(plugins_path)
for plugin in plugins:
path = plugin.replace("/", os.sep)
directory, file_name = os.path.split(path)
output_path = os.path.join(plugins_path, file_name)
print "Copying", path, "to", plugins_path
open(output_path, "wb").write(open(path, "rb").read())
return attrs
示例2: correr_interfaz
def correr_interfaz(app):
ESettings().cargar()
import src.ui.inicio # lint:ok
# Traductor
local = QLocale.system().name()
qtraductor = QTranslator()
qtraductor.load("qt_" + local, QLibraryInfo.location(
QLibraryInfo.TranslationsPath))
edis = EDIS()
app.setWindowIcon(QIcon(paths.ICONOS['icon']))
# Aplicar estilo
with open(os.path.join(paths.PATH,
"extras", "temas", "default.qss")) as tema:
estilo = tema.read()
app.setStyleSheet(estilo)
# Archivos de última sesión
archivos = ESettings.get('general/archivos')
# Archivos recientes
recents_files = ESettings.get('general/recientes')
if recents_files is None:
recents_files = []
edis.cargar_archivos(archivos, recents_files)
edis.show()
sys.exit(app.exec_())
示例3: __init__
def __init__(self, args=[], **kw):
QApplication.__init__(self, args)
locale = QLocale.system().name()
translator=QTranslator ()
translator.load("qt_" + locale,
QLibraryInfo.location(QLibraryInfo.TranslationsPath))
self.installTranslator(translator)
self._print_signal.connect(self._print)
示例4: copy_qt_plugins
def copy_qt_plugins(folder_names, dest): # This is only for Windows
from PyQt4.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)
示例5: __init__
def __init__(self, args=[], **kw):
QApplication.__init__(self, args)
locale = QLocale.system().name()
translator=QTranslator ()
translator.load("qt_" + locale,
QLibraryInfo.location(QLibraryInfo.TranslationsPath))
self.installTranslator(translator)
if param.style_Qt:
self.setStyle(param.style_Qt)
示例6: install_translator
def install_translator(qapp):
"""Install Qt translator to the QApplication instance"""
global QT_TRANSLATOR
if QT_TRANSLATOR is None:
qt_translator = QTranslator()
if qt_translator.load("qt_"+QLocale.system().name(),
QLibraryInfo.location(QLibraryInfo.TranslationsPath)):
QT_TRANSLATOR = qt_translator # Keep reference alive
if QT_TRANSLATOR is not None:
qapp.installTranslator(QT_TRANSLATOR)
示例7: locale
def locale(self, lang=None):
try:
lang = lang or self.lang
translate_path = QLibraryInfo.location(QLibraryInfo.TranslationsPath)
transl = self.transl = QTranslator(self)
fn = 'zebratrace_%s' % lang
if not(transl.load(fn, translate_path)):
transl.load(fn, self.translations_dir)
self.installTranslator(transl)
self.tr = lambda a: QApplication.translate("ZQApplication", a)
dialogs.tr = lambda a: QApplication.translate("@default", a)
utils.tr = lambda a: QApplication.translate("@default", a)
except locale.Error:
pass
示例8: _build_translations
def _build_translations(self, basepath):
"""Build translations_rc.py which inclues qt_xx.qm"""
from PyQt4.QtCore import QLibraryInfo
trpath = unicode(QLibraryInfo.location(QLibraryInfo.TranslationsPath))
d = tempfile.mkdtemp()
try:
for e in os.listdir(trpath):
if re.match(r'qt_[a-z]{2}(_[A-Z]{2})?\.ts$', e):
r = os.system('lrelease "%s" -qm "%s"'
% (os.path.join(trpath, e),
os.path.join(d, e[:-3] + '.qm')))
if r > 0:
self.warn('Unable to generate Qt message file'
' from %s' % e)
self.build_rc(os.path.join(basepath, 'translations_rc.py'),
d, '/translations')
finally:
shutil.rmtree(d)
示例9: build_localizations
def build_localizations(ui):
build_base_localizations()
if ui == 'cocoa':
app = cocoa_app()
loc.build_cocoa_localizations(app)
locale_dest = op.join(app.resources, 'locale')
elif ui == 'qt':
build_qt_localizations()
locale_dest = op.join('build', 'locale')
if op.exists(locale_dest):
shutil.rmtree(locale_dest)
shutil.copytree('locale', locale_dest, ignore=shutil.ignore_patterns('*.po', '*.pot'))
if ui == 'qt' and not ISLINUX:
print("Copying qt_*.qm files into the 'locale' folder")
from PyQt4.QtCore import QLibraryInfo
trfolder = QLibraryInfo.location(QLibraryInfo.TranslationsPath)
for lang in loc.get_langs('locale'):
qmname = 'qt_%s.qm' % lang
src = op.join(trfolder, qmname)
if op.exists(src):
copy(src, op.join('build', 'locale', qmname))
示例10: main
def main():
# For the translations to work, the initialization of QApplication and
# the loading of the translations must be done here instead of the
# gui module:
#
from PyQt4.QtGui import QApplication
from PyQt4.QtCore import QTranslator, QLocale, QLibraryInfo
app = QApplication(sys.argv)
translator = QTranslator()
success = translator.load(QLocale.system(), 'qt', '_',
QLibraryInfo.location(QLibraryInfo.TranslationsPath))
if not success:
success = translator.load(QLocale.system(), 'qt', '_',
utils.qt_translations_dir())
app.installTranslator(translator)
if len(sys.argv) >= 2:
filename = sys.argv[1]
else:
filename = None
interface = gui.Interface(app, False, False, [])
manager = ProgramManager(interface, session_file=filename)
manager.run()
示例11: qapplication
def qapplication(translate=True):
"""
Return QApplication instance
Creates it if it doesn't already exist
"""
if QApplication.startingUp():
app = QApplication([])
if translate:
locale = QLocale.system().name()
# Qt-specific translator
qt_translator = QTranslator()
TRANSLATORS.append(qt_translator) # Keep reference alive
paths = QLibraryInfo.location(QLibraryInfo.TranslationsPath)
if qt_translator.load("qt_"+locale, paths):
app.installTranslator(qt_translator)
# Spyder-specific translator
app_translator = QTranslator()
TRANSLATORS.append(app_translator) # Keep reference alive
if app_translator.load("spyder_"+locale, DATA_PATH):
app.installTranslator(app_translator)
else:
app = QApplication.instance()
return app
示例12: install_gettext_trans_under_qt
def install_gettext_trans_under_qt(base_folder, lang=None):
# 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 PyQt4.QtCore import QCoreApplication, QTranslator, QLocale, QLibraryInfo
if not lang:
lang = str(QLocale.system().name())[:2]
localename = get_locale_name(lang)
if localename is not None:
try:
locale.setlocale(locale.LC_ALL, localename)
except locale.Error:
logging.warning("Couldn't set locale %s", localename)
qmname = 'qt_%s' % lang
if ISLINUX:
# Under linux, a full Qt installation is already available in the system, we didn't bundle
# up the qm files in our package, so we have to load translations from the system.
qmpath = op.join(QLibraryInfo.location(QLibraryInfo.TranslationsPath), qmname)
else:
qmpath = op.join(base_folder, qmname)
qtr = QTranslator(QCoreApplication.instance())
qtr.load(qmpath)
QCoreApplication.installTranslator(qtr)
install_gettext_trans(base_folder, lang)
示例13: load_qt_locale
def load_qt_locale(app):
translator = QTranslator(app)
language = get_language()
directory = QLibraryInfo.location(QLibraryInfo.TranslationsPath)
translator.load("qt_" + language, directory)
app.installTranslator(translator)
示例14: start
def start(filenames=None, projects_path=None,
extra_plugins=None, linenos=None):
app = QApplication(sys.argv)
QCoreApplication.setOrganizationName('NINJA-IDE')
QCoreApplication.setOrganizationDomain('NINJA-IDE')
QCoreApplication.setApplicationName('NINJA-IDE')
app.setWindowIcon(QIcon(resources.IMAGES['icon']))
# Check if there is another session of ninja-ide opened
# and in that case send the filenames and projects to that session
running = ipc.is_running()
start_server = not running[0]
if running[0] and (filenames or projects_path):
sended = ipc.send_data(running[1], filenames, projects_path, linenos)
running[1].close()
if sended:
sys.exit()
else:
running[1].close()
# Create and display the splash screen
splash_pix = QPixmap(resources.IMAGES['splash'])
splash = QSplashScreen(splash_pix, Qt.WindowStaysOnTopHint)
splash.setMask(splash_pix.mask())
splash.show()
app.processEvents()
# Set the cursor to unblinking
if sys.platform != 'win32':
app.setCursorFlashTime(0)
#Set the codec for strings (QString)
QTextCodec.setCodecForCStrings(QTextCodec.codecForName('utf-8'))
#Translator
qsettings = QSettings()
language = QLocale.system().name()
lang = qsettings.value('preferences/interface/language',
defaultValue=language, type='QString') + '.qm'
lang_path = file_manager.create_path(resources.LANGS, lang)
if file_manager.file_exists(lang_path):
settings.LANGUAGE = lang_path
elif file_manager.file_exists(file_manager.create_path(
resources.LANGS_DOWNLOAD, lang)):
settings.LANGUAGE = file_manager.create_path(
resources.LANGS_DOWNLOAD, lang)
translator = QTranslator()
if settings.LANGUAGE:
translator.load(settings.LANGUAGE)
app.installTranslator(translator)
qtTranslator = QTranslator()
qtTranslator.load("qt_" + language,
QLibraryInfo.location(QLibraryInfo.TranslationsPath))
app.installTranslator(qtTranslator)
#Loading Syntax
splash.showMessage("Loading Syntax", Qt.AlignRight | Qt.AlignTop, Qt.black)
json_manager.load_syntax()
#Read Settings
splash.showMessage("Loading Settings", Qt.AlignRight | Qt.AlignTop,
Qt.black)
settings.load_settings()
#Set Stylesheet
style_applied = False
if settings.NINJA_SKIN not in ('Default', 'Classic Theme'):
file_name = ("%s.qss" % settings.NINJA_SKIN)
qss_file = file_manager.create_path(resources.NINJA_THEME_DOWNLOAD,
file_name)
if file_manager.file_exists(qss_file):
with open(qss_file) as f:
qss = f.read()
app.setStyleSheet(qss)
style_applied = True
if not style_applied:
if settings.NINJA_SKIN == 'Default':
with open(resources.NINJA_THEME) as f:
qss = f.read()
else:
with open(resources.NINJA__THEME_CLASSIC) as f:
qss = f.read()
app.setStyleSheet(qss)
#Loading Schemes
splash.showMessage("Loading Schemes",
Qt.AlignRight | Qt.AlignTop, Qt.black)
scheme = qsettings.value('preferences/editor/scheme', "default",
type='QString')
if scheme != 'default':
scheme = file_manager.create_path(resources.EDITOR_SKINS,
scheme + '.color')
if file_manager.file_exists(scheme):
resources.CUSTOM_SCHEME = json_manager.parse(open(scheme))
#Loading Shortcuts
resources.load_shortcuts()
#Loading GUI
splash.showMessage("Loading GUI", Qt.AlignRight | Qt.AlignTop, Qt.black)
#.........这里部分代码省略.........
示例15: str
#!/usr/bin/python
# vim: set fileencoding=utf-8 :
from PyQt4.QtCore import QLibraryInfo, QPluginLoader
import os.path
main_plugin_path = str(QLibraryInfo.location(QLibraryInfo.PluginsPath))
designer_plugin_path = os.path.join(main_plugin_path, 'designer')
kdewidgets_path = os.path.join(designer_plugin_path, 'kdewidgets.so')
kdelibs_present = QPluginLoader(kdewidgets_path).load()
if __name__ == '__main__':
print "Plugin Path", main_plugin_path
print "Designer plugin path", designer_plugin_path
print "Widgets Path", kdewidgets_path
print "Result", kdelibs_present