8 from PySide import QtCore, QtGui
9 from Ui_Qt import Ui_MainWindow
10 from wlSearch import Search
11 from history import History
15 class WienerLinienQt(QtGui.QMainWindow, Ui_MainWindow):
16 types = ('stop', 'address', 'poi')
19 QtGui.QMainWindow.__init__(self)
21 self.connect(self.btnSearch, QtCore.SIGNAL("clicked()"), self.search)
23 self.history = History(settings.hist_file)
24 self.editOrigin.addItems(self.history)
25 self.editDestination.addItems(self.history)
28 origin = self.editOrigin.currentText()
29 destination = self.editDestination.currentText()
31 self.history.insert(0, origin)
32 self.history.insert(0, destination)
34 if not origin in self.history:
35 self.editOrigin.insertItems(0, origin)
36 self.editDestination.insertItems(0, origin)
38 if not destination in self.history:
39 self.editOrigin.insertItems(0, destination)
40 self.editDestination.insertItems(0, destination)
42 if not origin and destination:
43 self.btnSearch.setText("Search - Missing input")
45 s = Search(origin, destination, \
46 origin_type=self.types[self.comboOrigin.currentIndex()], \
47 destination_type=self.types[self.comboDestination.currentIndex()])
50 except webbrowser.Error:
51 self.btnSearch.setText("Error starting webbrowser")
53 self.btnSearch.setText("Search - Opening webbrowser")
57 if __name__ == "__main__":
58 app = QtGui.QApplication(sys.argv)