本文整理汇总了Python中PyQt5.QtCore.QCoreApplication.installTranslator方法的典型用法代码示例。如果您正苦于以下问题:Python QCoreApplication.installTranslator方法的具体用法?Python QCoreApplication.installTranslator怎么用?Python QCoreApplication.installTranslator使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtCore.QCoreApplication
的用法示例。
在下文中一共展示了QCoreApplication.installTranslator方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from PyQt5.QtCore import QCoreApplication [as 别名]
# 或者: from PyQt5.QtCore.QCoreApplication import installTranslator [as 别名]
def __init__(self, iface):
"""Constructor.
:param iface: An interface instance that will be passed to this class
which provides the hook by which you can manipulate the QGIS
application at run time.
:type iface: QgsInterface
"""
# Save reference to the QGIS interface
self.iface = iface
# initialize plugin directory
self.plugin_dir = os.path.dirname(__file__)
# initialize locale
locale = QSettings().value('locale/userLocale')[0:2]
locale_path = os.path.join(
self.plugin_dir,
'i18n',
'RasterVisionPlugin_{}.qm'.format(locale))
if os.path.exists(locale_path):
self.translator = QTranslator()
self.translator.load(locale_path)
if qVersion() > '4.3.3':
QCoreApplication.installTranslator(self.translator)
# Create the dialog (after translation) and keep reference
self.experiment_controller = ExperimentDialogController(self.iface)
self.predict_controller = PredictDialogController(self.iface)
self.profiles_controller = ProfilesDialogController()
self.config_controller = ConfigDialogController()
# Declare instance attributes
self.actions = []
self.menu = self.tr(u'&Raster Vision')
# TODO: We are going to let the user set this up in a future iteration
self.toolbar = self.iface.addToolBar(u'RasterVisionPlugin')
self.toolbar.setObjectName(u'RasterVisionPlugin')
# noinspection PyMethodMayBeStatic
示例2: test_qgis_translations
# 需要导入模块: from PyQt5.QtCore import QCoreApplication [as 别名]
# 或者: from PyQt5.QtCore.QCoreApplication import installTranslator [as 别名]
def test_qgis_translations(self):
"""Test that translations work."""
parent_path = os.path.join(__file__, os.path.pardir, os.path.pardir)
dir_path = os.path.abspath(parent_path)
file_path = os.path.join(
dir_path, 'i18n', 'af.qm')
translator = QTranslator()
translator.load(file_path)
QCoreApplication.installTranslator(translator)
expected_message = 'Goeie more'
real_message = QCoreApplication.translate("@default", 'Good morning')
self.assertEqual(real_message, expected_message)
示例3: __init__
# 需要导入模块: from PyQt5.QtCore import QCoreApplication [as 别名]
# 或者: from PyQt5.QtCore.QCoreApplication import installTranslator [as 别名]
def __init__(self, iface):
self.provider = HqgisProvider()
# Save reference to the QGIS interface
self.iface = iface
# initialize plugin directory
self.plugin_dir = os.path.dirname(__file__)
# initialize locale
locale = QSettings().value('locale/userLocale')[0:2]
locale_path = os.path.join(
self.plugin_dir,
'i18n',
'Hqgis_{}.qm'.format(locale))
if os.path.exists(locale_path):
self.translator = QTranslator()
self.translator.load(locale_path)
if qVersion() > '4.3.3':
QCoreApplication.installTranslator(self.translator)
# Create the dialog (after translation) and keep reference
self.dlg = HqgisDialog()
# Declare instance attributes
self.actions = []
self.menu = self.tr(u'&Hqgis')
# TODO: We are going to let the user set this up in a future iteration
self.toolbar = self.iface.addToolBar(u'Hqgis')
self.toolbar.setObjectName(u'Hqgis')
self.getMapCoordinates = GetMapCoordinates(self.iface)
self.getMapCoordTool = None
# noinspection PyMethodMayBeStatic
示例4: changeTranslator
# 需要导入模块: from PyQt5.QtCore import QCoreApplication [as 别名]
# 或者: from PyQt5.QtCore.QCoreApplication import installTranslator [as 别名]
def changeTranslator(self, fileName):
#QC.removeTranslator(self.translator)
self.app.removeTranslator(self.translator)
logging.debug('changeTranslator() called with file: {}'.format(fileName))
self.translator.load(join(self.mod_path, 'translations/') + fileName)
#QC.installTranslator(self.translator)
self.app.installTranslator(self.translator)
logging.debug('Translation: {}'.format(QC.translate('', 'Save')))
"""
defaultLocale =QLocale.system().name()
"""
#defaultLocale.truncate(defaultLocale.lastIndexOf(''''))
#logging.debug('Locale: {}'.format())
示例5: __init__
# 需要导入模块: from PyQt5.QtCore import QCoreApplication [as 别名]
# 或者: from PyQt5.QtCore.QCoreApplication import installTranslator [as 别名]
def __init__(self, persepolis_setting):
super().__init__()
icon = QIcon()
self.persepolis_setting = persepolis_setting
# add support for other languages
locale = str(self.persepolis_setting.value('settings/locale'))
QLocale.setDefault(QLocale(locale))
self.translator = QTranslator()
if self.translator.load(':/translations/locales/ui_' + locale, 'ts'):
QCoreApplication.installTranslator(self.translator)
self.setWindowIcon(QIcon.fromTheme('persepolis', QIcon(':/persepolis.svg')))
self.setWindowTitle(QCoreApplication.translate("setting_ui_tr", 'Preferences'))
# set ui direction
ui_direction = self.persepolis_setting.value('ui_direction')
if ui_direction == 'rtl':
self.setLayoutDirection(Qt.RightToLeft)
elif ui_direction in 'ltr':
self.setLayoutDirection(Qt.LeftToRight)
global icons
icons = ':/' + str(self.persepolis_setting.value('settings/icons')) + '/'
window_verticalLayout = QVBoxLayout(self)
self.pressKeyLabel = QLabel(self)
window_verticalLayout.addWidget(self.pressKeyLabel)
self.capturedKeyLabel = QLabel(self)
window_verticalLayout.addWidget(self.capturedKeyLabel)
# window buttons
buttons_horizontalLayout = QHBoxLayout()
buttons_horizontalLayout.addStretch(1)
self.cancel_pushButton = QPushButton(self)
self.cancel_pushButton.setIcon(QIcon(icons + 'remove'))
buttons_horizontalLayout.addWidget(self.cancel_pushButton)
self.ok_pushButton = QPushButton(self)
self.ok_pushButton.setIcon(QIcon(icons + 'ok'))
buttons_horizontalLayout.addWidget(self.ok_pushButton)
window_verticalLayout.addLayout(buttons_horizontalLayout)
# labels
self.pressKeyLabel.setText(QCoreApplication.translate("setting_ui_tr", "Press new keys"))
self.cancel_pushButton.setText(QCoreApplication.translate("setting_ui_tr", "Cancel"))
self.ok_pushButton.setText(QCoreApplication.translate("setting_ui_tr", "OK"))
示例6: __init__
# 需要导入模块: from PyQt5.QtCore import QCoreApplication [as 别名]
# 或者: from PyQt5.QtCore.QCoreApplication import installTranslator [as 别名]
def __init__(self, parent, gid, persepolis_setting):
super().__init__(persepolis_setting)
self.persepolis_setting = persepolis_setting
self.parent = parent
self.gid = gid
self.status = None
self.resume_pushButton.clicked.connect(self.resumePushButtonPressed)
self.stop_pushButton.clicked.connect(self.stopPushButtonPressed)
self.pause_pushButton.clicked.connect(self.pausePushButtonPressed)
self.download_progressBar.setValue(0)
self.limit_pushButton.clicked.connect(self.limitPushButtonPressed)
self.limit_frame.setEnabled(False)
self.limit_checkBox.toggled.connect(self.limitCheckBoxToggled)
self.after_frame.setEnabled(False)
self.after_checkBox.toggled.connect(self.afterCheckBoxToggled)
self.after_pushButton.clicked.connect(self.afterPushButtonPressed)
# add support for other languages
locale = str(self.persepolis_setting.value('settings/locale'))
QLocale.setDefault(QLocale(locale))
self.translator = QTranslator()
if self.translator.load(':/translations/locales/ui_' + locale, 'ts'):
QCoreApplication.installTranslator(self.translator)
# check if limit speed activated by user or not
add_link_dictionary = self.parent.persepolis_db.searchGidInAddLinkTable(gid)
limit = str(add_link_dictionary['limit_value'])
if limit != '0':
limit_number = limit[:-1]
limit_unit = limit[-1]
self.limit_spinBox.setValue(float(limit_number))
if limit_unit == 'K':
self.after_comboBox.setCurrentIndex(0)
else:
self.after_comboBox.setCurrentIndex(1)
self.limit_checkBox.setChecked(True)
self.after_comboBox.currentIndexChanged.connect(self.afterComboBoxChanged)
self.limit_comboBox.currentIndexChanged.connect(self.limitComboBoxChanged)
self.limit_spinBox.valueChanged.connect(self.limitComboBoxChanged)
# set window size and position
size = self.persepolis_setting.value(
'ProgressWindow/size', QSize(595, 274))
position = self.persepolis_setting.value(
'ProgressWindow/position', QPoint(300, 300))
self.resize(size)
self.move(position)
# close window with ESC key
示例7: __init__
# 需要导入模块: from PyQt5.QtCore import QCoreApplication [as 别名]
# 或者: from PyQt5.QtCore.QCoreApplication import installTranslator [as 别名]
def __init__(self, parent, dict, persepolis_setting):
super().__init__(persepolis_setting)
self.persepolis_setting = persepolis_setting
self.dict = dict
self.parent = parent
# add support for other languages
locale = str(self.persepolis_setting.value('settings/locale'))
QLocale.setDefault(QLocale(locale))
self.translator = QTranslator()
if self.translator.load(':/translations/locales/ui_' + locale, 'ts'):
QCoreApplication.installTranslator(self.translator)
# connecting buttons
self.open_pushButtun.clicked.connect(self.openFile)
self.open_folder_pushButtun.clicked.connect(self.openFolder)
self.ok_pushButton.clicked.connect(self.okButtonPressed)
# labels
# find gid
gid = self.dict['gid']
# get file_path from data base
self.add_link_dict = self.parent.persepolis_db.searchGidInAddLinkTable(gid)
file_path = self.add_link_dict['download_path']
# save_as
self.save_as_lineEdit.setText(file_path)
self.save_as_lineEdit.setToolTip(file_path)
# link
link = str(self.dict['link'])
self.link_lineEdit.setText(link)
self.link_lineEdit.setToolTip(link)
# file_name
window_title = str(self.dict['file_name'])
file_name = QCoreApplication.translate("after_download_src_ui_tr", "<b>File name</b>: ") + \
window_title
self.setWindowTitle(window_title)
self.file_name_label.setText(file_name)
# size
size = QCoreApplication.translate("after_download_src_ui_tr", "<b>Size</b>: ") + str(self.dict['size'])
self.size_label.setText(size)
# disable link_lineEdit and save_as_lineEdit
self.link_lineEdit.setEnabled(False)
self.save_as_lineEdit.setEnabled(False)
# set window size and position
size = self.persepolis_setting.value(
'AfterDownloadWindow/size', QSize(570, 290))
position = self.persepolis_setting.value(
'AfterDownloadWindow/position', QPoint(300, 300))
self.resize(size)
self.move(position)
示例8: __init__
# 需要导入模块: from PyQt5.QtCore import QCoreApplication [as 别名]
# 或者: from PyQt5.QtCore.QCoreApplication import installTranslator [as 别名]
def __init__(self, iface):
"""Constructor.
:param iface: An interface instance that will be passed to this class
which provides the hook by which you can manipulate the QGIS
application at run time.
:type iface: QgsInterface
"""
# Save reference to the QGIS interface
self.iface = iface
# add Processing loadAlgorithms
# init dialog and dzetsaka dock
QDialog.__init__(self)
#sender = self.sender()
self.settings = QSettings()
self.loadConfig()
self.provider = dzetsakaProvider(self.providerType)
# initialize plugin directory
self.plugin_dir = os.path.dirname(__file__)
if self.firstInstallation is True:
self.showWelcomeWidget()
# initialize locale
"""
locale = self.settings.value('locale/userLocale')[0:2]
locale_path = os.path.join(
self.plugin_dir,
'i18n',
'dzetsaka_{}.qm'.format(locale))
if os.path.exists(locale_path):
self.translator = QTranslator()
self.translator.load(locale_path)
if qVersion() > '4.3.3':
QCoreApplication.installTranslator(self.translator)
"""
# Declare instance attributes
self.actions = []
self.menu = self.tr(u'&dzetsaka')
# # TODO: We are going to let the user set this up in a future iteration
# self.toolbar = self.iface.addToolBar(u'dzetsaka')
# self.toolbar.setObjectName(u'dzetsaka')
self.pluginIsActive = False
self.dockwidget = None
#
# param
self.lastSaveDir = ''
# run dock
# self.run()
示例9: __init__
# 需要导入模块: from PyQt5.QtCore import QCoreApplication [as 别名]
# 或者: from PyQt5.QtCore.QCoreApplication import installTranslator [as 别名]
def __init__(self, iface):
'''Constructor.
:param iface: An interface instance that will be passed to this class
which provides the hook by which you can manipulate the QGIS
application at run time.
:type iface: QgsInterface
'''
# Save reference to the QGIS interface
self.iface = iface
# initialize plugin directory
self.plugin_dir = os.path.dirname(__file__)
# initialize locale
locale = QSettings().value('locale/userLocale')[0:2]
locale_path = os.path.join(
self.plugin_dir,
'i18n',
'OfflineMapMatching_{}.qm'.format(locale))
if os.path.exists(locale_path):
self.translator = QTranslator()
self.translator.load(locale_path)
if qVersion() > '4.3.3':
QCoreApplication.installTranslator(self.translator)
# Create the dialog (after translation) and keep reference
self.dlg = OfflineMapMatchingDialog()
# Declare instance attributes
self.actions = []
self.menu = self.tr(u'&Offline-MapMatching')
# TODO: We are going to let the user set this up in a future iteration
self.toolbar = self.iface.addToolBar(u'OfflineMapMatching')
self.toolbar.setObjectName(u'OfflineMapMatching')
#add help-document to the GUI
dir = os.path.dirname(__file__)
file = os.path.abspath(os.path.join(dir, 'help_docs', 'help.html'))
if os.path.exists(file):
with open(file) as helpf:
help = helpf.read()
self.dlg.textBrowser_help.insertHtml(help)
self.dlg.textBrowser_help.moveCursor(QTextCursor.Start)
#declare additional instance vars
self.map_matcher = MapMatcher()
self.provider = OfflineMapMatchingProvider()
#connect slots and signals
self.dlg.comboBox_trajectory.currentIndexChanged.connect(self.startPopulateFieldsComboBox)
self.dlg.pushButton_start.clicked.connect(self.startMapMatching)
#set a default crs to avoid problems in QGIS 3.4
self.dlg.mQgsProjectionSelectionWidget.setCrs(QgsCoordinateReferenceSystem('EPSG:4326'))
# noinspection PyMethodMayBeStatic