(New page: {{Template:I18n/Language Navigation Bar|Editing Projects/Marble/MarblePython}} {{TutorialBrowser| series=Marble Python Tutorial| name=Hello Marble| pre=[http://docs.python.org/tutorial/...) |
|||
| Line 13: | Line 13: | ||
== Hello Marble! == | == Hello Marble! == | ||
| − | Marble offers Python bindings. A small hello world example is available as part of the Marble sources at | + | Marble offers KDE-Python bindings. A small hello world example is available as part of the Marble sources at |
<code> | <code> | ||
Languages: عربي | Asturianu | Català | Česky | Kaszëbsczi | Dansk | Deutsch | English | Esperanto | Español | Eesti | فارسی | Suomi | Français | Galego | Italiano | 日本語 | 한국어 | Norwegian | Polski | Português Brasileiro | Română | Русский | Svenska | Slovenčina | Slovenščina | српски | Türkçe | Tiếng Việt | Українська | 简体中文 | 繁體中文
| Tutorial Series | Marble Python Tutorial |
| Previous | Python, Qt |
| What's Next | Tutorial 2 - Marble's GeoPainter |
| Further Reading | n/a |
Marble offers KDE-Python bindings. A small hello world example is available as part of the Marble sources at
marble/examples/python/simple_marble.py
The Marble API allows a very easy integration of a map widget into your application. Let's prove that with some python code:
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.setMapThemeId("earth/bluemarble/bluemarble.dgml")
self.setCentralWidget(self.marble)
self.marble.centerOn(5.8333, 51.8333)
self.marble.zoomView(2000)
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 = "www.simonzone.com"
bugEmail = "simon@simonzone.com"
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")
mainWindow.show()
app.connect(app, SIGNAL ("lastWindowClosed ()"), app.quit)
app.exec_()
main()