From dced2bcc6ce21428daf011671224968f8b3ae7c8 Mon Sep 17 00:00:00 2001 From: Juke Date: Sun, 11 Apr 2010 18:16:27 +0200 Subject: [PATCH 1/2] add file for script and frontend --- scripts/travel_ui | 26 ++++++++++++++++++++++++++ weboob/frontends/travel_ui/__init__.py | 22 ++++++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100755 scripts/travel_ui create mode 100644 weboob/frontends/travel_ui/__init__.py diff --git a/scripts/travel_ui b/scripts/travel_ui new file mode 100755 index 00000000..60b96a5b --- /dev/null +++ b/scripts/travel_ui @@ -0,0 +1,26 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# vim: ft=python et softtabstop=4 cinoptions=4 shiftwidth=4 ts=4 ai + +""" +Copyright(C) 2010 Romain Bignon + +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, version 3 of the License. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +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, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +""" + +from weboob.frontends.travel_ui import Travel + +if __name__ == '__main__': + Travel.run() diff --git a/weboob/frontends/travel_ui/__init__.py b/weboob/frontends/travel_ui/__init__.py new file mode 100644 index 00000000..18cf137f --- /dev/null +++ b/weboob/frontends/travel_ui/__init__.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +# vim: ft=python et softtabstop=4 cinoptions=4 shiftwidth=4 ts=4 ai + +""" +Copyright(C) 2010 Romain Bignon + +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, version 3 of the License. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +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, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +""" + +from .application import Travel From ed84bf0e37c3ceaac9dcfd9785a51b4b8db04be1 Mon Sep 17 00:00:00 2001 From: Juke Date: Mon, 12 Apr 2010 09:33:48 +0200 Subject: [PATCH 2/2] display stations and departures [IN DEV] --- weboob/frontends/travel_ui/application.py | 162 ++++++++++++++++++++++ 1 file changed, 162 insertions(+) create mode 100644 weboob/frontends/travel_ui/application.py diff --git a/weboob/frontends/travel_ui/application.py b/weboob/frontends/travel_ui/application.py new file mode 100644 index 00000000..924f3e3c --- /dev/null +++ b/weboob/frontends/travel_ui/application.py @@ -0,0 +1,162 @@ +# -*- coding: utf-8 -*- + +""" +Copyright(C) 2010 Romain Bignon + +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, version 3 of the License. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +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, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +""" + +from weboob.capabilities.travel import ICapTravel +from weboob.tools.application import BaseApplication + +try: + import hildon +except ImportError: + raise ImportError("erreur d'importation de hildon http://maemo.org/packages/view/python-hildon/") + +try : + import gtk +except ImportError: + raise ImportError("erreur d'importation de gtk") + +class TransilienUI(): + "interface hildon" + def __init__(self, weboob): + self.weboob = weboob + self.main_window = hildon.Window() + self.main_window.set_title("Horaires des Prochains Trains") + self.main_window.connect("destroy", self.on_main_window_destroy) + + + refresh_button = hildon.Button( + gtk.HILDON_SIZE_AUTO_WIDTH | gtk.HILDON_SIZE_FINGER_HEIGHT, + hildon.BUTTON_ARRANGEMENT_HORIZONTAL, + "Actualiser" + ) + retour_button = hildon.Button( + gtk.HILDON_SIZE_AUTO_WIDTH | gtk.HILDON_SIZE_FINGER_HEIGHT, + hildon.BUTTON_ARRANGEMENT_HORIZONTAL, + "Retour" + ) + refresh_button.connect("clicked", self.on_refresh_button_clicked) + retour_button.connect("clicked", self.on_retour_button_clicked) + + self.treestore = gtk.TreeStore(str, str, str, str) + self.treeview = gtk.TreeView(self.treestore) + + self.treeview.append_column( + gtk.TreeViewColumn( + 'Train', + gtk.CellRendererText(), + text=0 + )) + + self.treeview.append_column( + gtk.TreeViewColumn( + 'Horaire', + gtk.CellRendererText(), + text=1 + )) + + self.treeview.append_column( + gtk.TreeViewColumn( + 'Destination', + gtk.CellRendererText(), + text=2 + )) + self.treeview.append_column( + gtk.TreeViewColumn( + 'Voie', + gtk.CellRendererText(), + text=3 + )) + + self.combo_source = hildon.TouchSelectorEntry(text=True) + self.combo_dest = hildon.TouchSelectorEntry(text=True) + + liste = [] + + #liste = ConfFile('/opt/masstransit/masstransit.cfg').config.items('ListeDesGares') + for name, backend in self.weboob.iter_backends(): + for station in backend.iter_station_search(""): + liste.append(station) + + liste.sort() + for station in liste: + print station + self.combo_source.append_text(station.name.capitalize()) + self.combo_dest.append_text(station.name.capitalize()) + + picker_button_source = hildon.PickerButton( + gtk.HILDON_SIZE_AUTO, + hildon.BUTTON_ARRANGEMENT_VERTICAL) + + picker_button_dest = hildon.PickerButton( + gtk.HILDON_SIZE_AUTO, + hildon.BUTTON_ARRANGEMENT_VERTICAL + ) + + picker_button_source.set_title("Gare de Depart") + picker_button_dest.set_title("Gare d'arrivee") + + picker_button_source.set_selector(self.combo_source) + picker_button_dest.set_selector(self.combo_dest) + + vertical_box = gtk.VBox() + horizontal_box = gtk.HBox() + vertical_box.pack_start(horizontal_box) + horizontal_box.pack_start(picker_button_source) + horizontal_box.pack_start(picker_button_dest) + horizontal_box.pack_start(retour_button) + vertical_box.pack_start(self.treeview) + vertical_box.pack_start(refresh_button) + + self.main_window.add(vertical_box) + self.main_window.show_all() + + def on_main_window_destroy(self, widget): + "quitte l'application à la fermeture de la fenetre" + gtk.main_quit() + + + def on_retour_button_clicked(self, widget): + "le bouton retour est clicked" + col_source = self.combo_source.get_active(0) + col_dest = self.combo_dest.get_active(0) + self.combo_source.set_active(0, col_dest) + self.combo_dest.set_active(0, col_source) + self.refresh() + + def on_refresh_button_clicked(self, widget): + "le bouton refresh est clicked" + self.refresh() + + def refresh(self): + "met a jour les horaires" + for name, backend in self.weboob.iter_backends(): + for station in backend.iter_station_search(self.combo_source.get_current_text()): + for name, backend in self.weboob.iter_backends(): + for arrival in backend.iter_station_search(self.combo_dest.get_current_text()): + for name, backend, in self.weboob.iter_backends(): + for departure in backend.iter_station_departures(station.id, arrival.id): + print departure.id, departure.type, departure.time, departure.arrival_station, departure.late, departure.information + +class Travel(BaseApplication): + APPNAME = 'travel' + + def main(self, argv): + self.weboob.load_modules(ICapTravel) + TransilienUI(self.weboob) + gtk.main()