ну просто я не совсем весь код кинула
остальное работало до того как я вставила кусок того кода
вот абсолютно весь
Код: Выделить всё
# -*- coding: utf-8 -*-
# Import the PyQt and QGIS libraries
import sys,os
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from qgis.core import *
class HelloWorld:
def __init__(self, iface):
# Save reference to the QGIS interface
self.iface = iface
self.canvas = iface.mapCanvas()
def initGui(self):
# Create action that will start plugin
self.action = QAction(QIcon(":/plugins/"), "&HelloWorld", self.iface.mainWindow())
# connect the action to the run method
QObject.connect(self.action, SIGNAL("activated()"), self.hello_world)
# Add toolbar button and menu item
self.iface.addPluginToMenu("HelloWorld", self.action)
def unload(self):
# Remove the plugin menu item and icon
self.iface.removePluginMenu("HelloWorld",self.action)
# run
def hello_world(self):
QMessageBox.information(self.iface.mainWindow(), QCoreApplication.translate('HelloWorld', "HelloWorld"), QCoreApplication.translate('HelloWorld', "HelloWorld"))
f=open('temp/op.txt', 'w')
layer = self.iface.activeLayer()
feats = layer.selectedFeatures()
for feat in feats:
attrs = feat.attributeMap()
for (k,attr) in attrs.iteritems():
if k in [0,1,2]:
if k ==1:
f.write("%d:Ploshad - %s\r\n" % (k, attr.toString()))
if k ==2:
f.write("%d:Nomer vylela - %s\r\n" % (k, attr.toString()))
MyProgramme = QApplication(sys.argv)
MainWidget = QVBox(None)
MainWidget.setCaption("Hello!")
HelloLabel = QLabel("Hello World!", MainWidget)
CloseButton = QPushButton("Quit", MainWidget)
MyProgramme.setMainWidget(MainWidget)
MyProgramme.connect(CloseButton, SIGNAL("clicked()"), MainWidget, SLOT("close()"))
MainWidget.show()
MyProgramme.exec_loop()
f.close()
if __name__ == "__main__":
pass
Последний раз редактировалось
Cathrin 09 июн 2012, 11:53, всего редактировалось 1 раз.