[Qgis-user] show record from table in ms-access using python

2014-06-20 Thread Suryo Miles
I have a ms-access database and i try to make QGIS plugin that take record
from table and show it in Qt, database have format like this :

NO  Skala 1 Skala2  Rekomendasi

1.  10001000Skala Sama
2.  10005000Skala Bisa digunakan
3.  50001   Skala Tidak Cocok
4.  50005   Skala Terlalu Besar

what i try to make is, when i input skala1 (ex:1000) and skala2 (ex:5000)
it automatic take Skala Bisa Digunakan from database and put it in Qt, i
try to use code like :

 def Compskala(self):
skal1 = self.ui.lineSkl_1.text() #(input)
skal2 = self.ui.lineSkl_2.text() #(input)
bandskal = ''#(from table)
if skal1 and skal2:
bandskal = ' How to direct this to table?'

but i really didn't know what i must do next to direct my code to take
record from table

Can someone help me?

Sorry for my bad english
___
Qgis-user mailing list
Qgis-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-user

[Qgis-user] show text in TextBrowser

2014-05-15 Thread Suryo Miles
, I make a QGIS plugin to parse xml and show it as a report in TextBrowser,
but when i run this plugin it didnt appear in TextBrowser and i didnt get
any error message from it, this code i use to showing text in textBrowser

def info(self, inform):
fore = open(inform, 'w' ).write()
fore.write( 'Input 1 : ' + %s % self.ui.lineSkala.text() )
fore.write( 'Input 2 : ' + %s % self.ui.lineFitur.text() )
fore.close()
jde = open(inform, 'r').read()
self.ui.textRangkum.setText(jde)

what must i add/ repair? (Sorry I am a total newb)
___
Qgis-user mailing list
Qgis-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-user

[Qgis-user] change element into Qstring in ElementTree

2014-04-28 Thread Suryo Miles
I try to make QGIS plugin to open and show metadata information in xml
format i use this code to open metadata from drive and show it in UI:













































*from PyQt4 import QtCore, QtGuifrom ui_testparse import Ui_testparseimport
xml.etree.ElementTree as ETree# create the dialog for zoom to pointclass
testparseDialog(QtGui.QDialog):def __init__(self):
QtGui.QDialog.__init__(self)# Set up the user interface from
Designer.self.ui = Ui_testparse()
self.ui.setupUi(self)opendata = self.ui.btnCari
QtCore.QObject.connect(opendata,
QtCore.SIGNAL('clicked()'),self.openxml)def openxml(self,
event=None):#open dialogopenfile =
QtGui.QFileDialog.getOpenFileName(self, 'Open File', '*.xml')
self.ui.lineLokasi.setText(openfile)#call XML data
self.isiData(openfile)def isiData(self, nmsatu):#open teks with
read modeopenteks = open(nmsatu, 'r').read()
self.ui.textXml.setText(openteks)#Parse XML from Above
self.parsenow(openteks)def parsenow(self, parse):element =
ETree.fromstring(parse)xml_obj = ETree.ElementTree(element)
for title_obj in
xml_obj.findall('./{gmd#}dateStamp/{gco#}Date'):print
elementself.ui.lineSkala.setText(element)*But the value i want
to show didn't appear in QLineEdit (LineSkala), i dont get any error
message, it just blank, xml i want to parse look like this :



*gmd:dateStamp  gco:Date2013-12-12/gco:Date   /gmd:dateStamp*

someone in forum tell me i must change element in print element to a
QString so QLineEdit can read it and show it, but i didn't know how to do
it, i really newbie in python

Can someone teach me?
___
Qgis-user mailing list
Qgis-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-user

[Qgis-user] argument 1 has unexpected type error when parse xml with ElementTree

2014-04-22 Thread Suryo Miles
I try to make plugin in QGIS Dufour to open and read xml metadata and then
to show some information in metadata i try to parse it with ElementTree and
then show it in QLineEdit, this code i use to open metadata and parse
metadata :

from PyQt4 import QtCore, QtGui
from ui_testparse import Ui_testparse
import xml.etree.ElementTree as ETree
# create the dialog for zoom to point


class testparseDialog(QtGui.QDialog):
def __init__(self):
QtGui.QDialog.__init__(self)
# Set up the user interface from Designer.
self.ui = Ui_testparse()
self.ui.setupUi(self)

opendata = self.ui.btnCari
QtCore.QObject.connect(opendata,
QtCore.SIGNAL('clicked()'),self.openxml)

def openxml(self, event=None):

#open dialog
openfile = QtGui.QFileDialog.getOpenFileName(self, 'Open File', '*.xml')

self.ui.lineLokasi.setText(openfile)

#call XML data
self.isiData(openfile)

def isiData(self, nmsatu):
#open teks with read mode
openteks = open(nmsatu, 'r').read()

self.ui.textXml.setText(openteks)

#Parse XML from Above
self.parsenow(openteks)

def parsenow(self, parse):
element = ETree.fromstring(parse)
xml_obj = ETree.ElementTree(element)
for title_obj in
xml_obj.findall('.//{http://www.isotc211.org/2005/gmd}dateStamp/'
 '{http://www.isotc211.org/2005/gco}Date'):
print element
self.ui.lineSkala.setText(element)

however when i try to run it, it give me a error message, the error message say:

Traceback (most recent call last):
  File C:\Users\Mr.Pakde/.qgis2/python/plugins\testparse\testparsedialog.py,
line 47, in openxml
self.isiData(openfile)
  File C:\Users\Mr.Pakde/.qgis2/python/plugins\testparse\testparsedialog.py,
line 56, in isiData
self.parsenow(openteks)
  File C:\Users\Mr.Pakde/.qgis2/python/plugins\testparse\testparsedialog.py,
line 64, in parsenow
self.ui.lineSkala.setText(element)
TypeError: QLineEdit.setText(QString): argument 1 has unexpected type 'Element'

Python version:
2.7.4 (default, Apr  6 2013, 19:54:46) [MSC v.1500 32 bit (Intel)]

and xml file i want to parse look like this :

gmd:dateStamp
  gco:Date2013-12-12/gco:Date

Can someone help me, Thanks in Advance
___
Qgis-user mailing list
Qgis-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-user

[Qgis-user] (no subject)

2014-04-20 Thread Suryo Miles
Hay i m new in python and i have a task to make plugin in QGIS and use this
code to open xml file and then read it in QTextBrowser, this is code i use
to open xml file :

class testparseDialog(QtGui.QDialog):
def __init__(self):
QtGui.QDialog.__init__(self)
# Set up the user interface from Designer.
self.ui = Ui_testparse()
self.ui.setupUi(self)

opendata = self.ui.btnCari
QtCore.QObject.connect(opendata,
QtCore.SIGNAL('clicked()'),self.openxml)

def openxml(self, event=None):

#open dialog
openfile = QtGui.QFileDialog.getOpenFileName(self, 'Open File',
'*.xml')

self.ui.lineLokasi.setText(openfile)

#call XML data
self.isiData(openfile)

def isiData(self, nmsatu):
#open teks with read mode
openteks = open(nmsatu, 'r').read()

self.ui.textXml.setText(openteks)

but then when i try to parse xml i open with code above i read it must be
converted into a variable with the type of list/dictionary and only after
that it can be parsed with ElementTree or other parse method

can someone tell me how to convert xml into variable?

and Xml i try to parse have format like this

gmd:dateStamp
  gco:Date2013-12-12/gco:Date

Thanks for Advance
___
Qgis-user mailing list
Qgis-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-user

[Qgis-user] convert xml into variable with type of list/dictionary

2014-04-20 Thread Suryo Miles
Hay i m new in python and i have a task to make plugin in QGIS and use this
code to open xml file and then read it in QTextBrowser, this is code i use
to open xml file :

class testparseDialog(QtGui.QDialog)
:
def __init__(self):
QtGui.QDialog.__init__(self)
# Set up the user interface from Designer.
self.ui = Ui_testparse()
self.ui.setupUi(self)

opendata = self.ui.btnCari
QtCore.QObject.connect(opendata,
QtCore.SIGNAL('clicked()'),self.openxml)

def openxml(self, event=None):

#open dialog
openfile = QtGui.QFileDialog.getOpenFileName(self, 'Open File',
'*.xml')

self.ui.lineLokasi.setText(openfile)

#call XML data
self.isiData(openfile)

def isiData(self, nmsatu):
#open teks with read mode
openteks = open(nmsatu, 'r').read()

self.ui.textXml.setText(openteks)

but then when i try to parse xml i open with code above i read it must be
converted into a variable with the type of list/dictionary and only after
that it can be parsed with ElementTree or other parse method

can someone tell me how to convert xml into variable?

and Xml i try to parse have format like this

gmd:dateStamp
  gco:Date2013-12-12/gco:Date

Thanks for Advance
___
Qgis-user mailing list
Qgis-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-user

[Qgis-user] argument 1 has unexpected type error when try parse xml

2014-04-13 Thread Suryo Miles
I try to parse xml from a string source, I make code to open xml from drive
and read it then parse it and show in QlineEdit

This code I use:

From PyQt4 import QtCore, QtGui
from ui_testparse import Ui_testparse
import xml.etree.ElementTree as ETree
# create the dialog for zoom to point


class testparseDialog(QtGui.QDialog):
def __init__(self):
QtGui.QDialog.__init__(self)
# Set up the user interface from Designer.
self.ui = Ui_testparse()
self.ui.setupUi(self)

opendata = self.ui.btnCari
QtCore.QObject.connect(opendata,
QtCore.SIGNAL('clicked()'),self.openxml)

def openxml(self, event=None):

#open dialog
openfile = QtGui.QFileDialog.getOpenFileName(self, 'Open File',
'*.xml')

self.ui.lineLokasi.setText(openfile)

#call XML data
self.isiData(openfile)

def isiData(self, nmsatu):
#open teks with read mode
openteks = open(nmsatu, 'r').read()

self.ui.textXml.setText(openteks)

#Parse XML from Above
self.parsenow(openteks)

def parsenow(self, parse):
element = ETree.fromstring(parse)
xml_obj = ETree.ElementTree(element)
for title_obj in xml_obj.findall('./{gmd#}dateStamp/{gco#}Date'):
print xml_obj
self.ui.lineSkala.setText(xml_obj)

But I get error message like this

Traceback (most recent call last):
  File
C:\Users\Mr.Pakde/.qgis2/python/plugins\testparse\testparsedialog.py,
line 47, in openxml
self.isiData(openfile)
  File
C:\Users\Mr.Pakde/.qgis2/python/plugins\testparse\testparsedialog.py,
line 56, in isiData
self.parsenow(openteks)
  File
C:\Users\Mr.Pakde/.qgis2/python/plugins\testparse\testparsedialog.py,
line 63, in parsenow
self.ui.lineSkala.setText(xml_obj)
TypeError: QLineEdit.setText(QString): argument 1 has unexpected type
'ElementTree'

Python version:
2.7.4 (default, Apr  6 2013, 19:54:46) [MSC v.1500 32 bit (Intel)]


Someone has say to me i must do something like xml_obj.text to get the
string but i dont know how

can someone help me??
___
Qgis-user mailing list
Qgis-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-user

[Qgis-user] QGIS Plugin to open and parse xml metadata

2014-03-24 Thread Suryo Miles
I make plugin in QGIS to open and read XML file, then parse it and show
scale map from it, its a big xml file and line with scale information have
format like this

gmd:denominatorgco:IntegerScaleValue/gco:Integer/gmd:denominator

and i try code like this to open xml file and then parse it:

from PyQt4 import QtCore, QtGuifrom ui_latih import Ui_latih# create
the dialog for zoom to point

class latihDialog(QtGui.QDialog):
def __init__(self):
QtGui.QDialog.__init__(self)
# Set up the user interface from Designer.
self.ui = Ui_latih()
self.ui.setupUi(self)

cariButton = self.ui.btnCari
QtCore.QObject.connect(cariButton, QtCore.SIGNAL('clicked()'),self.cari)

def cari(self, event=None):

#open dialog
filename = QtGui.QFileDialog.getOpenFileName(self, 'Open File', '*.xml')

self.ui.lineFile.setText(filename)

#call text
self.isiDataFile(filename)

def isiDataFile(self, nmfile):
#open with read mode
teksFile = open(nmfile, 'r').read()

self.ui.textFile.setText(teksFile)

import xml.etree.ElementTree as ET

tree = ET.parse(filename)
doc = tree.getroot()

for elem in doc.findall('Default_Config/gmd:denominator'):
x = elem.tag, elem.text
self.ui.lineSkala.setText(x)

for elem in doc.findall('Default_Config/gmd:MD_Format'):
y = elem.tag, elem.text
self.ui.lineFitur.setText(y)

I try using Element Tree to parse and show ScaleValue in LineEdit because
its integrated in python, but i have error message like this :

NameError: name 'filename' is not defined

i am really newbie in python and xml parser, can i pass the xml location
from open xml code to

tree = ET.parse( )

because i plan to open more than one xml file and scale in one and another
xml file have different value as well

Can Someone help me?
___
Qgis-user mailing list
Qgis-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-user

[Qgis-user] Open Metadata and Show Specific Information

2014-03-11 Thread Suryo Miles
I try make plugin to open and read metadata (.xml) and show information
inside metadata like map scale, map fiture and bounding box and auto fill
it to QLineEdit

This code i use to open metadata


cariButton = self.ui.btnCari
QtCore.QObject.connect(cariButton, QtCore.SIGNAL('clicked()'),self.cari)

def cari(self, event=None):

#open dialog
filename = QtGui.QFileDialog.getOpenFileName(self, 'Open File', '*.xml')

self.ui.lineFile.setText(filename)

#panggil isi data
self.isiDataFile(filename)

def isiDataFile(self, nmfile):
#buka dengan open mode baca
teksFile = open(nmfile, 'r').read()

self.ui.textFile.setText(teksFile)

but metadata have a complicated structure, like the line that have
information about scale

gmd:scaleDenominatorgmd:MD_RepresentativeFractiongmd:denominator**gco:Integer10/gco:Interger**/gmd:scaleDenominator/gmd:MD_RepresentativeFraction/gmd:denominator

it is possible to just take scale number (10) and auto fill it in
QLineEdit when metadata has opened?
___
Qgis-user mailing list
Qgis-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-user

[Qgis-user] Plugin QGIS Error QTextEdit.setPlainText(QString): not enough arguments

2014-01-01 Thread Suryo Miles
I try to make save as button but i got this error message when try to save
file in my directory

File
C:\Users\Mr.Pakde/.qgis2/python/plugins\condition\conditiondialog.py,
line 80, in saveAs
self._save( _filename )
File
C:\Users\Mr.Pakde/.qgis2/python/plugins\condition\conditiondialog.py,
line 68, in _save
f.write( 'Rekomendasi :' + str(self.ui.textRec1.setPlainText() ) )
TypeError: QTextEdit.setPlainText(QString): not enough arguments

this is my code

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 = 'Data dapat digunakam'
else:
compare = 'Data tidak cocok'
self.ui.textRec1.setPlainText(compare)

def _save(self, simpan):
f = open( simpan, 'w' )
f.write( 'Input 1 :' + str(self.ui.lineInput1.text()) )
f.write( 'Input 2 :' + str(self.ui.lineInput2.text()) )
f.write( 'Rekomendasi :' + str(self.ui.textRec1.setPlainText())
)
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 )
___
Qgis-user mailing list
Qgis-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-user

Re: [Qgis-user] Plugin QGIS Error QTextEdit.setPlainText(QString): not enough arguments

2014-01-01 Thread Suryo Miles
happy new year too

uhm, but yes i use textBrowser to self.ui.textRec1 and it seems textBrowser
didn't accept (.text) and (setPlainText)

i try it and got error message like  X dont have attribute text


On Wed, Jan 1, 2014 at 1:25 PM, Jorge Tornero jtorlis...@gmail.com wrote:

 As a quick answer: you're setting the tex(not getting)t in

  f.write( 'Rekomendasi :' + str(self.ui.textRec1.setPlainText()) )

 It should be something like

  f.write( 'Rekomendasi :' + str(self.ui.textRec1.text()) )

 (I guess that self.ui.textRec1 is a QLineEdit, of course)

 Happy New Year!!


 Jorge Tornero



 2014/1/1 Suryo Miles suryomiles...@gmail.com

 I try to make save as button but i got this error message when try to
 save file in my directory

 File
 C:\Users\Mr.Pakde/.qgis2/python/plugins\condition\conditiondialog.py,
 line 80, in saveAs
 self._save( _filename )
 File
 C:\Users\Mr.Pakde/.qgis2/python/plugins\condition\conditiondialog.py,
 line 68, in _save
 f.write( 'Rekomendasi :' + str(self.ui.textRec1.setPlainText() ) )
 TypeError: QTextEdit.setPlainText(QString): not enough arguments

 this is my code

 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 = 'Data dapat digunakam'
 else:
 compare = 'Data tidak cocok'
 self.ui.textRec1.setPlainText(compare)

 def _save(self, simpan):
 f = open( simpan, 'w' )
 f.write( 'Input 1 :' + str(self.ui.lineInput1.text()) )
 f.write( 'Input 2 :' + str(self.ui.lineInput2.text()) )
 f.write( 'Rekomendasi :' +
 str(self.ui.textRec1.setPlainText()) )
 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 )



 ___
 Qgis-user mailing list
 Qgis-user@lists.osgeo.org
 http://lists.osgeo.org/mailman/listinfo/qgis-user



___
Qgis-user mailing list
Qgis-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-user

[Qgis-user] Need help with write and save as in QGIS plugin

2013-12-29 Thread Suryo Miles
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 0x0B2264F8Condition 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?
___
Qgis-user mailing list
Qgis-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-user

Re: [Qgis-user] Write and Save As with python in QGIS plugin

2013-12-26 Thread Suryo Miles
It works but now i have a different error message, it say

 File C:\Users\Mr.Pakde/.qgis2/python/plugins\latih\latihdialog.py, line
70, in saveAs
_filename = %s % simpan
NameError: global name 'simpan' is not defined

It is because i use python 3 and the code is from older version?

Thank you


On Wed, Dec 25, 2013 at 6:09 PM, Suryo Miles suryomiles...@gmail.comwrote:

 Sorry i late to reply, i m trying it as soon as posible

 Thank you all for the answer

 @Joshua : wow nice observation yeah you are right i m a indonesian

___
Qgis-user mailing list
Qgis-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-user

Re: [Qgis-user] Write and Save As with python in QGIS plugin

2013-12-26 Thread Suryo Miles
Silly me, i forgot to change the code below, the real problem is this error
message

[File C:\Users\Mr.Pakde/.qgis2/python/plugins\latih\latihdialog.py, line
71, in saveAs
self._save( _filename )
  File C:\Users\Mr.Pakde/.qgis2/python/plugins\latih\latihdialog.py, line
59, in _save
f.write( %s % self.nmfile.text() )
AttributeError: 'latihDialog' object has no attribute 'nmfile']


Can someone help me?


On Fri, Dec 27, 2013 at 2:21 AM, Suryo Miles suryomiles...@gmail.comwrote:

 It works but now i have a different error message, it say

  File C:\Users\Mr.Pakde/.qgis2/python/plugins\latih\latihdialog.py,
 line 70, in saveAs
 _filename = %s % simpan
 NameError: global name 'simpan' is not defined

 It is because i use python 3 and the code is from older version?

 Thank you


 On Wed, Dec 25, 2013 at 6:09 PM, Suryo Miles suryomiles...@gmail.comwrote:

 Sorry i late to reply, i m trying it as soon as posible

 Thank you all for the answer

 @Joshua : wow nice observation yeah you are right i m a indonesian



___
Qgis-user mailing list
Qgis-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-user

Re: [Qgis-user] Write and Save As with python in QGIS plugin

2013-12-25 Thread Suryo Miles
Sorry i late to reply, i m trying it as soon as posible

Thank you all for the answer

@Joshua : wow nice observation yeah you are right i m a indonesian
___
Qgis-user mailing list
Qgis-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-user

[Qgis-user] Open and read shapefile plugin in QGIS dufour

2013-12-10 Thread Suryo Miles
I try to make plugin to read shapefile with plugin builder in QGIS and i
try to import pyshp in plugin to read shapefiles but i got this error
message

 Traceback (most recent call last):
  File C:\Users\Mr.Pakde/.qgis2/python/plugins\shpread\shpreaddialog.py,
line 42, in baca
shapefile.Reader(shapefiles/blockgroups)
  File C:\Users\Mr.Pakde/.qgis2/python/plugins\shpread\shapefile.py, line
220, in __init__
self.load(args[0])
  File C:\Users\Mr.Pakde/.qgis2/python/plugins\shpread\shapefile.py, line
253, in load
raise ShapefileException(Unable to open %s.shp % shapeName)
ShapefileException: Unable to open shapefiles/blockgroups.shp

Python version:
2.7.4 (default, Apr  6 2013, 19:54:46) [MSC v.1500 32 bit (Intel)]

--and this is code i use ( i put it in dialog.py)---

# insert every signal connection here!
cariButton = self.ui.btnShp
QtCore.QObject.connect(cariButton,
QtCore.SIGNAL('clicked()'),self.baca)

def baca(self):
sf = QtGui.QFileDialog.getOpenFileName(self, 'Open File', '*.shp')
shapefile.Reader(shapefiles/blockgroups)
shapes = sf.shapes()
# Read the bounding box from the 4th shape
shapes[3].bbox
[-122.485792, 37.7869313, -122.446285, 37.8110192]
#  Read the 8th point in the 4th shape
shapes[3].points[7]
[-122.471063, 37.7874028]

#panggil isi data
self.isiDataFile(sf)

def isiDataFile(self, nmfile):
#buka dengan open mode baca
teksFile = open(nmfile, 'r').read()

self.ui.textShp.setText(teksFile)


can someone help me?
___
Qgis-user mailing list
Qgis-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-user

[Qgis-user] QGIS plugin to compare 2 different input

2013-12-03 Thread Suryo Miles
I try to make a QGIS plugin to compare 2 different number with 2 input
data, and i want to compare input 1 and input 2, but i dont know how to use
python condition to compare 2 random number input

i try it like this

def Compare1(self):
input1 = self.ui.lineInput1.text()
input2 = self.ui.lineInput2.text()
compare = ''
if input1 == input2:
compare = 'number was same'
else
compare = 'number not same'
self.ui.textRec1.setPlainText(compare)

Can someone help me solve this

Thanks Before
___
Qgis-user mailing list
Qgis-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-user

[Qgis-user] 'QLineEdit' object has no attribute 'delete' error in QGIS Dufour plugin

2013-12-01 Thread Suryo Miles
When i try to open text in textBrowser with command read i got this error
message

def cari(self, event=None):

#open dialog
filename = QtGui.QFileDialog.getOpenFileName(self, 'Open File',
'*.xml')

if filename:
self.ui.lineFile.delete(0, END)
self.ui.lineFile.insert(END, filename)

#panggil isi data
self.isiDataFile(filename)

def isiDataFile(self, nmfile):
#buka dengan open mode baca
teksFile = open(nmfile, 'r').read()

self.ui.textFile.delete('1.0', END)
self.ui.textFile.insert('1.0', teksFile)

Traceback (most recent call last):
  File C:\Users\Mr.Pakde/.qgis2/python/plugins\latih\latihdialog.py, line
44, in cari
self.ui.lineFile.delete(0, END)

 'QLineEdit' object has no attribute 'delete'

Can someone help me?
I m new in python and QGIS so i dont know what i must do
___
Qgis-user mailing list
Qgis-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-user

[Qgis-user] Open File Dialog Plugin Error

2013-11-28 Thread Suryo Miles
I tried to make plugin open file dialog in QGIS Dofour 2.0.1

I write my code like this (attachment) and try to run it in QGIS plugin,
but nothing happened ( the GUI show up but when i try to click the button,
nothing happened, even a error message is not pop up) since its not show a
error message i dont know what to do

Can someone help me?
# Import the PyQt and QGIS libraries
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from qgis.core import *
# Initialize Qt resources from file resources.py
import resources_rc
# Import the code for the dialog
from latihdialog import latihDialog
import os.path


class latih:

def __init__(self, iface):
# Save reference to the QGIS interface
self.iface = iface
# initialize plugin directory
self.plugin_dir = os.path.dirname(__file__)
# initialize locale
locale = QSettings().value(locale/userLocale)[0:2]
localePath = os.path.join(self.plugin_dir, 'i18n', 
'latih_{}.qm'.format(locale))

if os.path.exists(localePath):
self.translator = QTranslator()
self.translator.load(localePath)

if qVersion()  '4.3.3':
QCoreApplication.installTranslator(self.translator)

# Create the dialog (after translation) and keep reference
self.dlg = latihDialog()

def initGui(self):
# Create action that will start plugin configuration
self.action = QAction(
QIcon(:/plugins/latih/icon.png),
uini latihan, self.iface.mainWindow())
# connect the action to the run method
self.action.triggered.connect(self.run)

# Add toolbar button and menu item
self.iface.addToolBarIcon(self.action)
self.iface.addPluginToMenu(ulatih, self.action)

def unload(self):
# Remove the plugin menu item and icon
self.iface.removePluginMenu(ulatih, self.action)
self.iface.removeToolBarIcon(self.action)

# run method that performs all the real work
def run(self):

# show the dialog
self.dlg.show()

#connect
   
QObject.connect(self.dlg.ui.btnCari,SIGNAL(accepted()),self.cari)

def cari(self):
#membuka dialog
#connect
   
QObject.connect(self.dlg.ui.btnCari,SIGNAL(accepted()),self.cari)

def cari(self):
#open dialog
filename = QtGui.QFileDialog.getOpenFileName(self, 'Open File', '.')
fname = open(filename)
data = fname.read()
self.textEdit.setText(data)
fname.close() 

#Show in Line Edit
if namafile:
self.lineEdit.delete(0, END)
self.lineEdit.insert(END, namafile)
 
# call isidata
self.isiDataFile(namafile)

def isiDataFile(self, nmfile):
#open file with read mode
teksFile = open(nmfile, 'r').read()

#show text in TextView
self.txtFile.delete('1.0', END)
self.txtFile.insert('1.0', teksFile)

# Run the dialog event loop
result = self.dlg.exec_()
# See if OK was pressed
if result == 1:
# do something useful (delete the line containing pass and
# substitute with your code)
pass___
Qgis-user mailing list
Qgis-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-user