#!/usr/env/python """Public transport information for Vienna""" __author__ = 'kelvan ' __version__ = '1.0' __website__ = 'https://github.com/kelvan/gotoVienna/' __license__ = 'GNU General Public License v3 or later' from PySide import QtCore, QtGui, QtDeclarative from gotovienna.utils import * from gotovienna.realtime import * import urllib2 import os import sys class Gui(QtCore.QObject): @QtCore.Slot(str, str) def search(self, line, station): line = line.upper() station = station.decode('utf-8') print line, station itip = ITipParser() print itip.lines if not line in itip.lines: return "Invalid line" try: stations = sorted(itip.get_stations(line).items()) print stations headers, stations = zip(*stations) print headers print stations details = [(direction, name, url) for direction, stops in stations for name, url in stops if match_station(station, name)] print details except urllib2.URLError as e: print e.message return e.message if __name__ == '__main__': app = QtGui.QApplication(sys.argv) view = QtDeclarative.QDeclarativeView() # instantiate the Python object itip = Gui() # expose the object to QML context = view.rootContext() context.setContextProperty("itip", itip) if os.path.abspath(__file__).startswith('/usr/bin/'): # Assume system-wide installation, QML from /usr/share/ view.setSource('/usr/share/gotovienna/qml/main.qml') else: # Assume test from source directory, use relative path view.setSource(os.path.join(os.path.dirname(__file__), 'qml/main.qml')) view.showFullScreen() sys.exit(app.exec_())