[Qgis-user] Need help with write and save as in QGIS plugin
Suryo Miles
suryomiles666 at gmail.com
Sun Dec 29 14:48:55 PST 2013
I m trying to make QGIS plugin that compare 2 map scale with Input1 and
Input2 and Information about scale when clicked the button, and then i want
to write and save it in pdf format file
i make my code like this
class conditionDialog(QtGui.QDialog):
def __init__(self):
QtGui.QDialog.__init__(self)
# Set up the user interface from Designer.
self.ui = Ui_condition()
self.ui.setupUi(self)
Recomend = self.ui.btnProc
QtCore.QObject.connect(Recomend,
QtCore.SIGNAL('clicked()'),self.Compare1)
RecSec = self.ui.btnProc2
QtCore.QObject.connect(RecSec,
QtCore.SIGNAL('clicked()'),self.Compare2)
Smpan = self.ui.btnSave
QtCore.QObject.connect(Smpan,
QtCore.SIGNAL('clicked()'),self.saveAs)
def Compare1(self):
input1 = self.ui.lineInput1.text()
input2 = self.ui.lineInput2.text()
compare = ''
if input1 == input2:
compare = 'Matching'
else:
compare = 'Not Matching'
self.ui.textRec1.setPlainText(compare)
def Compare2(self):
dat1 = self.ui.lineCond1.text()
dat2 = self.ui.lineCond2.text()
hitung = ''
if dat1 == dat2:
hitung = 'Scale is Matching'
elif dat1 >= dat2:
hitung = 'Still can be used'
else:
hitung = 'Cannot be used'
self.ui.textRec2.setPlainText(hitung)
def _save(self, simpan):
f = open( simpan, 'w' )
f.write( 'Input 1 :' + "%s" % self.ui.lineInput1.text() )
f.write( 'Input 2 :' + "%s" % self.ui.lineInput2.text() )
f.write( 'Recomendation :' + (str(compare)+'\n' )
f.write( 'Data 1 :' + "%s" % self.ui.lineCond1.text() )
f.write( 'Data 2 :' + "%s" % self.ui.lineCond2.text() )
f.close()
def savefile(self):
if self.simpan:
self._save( "%s" % self.simpan )
else:
self.saveAs()
def saveAs(self):
tulis = QtGui.QFileDialog(self).getSaveFileName()
if tulis !="":
_filename = "%s" % tulis
self._save( _filename )
But my save file looks messed up, it going straight not descend
this the example:
"Input 1 :Input NumberInput 2:Input NumberRekomendasi
:<PyQt4.QtGui.QTextEdit object at 0x0B2264F8>Condition 1Condition 2
it got error on recomendation and i cannot save it in any text format ( it
going like a unknown format file)
can someone help me?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20131230/81f492f2/attachment.html>
More information about the Qgis-user
mailing list