< Projects‎ | Marble
Revision as of 16:36, 17 July 2012 by AnneW (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
Hello Marble
Tutorial Series   Marble Python Tutorial
Previous   Python, Qt
What's Next   Tutorial 2 - Marble's GeoPainter
Further Reading   n/a

Hello Marble!

Marble offers KDE-Python bindings. A small hello world example is available as part of the Marble sources at


The Marble API allows a very easy integration of a map widget into your application. Let's prove that with some python code:

#!env python
# Copyright 2008 Simon Edwards <>
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 2 of 
# the License, or (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <>.
# A very simple example of how to use the marble widget.
from PyQt4.QtCore import *
from PyKDE4.kdeui import *
from PyKDE4.kdecore import *
from PyKDE4.marble import *
import sys
class MainWin (KMainWindow):
    def __init__ (self, *args):
        KMainWindow.__init__ (self)
        self.resize(640, 480)
        self.marble = Marble.MarbleWidget(self)
        self.marble.centerOn(5.8333, 51.8333)
def main():
    appName     = "simple_marble"
    catalog     = ""
    programName = ki18n ("default")
    version     = "1.0"
    description = ki18n ("Simple Python Marble Example")
    license     = KAboutData.License_GPL
    copyright   = ki18n ("(c) 2008 Simon Edwards")
    text        = ki18n ("none")
    homePage    = ""
    bugEmail    = ""
    aboutData   = KAboutData (appName, catalog, programName, version, description,
                              license, copyright, text, homePage, bugEmail)
    aboutData.addAuthor (ki18n("Simon Edwards"), ki18n("Developer"))
    KCmdLineArgs.init(sys.argv, aboutData)
    app = KApplication()
    mainWindow = MainWin(None, "main window")
    app.connect(app, SIGNAL ("lastWindowClosed ()"), app.quit)

This page was last modified on 17 July 2012, at 16:36. This page has been accessed 6,002 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