Hi Dane,
Woudl it be possible to incorporate a open file dialog so we can open
the xml file.
Have a look at the code below. The def showDialog is not complete.
Noli
~~~~~~~~~
class MapnikWidget(QWidget):
def __init__(self, parent = None):
QWidget.__init__(self, parent)
self.map = mapnik.Map(256, 256)
self.qim = QImage()
self.startDragPos = QPoint()
self.endDragPos = QPoint()
self.drag = False
self.scale = False
self.timer = QTimer()
self.timer.timeout.connect(self.updateMap)
self.total_scale = 1.0
openFile = QtGui.QAction(QtGui.QIcon('open.png'), 'Open', self)
openFile.setShortcut('Ctrl+O')
openFile.setStatusTip('Open new File')
self.connect(openFile, QtCore.SIGNAL('triggered()'), self.showDialog)
menubar = self.menuBar()
fileMenu = menubar.addMenu('&File')
fileMenu.addAction(openFile)
def showDialog(self):
filename = QtGui.QFileDialog.getOpenFileName(self, 'Open file',
'/home')
fname = open(filename)
data = fname.read()
def load_map(self, xml):
self.map = mapnik.Map(256, 256)
mapnik.load_map(self.map, xml)
self.map.resize(self.width(), self.height())
self.zoom_all()
On 7/23/10, Noli Sicad <[email protected]> wrote:
> I run with the original map.xml in the python directory.
>
> I still get the same error:
> ~~~~~~~~~~~~~~
>
> C:\mapnik-0.7.1\demo\python>python pyqtmapnik.py map.xml
> Traceback (most recent call last):
> File "pyqtmapnik.py", line 128, in <module>
> w = MapnikWidget()
> File "pyqtmapnik.py", line 24, in __init__
> self.map = mapnik.Map(256, 256)
> AttributeError: 'module' object has no attribute 'Map'
>
> ~~~~~~~~~~~~
>
> Noli
>
> On 7/23/10, Noli Sicad <[email protected]> wrote:
>> Hi Dane,
>>
>> Sorry, I did not read at the answer to my question in your email.
>>
>> It seems that gmail folded some of the texts -
>>
>> I did not even read this;
>>
>> $ pyqtmapnik.py /path/to/map.xml
>>
>> Now, I did this command below in Windows XP
>>
>> python pyqtmapnik.py C:/mapnik-0.7.1/tilelite/demo/population.xml
>>
>> I go this error
>>
>> C:\mapnik-0.7.1\demo\python>python pyqtmapnik.py
>> C:/mapnik-0.7.1/tilelite/demo/population.xml
>> Traceback (most recent call last):
>> File "pyqtmapnik.py", line 128, in <module>
>> w = MapnikWidget()
>> File "pyqtmapnik.py", line 24, in __init__
>> self.map = mapnik.Map(256, 256)
>> AttributeError: 'module' object has no attribute 'Map'
>>
>> Is this the right command?
>>
>> $pyqtmapnik.py C:/mapnik-0.7.1/tilelite/demo/population.xml
>>
>> I eager to see a form displaying.
>>
>> Noli
>>
>> On 7/23/10, Noli Sicad <[email protected]> wrote:
>>> Hi Dane,
>>>
>>> I clone and installed Tilelite in python2.6 in Windows XP.
>>>
>>> I still get the same error
>>>
>>>>C:\\Python26\pythonw -u "pyqtmapnik.py"
>>> please provide the path to a mapnik xml stylesheet
>>>>Exit code: 1 Time: 0.911
>>>
>>> How do run the demo in the link below?
>>>
>>>>http://bitbucket.org/springmeyer/tilelite/src/tip/demo/
>>>
>>> I guess my problem is how to make Mapnik XML stylesheet working.
>>>
>>> And how do I run the demo in the above link?
>>>
>>> Noli
>>>
>>> On 7/23/10, Noli Sicad <[email protected]> wrote:
>>>> Hi Dane,
>>>>
>>>> Thanks for this example.
>>>>
>>>> I run it in SciTE IDE, I go this error (below) as expected - XML
>>>> stylesheet
>>>>
>>>> ~~~~
>>>>>C:\\Python26\pythonw -u "pyqtmapnik.py"
>>>> please provide the path to a mapnik xml stylesheet
>>>>>Exit code: 1 Time: 1.133
>>>> ~~~~
>>>>
>>>> I am new to mapnik.
>>>>
>>>>>Let us know how the attached code goes. It requires a working Mapnik
>>>>> XML
>>>>> stylesheet.
>>>>
>>>> How do I make Mapnik XML stylesheet working?
>>>>
>>>>>If you need one, grab the one try this one:
>>>>
>>>>>http://bitbucket.org/springmeyer/tilelite/src/tip/demo/
>>>>
>>>> Do I need to clone tilelite? Or just download the individual files in
>>>> the demo and where should I put this demo files?
>>>>
>>>> Regards,
>>>>
>>>> Noli
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> On 7/23/10, Dane Springmeyer <[email protected]> wrote:
>>>>> Noli,
>>>>>
>>>>> Right, zsj's script is what you want - its fun and works quite well.
>>>>>
>>>>> But to make it work you need to launch and application process (like
>>>>> QGIS
>>>>> does) and attach the widget.
>>>>>
>>>>> I've placed the code here for you to get at:
>>>>>
>>>>>
>>>>>
>>>>> http://bitbucket.org/dodobas/haosbuilder/
>>>>> On Jul 22, 2010, at 7:42 PM, Noli Sicad wrote:
>>>>>
>>>>>> Hi,
>>>>>>
>>>>>> I have been looking for simple application in python i..e. PyQt that
>>>>>> has map canvas to render shapefile or spatialite.
>>>>>
>>>>> Well, given styling logic, right?
>>>>>
>>>>> Thats the nice thing about QGIS - it gives you a pretty solid
>>>>> environment
>>>>> to
>>>>> create the styles.
>>>>>
>>>>>>
>>>>>> I like QGIS, however, qgis.core and qgis.gui is only available when
>>>>>> you installed QGIS application. It is not a regular python module.
>>>>>>
>>>>>
>>>>> Well, it should be possible, but ya, its rarely done and depending on
>>>>> the
>>>>> build of QGIS you are using could be tricky in terms of library paths
>>>>> (mac
>>>>> osx in particular)
>>>>>
>>>>>
>>>>>> I like to see a simple PyQt4 application with mapnik canvas viewer
>>>>>> without PyQGIS (QGIS API).
>>>>>>
>>>>>> I have been reading the archive of mapnik. I saw these postings.
>>>>>> http://www.mail-archive.com/[email protected]/msg02736.html
>>>>>>
>>>>>> zsj,/ feverzsj, is your "simple pyqt4 widget" that are working
>>>>>> running now?
>>>>>
>>>>> Yes, zsj's app is very simple, but quite nice. Other examples using
>>>>> wxpython
>>>>> include:
>>>>>
>>>>> http://bitbucket.org/dodobas/haosbuilder/
>>>>> http://trac.mapnik.org/wiki/IntegrateWithWxPython
>>>>>
>>>>>
>>>>>> Do you have a complete code to this program now? I run
>>>>>> your scripts appended the postings, no errors but what do you suppose
>>>>>> to see? No widget or qt form being rendered.
>>>>>
>>>>> Right, because the script needs to launch an application. I will
>>>>> attach
>>>>> the
>>>>> modified code which does that.
>>>>>
>>>>> Use it like:
>>>>>
>>>>> $ pyqtmapnik.py /path/to/map.xml
>>>>>
>>>>>
>>>>>>
>>>>>> http://www.mail-archive.com/[email protected]/msg02719.html
>>>>>> http://bitbucket.org/springmeyer/quantumnik/src/tip/quantumnik.py#cl-592
>>>>>>
>>>>>> Dane, would be possilbe to have just PyQt with mapnik without QGIS
>>>>>> example?
>>>>>>
>>>>> zsj's code does that.
>>>>>
>>>>>> Hope see simple PyQt application with Mapnik viewer / canvas running.
>>>>>>
>>>>>
>>>>> Let us know how the attached code goes. It requires a working Mapnik
>>>>> XML
>>>>> stylesheet.
>>>>>
>>>>> If you need one, grab the one try this one:
>>>>>
>>>>> http://bitbucket.org/springmeyer/tilelite/src/tip/demo/
>>>>>
>>>>
>>>
>>
>
_______________________________________________
Mapnik-users mailing list
[email protected]
https://lists.berlios.de/mailman/listinfo/mapnik-users