本文整理汇总了Python中qgis.PyQt.QtWidgets.QTabWidget.addTab方法的典型用法代码示例。如果您正苦于以下问题:Python QTabWidget.addTab方法的具体用法?Python QTabWidget.addTab怎么用?Python QTabWidget.addTab使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类qgis.PyQt.QtWidgets.QTabWidget
的用法示例。
在下文中一共展示了QTabWidget.addTab方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: DBManager
# 需要导入模块: from qgis.PyQt.QtWidgets import QTabWidget [as 别名]
# 或者: from qgis.PyQt.QtWidgets.QTabWidget import addTab [as 别名]
#.........这里部分代码省略.........
if table is None:
self.infoBar.pushMessage(self.tr("Select the table you want export to file."), QgsMessageBar.INFO,
self.iface.messageTimeout())
return
inLayer = table.toMapLayer()
if inLayer.type() != QgsMapLayer.VectorLayer:
self.infoBar.pushMessage(
self.tr("Select a vector or a tabular layer you want export."),
QgsMessageBar.WARNING, self.iface.messageTimeout())
return
from .dlg_export_vector import DlgExportVector
dlg = DlgExportVector(inLayer, table.database(), self)
dlg.exec_()
inLayer.deleteLater()
def runSqlWindow(self):
db = self.tree.currentDatabase()
if db is None:
self.infoBar.pushMessage(self.tr("No database selected or you are not connected to it."),
QgsMessageBar.INFO, self.iface.messageTimeout())
# force displaying of the message, it appears on the first tab (i.e. Info)
self.tabs.setCurrentIndex(0)
return
from .dlg_sql_window import DlgSqlWindow
query = DlgSqlWindow(self.iface, db, self)
dbname = db.connection().connectionName()
tabname = self.tr("Query ({0})").format(dbname)
index = self.tabs.addTab(query, tabname)
self.tabs.setTabIcon(index, db.connection().icon())
self.tabs.setCurrentIndex(index)
query.nameChanged.connect(functools.partial(self.update_query_tab_name, index, dbname))
def runSqlLayerWindow(self, layer):
from .dlg_sql_layer_window import DlgSqlLayerWindow
query = DlgSqlLayerWindow(self.iface, layer, self)
lname = layer.name()
tabname = self.tr("Layer ({0})").format(lname)
index = self.tabs.addTab(query, tabname)
# self.tabs.setTabIcon(index, db.connection().icon())
self.tabs.setCurrentIndex(index)
def update_query_tab_name(self, index, dbname, queryname):
if not queryname:
queryname = self.tr("Query")
tabname = u"%s (%s)" % (queryname, dbname)
self.tabs.setTabText(index, tabname)
def showSystemTables(self):
self.tree.showSystemTables(self.actionShowSystemTables.isChecked())
def registerAction(self, action, menuName, callback=None):
""" register an action to the manager's main menu """
if not hasattr(self, '_registeredDbActions'):
self._registeredDbActions = {}
if callback is not None:
def invoke_callback(x):
return self.invokeCallback(callback)
if menuName is None or menuName == "":
示例2: ModelerParametersDialog
# 需要导入模块: from qgis.PyQt.QtWidgets import QTabWidget [as 别名]
# 或者: from qgis.PyQt.QtWidgets.QTabWidget import addTab [as 别名]
#.........这里部分代码省略.........
if isinstance(output, (OutputRaster, OutputVector, OutputTable,
OutputHTML, OutputFile, OutputDirectory)):
label = QLabel(output.description + '<'
+ output.__class__.__name__ + '>')
item = QLineEdit()
if hasattr(item, 'setPlaceholderText'):
item.setPlaceholderText(ModelerParametersDialog.ENTER_NAME)
self.verticalLayout.addWidget(label)
self.verticalLayout.addWidget(item)
self.valueItems[output.name] = item
label = QLabel(' ')
self.verticalLayout.addWidget(label)
label = QLabel(self.tr('Parent algorithms'))
self.dependenciesPanel = self.getDependenciesPanel()
self.verticalLayout.addWidget(label)
self.verticalLayout.addWidget(self.dependenciesPanel)
self.verticalLayout.addStretch(1000)
self.setLayout(self.verticalLayout)
self.setPreviousValues()
self.setWindowTitle(self._alg.name)
self.verticalLayout2 = QVBoxLayout()
self.verticalLayout2.setSpacing(2)
self.verticalLayout2.setMargin(0)
self.tabWidget = QTabWidget()
self.tabWidget.setMinimumWidth(300)
self.paramPanel = QWidget()
self.paramPanel.setLayout(self.verticalLayout)
self.scrollArea = QScrollArea()
self.scrollArea.setWidget(self.paramPanel)
self.scrollArea.setWidgetResizable(True)
self.tabWidget.addTab(self.scrollArea, self.tr('Parameters'))
self.webView = QWebView()
html = None
url = None
isText, help = self._alg.help()
if help is not None:
if isText:
html = help
else:
url = QUrl(help)
else:
html = self.tr('<h2>Sorry, no help is available for this '
'algorithm.</h2>')
try:
if html:
self.webView.setHtml(html)
elif url:
self.webView.load(url)
except:
self.webView.setHtml(self.tr('<h2>Could not open help file :-( </h2>'))
self.tabWidget.addTab(self.webView, 'Help')
self.verticalLayout2.addWidget(self.tabWidget)
self.verticalLayout2.addWidget(self.buttonBox)
self.setLayout(self.verticalLayout2)
self.buttonBox.accepted.connect(self.okPressed)
self.buttonBox.rejected.connect(self.cancelPressed)
QMetaObject.connectSlotsByName(self)
def getAvailableDependencies(self):
if self._algName is None:
dependent = []
else:
示例3: GeometryDiffViewerDialog
# 需要导入模块: from qgis.PyQt.QtWidgets import QTabWidget [as 别名]
# 或者: from qgis.PyQt.QtWidgets.QTabWidget import addTab [as 别名]
class GeometryDiffViewerDialog(QDialog):
def __init__(self, geoms, crs, parent = None):
super(GeometryDiffViewerDialog, self).__init__(parent)
self.geoms = geoms
self.crs = crs
self.initGui()
def initGui(self):
layout = QVBoxLayout()
self.tab = QTabWidget()
self.table = QTableView()
self.setLayout(layout)
self.canvas = QgsMapCanvas()
self.canvas.setCanvasColor(Qt.white)
settings = QSettings()
self.canvas.enableAntiAliasing(settings.value("/qgis/enable_anti_aliasing", False, type = bool))
self.canvas.useImageToRender(settings.value("/qgis/use_qimage_to_render", False, type = bool))
self.canvas.mapSettings().setDestinationCrs(self.crs)
action = settings.value("/qgis/wheel_action", 0, type = float)
zoomFactor = settings.value("/qgis/zoom_factor", 2, type = float)
self.canvas.setWheelAction(QgsMapCanvas.WheelAction(action), zoomFactor)
self.panTool = QgsMapToolPan(self.canvas)
self.canvas.setMapTool(self.panTool)
execute(self.createLayers)
model = GeomDiffTableModel(self.data)
self.table.setModel(model)
self.table.resizeColumnsToContents()
self.table.resizeRowsToContents()
self.tab.addTab(self.canvas, "Map view")
self.tab.addTab(self.table, "Table view")
layout.addWidget(self.tab)
self.resize(600, 500)
self.setWindowTitle("Geometry comparison")
def createLayers(self):
textGeometries = []
for geom in self.geoms:
text = geom.exportToWkt()
valid = " -1234567890.,"
text = "".join([c for c in text if c in valid])
textGeometries.append(text.split(","))
lines = difflib.Differ().compare(textGeometries[0], textGeometries[1])
self.data = []
for line in lines:
if line.startswith("+"):
self.data.append([None, line[2:]])
if line.startswith("-"):
self.data.append([line[2:], None])
if line.startswith(" "):
self.data.append([line[2:], line[2:]])
types = [("LineString", lineBeforeStyle, lineAfterStyle),
("Polygon", polygonBeforeStyle, polygonAfterStyle)]
layers = []
extent = self.geoms[0].boundingBox()
for i, geom in enumerate(self.geoms):
geomtype = types[int(geom.type() - 1)][0]
style = types[int(geom.type() - 1)][i + 1]
layer = loadLayerNoCrsDialog(geomtype + "?crs=" + self.crs.authid(), "layer", "memory")
pr = layer.dataProvider()
feat = QgsFeature()
feat.setGeometry(geom)
pr.addFeatures([feat])
layer.loadNamedStyle(style)
layer.updateExtents()
layers.append(layer)
QgsMapLayerRegistry.instance().addMapLayer(layer, False)
extent.combineExtentWith(geom.boundingBox())
layer = loadLayerNoCrsDialog("Point?crs=%s&field=changetype:string" % self.crs.authid(), "points", "memory")
pr = layer.dataProvider()
feats = []
for coords in self.data:
coord = coords[0] or coords[1]
feat = QgsFeature()
x, y = coord.strip().split(" ")
x, y = (float(x), float(y))
pt = QgsGeometry.fromPoint(QgsPoint(x, y))
feat.setGeometry(pt)
if coords[0] is None:
changetype = "A"
elif coords[1] is None:
changetype = "R"
else:
changetype = "U"
feat.setAttributes([changetype])
feats.append(feat)
pr.addFeatures(feats)
layer.loadNamedStyle(pointsStyle)
QgsMapLayerRegistry.instance().addMapLayer(layer, False)
layers.append(layer)
self.mapLayers = [QgsMapCanvasLayer(lay) for lay in layers]
self.canvas.setLayerSet(self.mapLayers)
#.........这里部分代码省略.........