Move files around, add logo to start page
[pywienerlinien] / gotoVienna-qml
1 #!/usr/env/python
2
3 from PySide import QtCore, QtGui, QtDeclarative
4 from gotovienna.utils import *
5 from gotovienna.realtime import *
6
7 import urllib2
8 import os
9 import sys
10
11
12 class Gui(QtCore.QObject):
13     @QtCore.Slot(str, str)
14     def search(self, line, station):
15         line = line.upper()
16         station = station.decode('utf-8')
17         print line, station
18         
19         itip = ITipParser()
20         print itip.lines
21         if not line in itip.lines:
22             return "Invalid line"
23         
24         try:
25             stations = sorted(itip.get_stations(line).items())
26             print stations
27             headers, stations = zip(*stations)
28             print headers
29             print stations
30             details = [(direction, name, url) for direction, stops in stations
31                         for name, url in stops if match_station(station, name)]
32             print details
33         except urllib2.URLError as e:
34             print e.message
35             return e.message
36
37 if __name__ == '__main__':
38     app = QtGui.QApplication(sys.argv)
39
40     view = QtDeclarative.QDeclarativeView()
41
42     # instantiate the Python object
43     itip = Gui()
44
45     # expose the object to QML
46     context = view.rootContext()
47     context.setContextProperty("itip", itip)
48
49     view.setSource(os.path.join(os.path.dirname(__file__), 'qml/main.qml'))
50     view.showFullScreen()
51
52     sys.exit(app.exec_())
53