Jump to: navigation, search
Hello Marble
Tutorial Series   Marble Python Tutorial
Previous   None
What's Next   Tutorial 2 - MarbleWidget: Changing basic map properties
Further Reading   n/a

Hello Marble!

The API of the Marble library allows for a very easy integration of a map widget into your application.

Let's prove that with a tiny Hello world-like example. For a start we just create a KApplication object and a MarbleWidget object which serves as a window. By default the MarbleWidget uses the Atlas map theme. However for our first example we choose to display streets. So we set the maptheme id to OpenStreetMap. Then we call to show the map widget and we call QApplication.exec_() to start the application's event loop. That's all!

from PyQt4.QtGui import *
from PyKDE4.marble import *
import sys
def main():
  # Initialize QApplication
  app = QApplication(sys.argv)
  # Create a Marble QWidget
  m = Marble.MarbleWidget()
  # Load the OpenStreeMap map
  # Show the window
  # Run the app

Copy and paste the code above into a text editor. Then save it as and run it by entering the following command on the command line:


You end up with a fully usable OpenStreetMap application:

My hello py.png

You need PyQt, PyKDE and Marble development packages for Python (or comparable git installations)
If you provide maps in your application please check the Terms of Use of the map material. The map material that is shipped with Marble is licensed in the spirit of Free Software. This usually means at least that the authors should be credited and that the license is mentioned. E.g. for OpenStreetMap the license is CC-BY-SA. Other map data shipped with Marble is either public domain or licensed in the spirit of the BSD license.

This page was last modified on 25 November 2013, at 18:03. This page has been accessed 1,416 times. Content is available under Creative Commons License SA 3.0 as well as the GNU Free Documentation License 1.2.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V.Legal