当前位置: 首页>>代码示例>>Python>>正文


Python QCoreApplication.installTranslator方法代码示例

本文整理汇总了Python中PyQt4.QtCore.QCoreApplication.installTranslator方法的典型用法代码示例。如果您正苦于以下问题:Python QCoreApplication.installTranslator方法的具体用法?Python QCoreApplication.installTranslator怎么用?Python QCoreApplication.installTranslator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PyQt4.QtCore.QCoreApplication的用法示例。


在下文中一共展示了QCoreApplication.installTranslator方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from PyQt4.QtCore import QCoreApplication [as 别名]
# 或者: from PyQt4.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',
            'GeometryWrapper_{}.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'&Geometry Wrapper')
        # TODO: We are going to let the user set this up in a future iteration
        self.toolbar = self.iface.addToolBar(u'GeometryWrapper')
        self.toolbar.setObjectName(u'GeometryWrapper')
        
        # listen for browse button 
        self.dlg = GeometryWrapperDialog()
        self.dlg.inButton.clicked.connect(self.setInDataset) 

    # noinspection PyMethodMayBeStatic 
开发者ID:MACBIO,项目名称:GeoWrap,代码行数:41,代码来源:geometry_wrapper.py

示例2: test_qgis_translations

# 需要导入模块: from PyQt4.QtCore import QCoreApplication [as 别名]
# 或者: from PyQt4.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) 
开发者ID:MACBIO,项目名称:GeoWrap,代码行数:15,代码来源:test_translations.py

示例3: __init__

# 需要导入模块: from PyQt4.QtCore import QCoreApplication [as 别名]
# 或者: from PyQt4.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',
            'GoogleEarthEnginePlugin_{}.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'&Google Earth Engine')
        # TODO: We are going to let the user set this up in a future iteration
        self.toolbar = self.iface.addToolBar(u'GoogleEarthEngine')
        self.toolbar.setObjectName(u'GoogleEarthEngine')

        self.pluginIsActive = False
        self.dock_widget = None

    # noinspection PyMethodMayBeStatic 
开发者ID:gena,项目名称:qgis-earthengine-plugin,代码行数:41,代码来源:ee_plugin.py

示例4: __init__

# 需要导入模块: from PyQt4.QtCore import QCoreApplication [as 别名]
# 或者: from PyQt4.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
        """

        super(SortNumber, self).__init__() # necessary for pyqtSignal

        # 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',
            'SortNumber_{}.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 = SortNumberDialog()

        # Declare instance attributes
        self.actions = []
        self.menu = self.tr(u'&Sort and Number')
        # TODO: We are going to let the user set this up in a future iteration
        self.toolbar = self.iface.addToolBar(u'SortNumber')
        self.toolbar.setObjectName(u'SortNumber')

    # noinspection PyMethodMayBeStatic 
开发者ID:ArMoraer,项目名称:QGISSortAndNumber,代码行数:42,代码来源:sort_number.py

示例5: __init__

# 需要导入模块: from PyQt4.QtCore import QCoreApplication [as 别名]
# 或者: from PyQt4.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',
            'isochrones_{}.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 = isochronesDialog(self.iface.mainWindow(), self.iface)

        # Declare instance attributes
        self.actions = []
        self.menu = self.tr(u'&Isochrones')
        # TODO: We are going to let the user set this up in a future iteration
        self.toolbar = self.iface.addToolBar(u'isochrones')
        self.toolbar.setObjectName(u'isochrones')

    # noinspection PyMethodMayBeStatic 
开发者ID:Samweli,项目名称:isochrones,代码行数:39,代码来源:isochrone.py

示例6: __init__

# 需要导入模块: from PyQt4.QtCore import QCoreApplication [as 别名]
# 或者: from PyQt4.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',
            'HotspotAnalysis_{}.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 = HotspotAnalysisDialog()

        # Declare instance attributes
        self.actions = []
        self.menu = self.tr(u'&Hotspot Analysis')
        # TODO: We are going to let the user set this up in a future iteration
        self.toolbar = self.iface.addToolBar(u'HotspotAnalysis')
        self.toolbar.setObjectName(u'HotspotAnalysis')
        # Load output directory path
        self.dlg.lineEdit.clear()
        self.dlg.pushButton.clicked.connect(self.select_output_file)
        self.clear_ui()

    # noinspection PyMethodMayBeStatic 
开发者ID:stanly3690,项目名称:HotSpotAnalysis_Plugin,代码行数:43,代码来源:hotspot_analysis.py

示例7: __init__

# 需要导入模块: from PyQt4.QtCore import QCoreApplication [as 别名]
# 或者: from PyQt4.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',
            'mapillary_{}.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 = mapillaryDialog()

        # Declare instance attributes
        self.actions = []
        self.menu = self.tr(u'&mapillary')
        # TODO: We are going to let the user set this up in a future iteration
        self.toolbar = self.iface.addToolBar(u'mapillary')
        self.toolbar.setObjectName(u'mapillary')

    # noinspection PyMethodMayBeStatic 
开发者ID:geodrinx,项目名称:mapillary,代码行数:39,代码来源:mapillary.py

示例8: __init__

# 需要导入模块: from PyQt4.QtCore import QCoreApplication [as 别名]
# 或者: from PyQt4.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',
            'DataLoader_{}.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'&Data Loader')
        # TODO: We are going to let the user set this up in a future iteration
        self.toolbar = self.iface.addToolBar(u'DataLoader')
        self.toolbar.setObjectName(u'DataLoader')

    # noinspection PyMethodMayBeStatic 
开发者ID:OpenDataHack,项目名称:qgis-ecmwf-catalogue-plugin,代码行数:37,代码来源:Main.py

示例9: __init__

# 需要导入模块: from PyQt4.QtCore import QCoreApplication [as 别名]
# 或者: from PyQt4.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',
            'QgsResourceSharing_{}.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 = ResourceSharingDialog(iface=self.iface)

        # Declare instance attributes
        self.actions = []
        self.menu = self.tr(u'&Resource Sharing')
        # TODO: We are going to let the user set this up in a future iteration
        self.toolbar = self.iface.addToolBar(u'QgsResourceSharing')
        self.toolbar.setObjectName(u'QgsResourceSharing')

    # noinspection PyMethodMayBeStatic 
开发者ID:akbargumbira,项目名称:qgis_resources_sharing,代码行数:39,代码来源:plugin.py

示例10: __init__

# 需要导入模块: from PyQt4.QtCore import QCoreApplication [as 别名]
# 或者: from PyQt4.QtCore.QCoreApplication import installTranslator [as 别名]
def __init__(self, iface):
        self.iface = iface
        self.canvas = self.iface.mapCanvas()

        self.qgsVersion = unicode(QGis.QGIS_VERSION_INT)

        pluginPath = os.path.abspath(os.path.dirname(__file__))

        overrideLocale = QSettings().value('locale/overrideFlag', False, bool)
        if not overrideLocale:
            locale = QLocale.system().name()[:2]
        else:
            locale = QSettings().value('locale/userLocale', '')

        translationPath = '{}/i18n/landmark_{}.qm'.format(pluginPath, locale)

        if QFileInfo(translationPath).exists():
            self.translator = QTranslator()
            self.translator.load(translationPath)
            QCoreApplication.installTranslator(self.translator) 
开发者ID:matsu-reki,项目名称:GkukanMusiumdb,代码行数:22,代码来源:landmark_plugin.py

示例11: __init__

# 需要导入模块: from PyQt4.QtCore import QCoreApplication [as 别名]
# 或者: from PyQt4.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
        """
        QSettings().setValue("ckan_browser/isopen", False)
        # 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',
            'CKANBrowser_{}.qm'.format(locale))
        
        # load english file for testing
#         locale_path = os.path.join(
#             self.plugin_dir,
#             'i18n',
#             'CKANBrowser_en.qm')
        
        if not os.path.exists(locale_path):
            locale_path = os.path.join(
                self.plugin_dir,
                'i18n',
                'CKANBrowser_en.qm')
        
        if os.path.exists(locale_path):
            self.translator = QTranslator()
            self.translator.load(locale_path)

            if qVersion() > '4.3.3':
                QCoreApplication.installTranslator(self.translator)

        self.settings = Settings()
        self.settings.load()
        self.util = Util(self.settings, self.iface.mainWindow())

        # TODO ping API

        # Create the dialog (after translation) and keep reference
#         self.dlg = CKANBrowserDialog(self.settings, self.iface, self.iface.mainWindow())

        # Declare instance attributes
        self.actions = []
        self.menu = self.util.tr(u'&Open Data (CKAN) Browser')
        # TODO: We are going to let the user set this up in a future iteration
        self.toolbar = self.iface.addToolBar(u'Open Data (CKAN) Browser')
        self.toolbar.setObjectName(u'Open Data (CKAN) Browser') 
开发者ID:BergWerkGIS,项目名称:QGIS-CKAN-Browser,代码行数:56,代码来源:ckan_browser.py

示例12: __init__

# 需要导入模块: from PyQt4.QtCore import QCoreApplication [as 别名]
# 或者: from PyQt4.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__)
        self.elevation_dir = os.path.join(self.plugin_dir, 'elevation')
        print self.elevation_dir

        # initialize locale
        locale = QSettings().value('locale/userLocale')[0:2]
        locale_path = os.path.join(
            self.plugin_dir,
            'i18n',
            '{}.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 = ElevationPluginDialog()
        self.dlg.choose_dir_button.clicked.connect(self.open_browse)

        # Declare instance attributes
        self.actions = []
        self.menu = self.tr(u'&QGIS Elevation Plugin')

        # Making GDAL visible
        local_path = '/usr/local/bin:'
        if local_path not in os.environ['PATH']:
            os.environ['PATH'] = local_path + os.environ['PATH']

        # Checking the presence of elevation library
        try:
            import elevation
            print elevation.util.selfcheck(elevation.datasource.TOOLS)
        except:
            self.clear_and_push_message("Installing elevation library!", QgsMessageBar.WARNING, 10)
            pip.main(['install', '--target=%s' % self.elevation_dir, 'elevation'])
            if self.elevation_dir not in sys.path:
                sys.path.append(self.elevation_dir)
            self.clear_and_push_message("Elevation Library correctly installed!", QgsMessageBar.INFO, 5) 
开发者ID:bopen,项目名称:qgis-elevation-plugin,代码行数:54,代码来源:qgis_elevation_plugin.py

示例13: __init__

# 需要导入模块: from PyQt4.QtCore import QCoreApplication [as 别名]
# 或者: from PyQt4.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.dlg = MapzenIsochronesDialog()
        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',
            'MapzenIsochrones_{}.qm'.format(locale))

			
        #Populate comboBox_2 with all point file layers
        for layer in qgis.utils.iface.legendInterface().layers():
                layerType = layer.type()
                if layerType == QgsMapLayer.VectorLayer and layer.wkbType() == QGis.WKBPoint:
                    self.dlg.comboBox_2.addItem(layer.name())

        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'&Mapzen Isochrones')
        # TODO: We are going to let the user set this up in a future iteration
        self.toolbar = self.iface.addToolBar(u'MapzenIsochrones')
        self.toolbar.setObjectName(u'MapzenIsochrones')

    # noinspection PyMethodMayBeStatic 
开发者ID:spatialmonk,项目名称:qgsMapzenIsochrones,代码行数:45,代码来源:mapzen_isochrones.py

示例14: __init__

# 需要导入模块: from PyQt4.QtCore import QCoreApplication [as 别名]
# 或者: from PyQt4.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
        self.canvas = self.iface.mapCanvas()
        
        # 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',
            'GkukanMusiumdb_{}.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'&gkukanmusiumdb')
        # TODO: We are going to let the user set this up in a future iteration
        self.toolbar = self.iface.addToolBar(u'GkukanMusiumdb')
        self.toolbar.setObjectName(u'GkukanMusiumdb')

        #print "** INITIALIZING GkukanMusiumdb"

        self.pluginIsActive = False
        self.dockwidget = None

        self.GKukanSetting()
        self.land=LandmarkPlugin(self.iface)

        self.projectloaded=False

        QgsProject.instance().readProject.connect(self.project_loaded)


    # noinspection PyMethodMayBeStatic 
开发者ID:matsu-reki,项目名称:GkukanMusiumdb,代码行数:52,代码来源:gkukanmusiumdb.py


注:本文中的PyQt4.QtCore.QCoreApplication.installTranslator方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。