<div dir="ltr"><div><div><div><div>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<br>
<br></div>i make my code like this<br><br> class conditionDialog(QtGui.QDialog):<br> def __init__(self):<br> QtGui.QDialog.__init__(self)<br> # Set up the user interface from Designer.<br> self.ui = Ui_condition()<br>
self.ui.setupUi(self)<br><br> Recomend = self.ui.btnProc<br> QtCore.QObject.connect(Recomend, QtCore.SIGNAL('clicked()'),self.Compare1)<br> RecSec = self.ui.btnProc2<br> QtCore.QObject.connect(RecSec, QtCore.SIGNAL('clicked()'),self.Compare2)<br>
Smpan = self.ui.btnSave<br> QtCore.QObject.connect(Smpan, QtCore.SIGNAL('clicked()'),self.saveAs) <br><br> def Compare1(self):<br> input1 = self.ui.lineInput1.text()<br> input2 = self.ui.lineInput2.text()<br>
compare = ''<br> if input1 == input2:<br> compare = 'Matching'<br> else:<br> compare = 'Not Matching'<br> self.ui.textRec1.setPlainText(compare)<br>
<br> def Compare2(self):<br> dat1 = self.ui.lineCond1.text()<br> dat2 = self.ui.lineCond2.text()<br> hitung = ''<br> if dat1 == dat2:<br> hitung = 'Scale is Matching'<br>
elif dat1 >= dat2:<br> hitung = 'Still can be used'<br> else:<br> hitung = 'Cannot be used'<br> self.ui.textRec2.setPlainText(hitung)<br><br> def _save(self, simpan): <br>
f = open( simpan, 'w' )<br> f.write( 'Input 1 :' + "%s" % self.ui.lineInput1.text() )<br> f.write( 'Input 2 :' + "%s" % self.ui.lineInput2.text() )<br> f.write( 'Recomendation :' + (str(compare)+'\n' )<br>
f.write( 'Data 1 :' + "%s" % self.ui.lineCond1.text() )<br> f.write( 'Data 2 :' + "%s" % self.ui.lineCond2.text() )<br> f.close()<br> def savefile(self):<br> if self.simpan:<br>
self._save( "%s" % self.simpan )<br> else:<br> self.saveAs()<br><br> def saveAs(self):<br> tulis = QtGui.QFileDialog(self).getSaveFileName()<br> if tulis !="":<br>
_filename = "%s" % tulis<br> self._save( _filename )<br><br></div>But my save file looks messed up, it going straight not descend<br></div>this the example:<br>"Input 1 :Input NumberInput 2:Input NumberRekomendasi :<PyQt4.QtGui.QTextEdit object at 0x0B2264F8>Condition 1Condition 2<br>
</div><div>it got error on recomendation and i cannot save it in any text format ( it going like a unknown format file)<br></div><div>can someone help me?<br></div></div>