对不起。我意识到,要实现这一点,必须选择特性。如果选择了要素/点,则脚本只读取该点的属性。我设法写了一个剧本,我相信应该是我希望的。但问题是每当我运行插件ArcGIS时总是崩溃。。。在
我将把脚本附在这里给任何想要使用它的人….:import arcpy
import pythonaddins
import PyQt4
import sys
from PyQt4 import QtGui
from PyQt4 import QtCore
import Image
import os, sys
import webbrowser
class HyperlinkWindow(QtGui.QMainWindow, HyperlinkXAButton):
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):
#x = "Push Me!"
if x:
arcpy.env.workspace = "MyDatabase"
featureClass = arcpy.MakeFeatureLayer_management("MyFeatureClass","q")
fld = "Panorama"
rows = arcpy.SearchCursor(featureClass)
for row in rows:
webbrowser.open (row.getValue(fld))
def on_photo_clicked(y):
if y:
arcpy.env.workspace = "MyDatabase"
featureClass = arcpy.MakeFeatureLayer_management(MyFeatureClass","u")
fld = "Photo"
rows = arcpy.SearchCursor(featureClass)
for row in rows:
webbrowser.open (row.getValue(fld))
if __name__ == "__main__":
# Someone is launching this directly
# Create the QApplication
app = QtGui.QApplication(sys.argv)
#The Main window
main_window = HyperlinkWindow()
main_window.show()
# Enter the main loop
app.exec_()
class HyperlinkButton(object):
"""Implementation for HyperlinkButton_addin.button (Button)"""
def __init__(self):
self.enabled = True
self.checked = False
def onClick(self):
self.w = HyperlinkWindow()
self.w.show()
return
或者可以使用插件工具代替按钮。。。在