Ignore:
Timestamp:
2011-01-16T19:47:42+01:00 (14 years ago)
Author:
guggis
Message:

Updated sample scripts

File:
1 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/scripting/scripts/HelloWorld.py

    r25072 r25083  
    11#
    2 # HelloWorld.py  -  sample JOSM script in Python
     2# HelloWorld.py  - displays the number of actually open layers
    33#
    44from javax.swing import JOptionPane
    55from org.openstreetmap.josm import Main
    66
    7 JOptionPane.showMessageDialog(Main.parent, "[Python] Hello World!")
     7def getMapView():
     8        if Main.main == None:
     9                return None
     10        if Main.main.map == None:
     11                return None
     12        return Main.main.map.mapView
     13
     14
     15numlayers = 0
     16mv = getMapView()
     17if mv != None:
     18        numlayers = mv.getNumLayers()
     19       
     20JOptionPane.showMessageDialog(Main.parent, "[Python] Hello World! You have %s layer(s)." % numlayers)
Note: See TracChangeset for help on using the changeset viewer.