我希望为 ArcGIS 创建一个 python 插件工具,其工作方式类似于使用 python 的 ArcGIS 识别工具。该工具必须是这样的,当我单击一个点或要素时,它会从要素中读取特定属性。
具体来说,我希望开发一个超链接工具。但目前只能从要素类或图层的字段中读取超链接。我还可以创建一个带有按钮的 GUI,这些按钮充当打开我的照片和已链接到我的功能的全景图的超链接。
我已经包含我的代码来澄清我的问题。亲切的问候。以下是我目前拥有的代码:
#!/usr/bin/env python
import PyQt4
import sys
from PyQt4 import QtGui
from PyQt4 import QtCore
import Image
import os, sys
import webbrowser
import arcpy
class HyperlinkWindow(QtGui.QMainWindow):
def __init__(self, win_parent = None):
#Init the base class
QtGui.QMainWindow.__init__(self, win_parent)
self.create_widgets()
def create_widgets(self):
#Widgets
self.panorama_button = QtGui.QPushButton("Panorama")
self.photo_button = QtGui.QPushButton("Photo")
#connect signal
QtCore.QObject.connect(self.panorama_button
, QtCore.SIGNAL("clicked()")
, self.on_hello_clicked)
QtCore.QObject.connect(self.photo_button
, QtCore.SIGNAL("clicked()")
, self.on_photo_clicked)
#Horizontal layout
h_box = QtGui.QHBoxLayout()
h_box.addWidget(self.panorama_button)
h_box.addWidget(self.photo_button)
#Create central widget, add layout and set
central_widget = QtGui.QWidget()
central_widget.setLayout(h_box)
self.setCentralWidget(central_widget)
def on_hello_clicked(x):
featureClass = "My_Featureclass"
rows = arcpy.SearchCursor(featureClass)
row = rows.next()
while row:
webbrowser.open(row.Panorama)
print row.panorama
row = rows.next()
def on_photo_clicked(y):
featureClass1 = "My_Featureclass"
rows1 = arcpy.SearchCursor(featureClass1)
row1 = rows1.next()
while row1:
webbrowser.open (row1.Photo)
print row1.Photo
row1 = rows1.next()