本文整理匯總了Python中qgis_interface.QgisInterface方法的典型用法代碼示例。如果您正苦於以下問題:Python qgis_interface.QgisInterface方法的具體用法?Python qgis_interface.QgisInterface怎麽用?Python qgis_interface.QgisInterface使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類qgis_interface
的用法示例。
在下文中一共展示了qgis_interface.QgisInterface方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: get_qgis_app
# 需要導入模塊: import qgis_interface [as 別名]
# 或者: from qgis_interface import QgisInterface [as 別名]
def get_qgis_app():
""" Start one QGIS application to test against.
:returns: Handle to QGIS app, canvas, iface and parent. If there are any
errors the tuple members will be returned as None.
:rtype: (QgsApplication, CANVAS, IFACE, PARENT)
If QGIS is already running the handle to that app will be returned.
"""
try:
from PyQt4 import QtGui, QtCore
from qgis.core import QgsApplication
from qgis.gui import QgsMapCanvas
from qgis_interface import QgisInterface
except ImportError:
return None, None, None, None
global QGIS_APP # pylint: disable=W0603
if QGIS_APP is None:
gui_flag = True # All test will run qgis in gui mode
#noinspection PyPep8Naming
QGIS_APP = QgsApplication(sys.argv, gui_flag)
# Make sure QGIS_PREFIX_PATH is set in your env if needed!
QGIS_APP.initQgis()
s = QGIS_APP.showSettings()
LOGGER.debug(s)
global PARENT # pylint: disable=W0603
if PARENT is None:
#noinspection PyPep8Naming
PARENT = QtGui.QWidget()
global CANVAS # pylint: disable=W0603
if CANVAS is None:
#noinspection PyPep8Naming
CANVAS = QgsMapCanvas(PARENT)
CANVAS.resize(QtCore.QSize(400, 400))
global IFACE # pylint: disable=W0603
if IFACE is None:
# QgisInterface is a stub implementation of the QGIS plugin interface
#noinspection PyPep8Naming
IFACE = QgisInterface(CANVAS)
return QGIS_APP, CANVAS, IFACE, PARENT
示例2: get_qgis_app
# 需要導入模塊: import qgis_interface [as 別名]
# 或者: from qgis_interface import QgisInterface [as 別名]
def get_qgis_app():
"""
Start one QGIS application to test against.
If QGIS is already running the handle to that app is returned.
:returns:
| A tuple containing:
| - *QgsApplication* -- QGIS application
| - *QgisInterface* -- QGIS interface
| - *QgsMapCanvas* -- QGIS map canvas
| - *QWidget* -- parent
:rtype: tuple
"""
try:
from PyQt4 import QtGui, QtCore
from qgis.core import QgsApplication
from qgis.gui import QgsMapCanvas
from qgis_interface import QgisInterface
except ImportError:
return None, None, None, None
global QGIS_APP
if QGIS_APP is None:
# All test will run qgis in gui mode
gui_flag = True
QGIS_APP = QgsApplication(sys.argv, gui_flag)
# make sure QGIS_PREFIX_PATH is set in your env if needed
QGIS_APP.initQgis()
s = QGIS_APP.showSettings()
LOGGER.debug(s)
global PARENT
if PARENT is None:
PARENT = QtGui.QWidget()
global CANVAS
if CANVAS is None:
CANVAS = QgsMapCanvas(PARENT)
CANVAS.resize(QtCore.QSize(400, 400))
global IFACE
if IFACE is None:
# QgisInterface is a stub implementation of the QGIS plugin interface
IFACE = QgisInterface(CANVAS)
return QGIS_APP, IFACE, CANVAS, PARENT