1 # -*- coding: UTF-8 -*-
8 from timetable import StanTimetable
10 class StanGUI(hildon.Program):
13 hildon.Program.__init__(self)
15 self.window = hildon.Window()
16 self.window.set_title('pySTAN')
17 self.window.connect("destroy", gtk.main_quit)
18 self.add_window(self.window)
20 self.tabs = self.main_tabs()
21 self.window.add(self.tabs)
23 self.last_station = False
27 tabs.set_tab_pos(gtk.POS_TOP)
28 tabs.append_page(self.tab_lines(), gtk.Label('Par lignes'))
29 #tabs.append_page(self.tab_stations(), gtk.Label('Par arrets'))
30 #tabs.append_page(self.tab_search(), gtk.Label('Recherche'))
34 tab_search = gtk.Frame(None) #'Recherche de trajet')
36 from_location = gtk.Entry()
37 from_location_label = gtk.Label(u"Départ")
38 from_city = gtk.Entry()
39 from_city_label = gtk.Label(u"à")
41 to_location = gtk.Entry()
42 to_location_label = gtk.Label(u"Arrivée")
44 to_city_label = gtk.Label(u"à")
46 datetime_select = gtk.Calendar()
47 datetime_select.display_options(gtk.CALENDAR_SHOW_DAY_NAMES | gtk.CALENDAR_WEEK_START_MONDAY)
49 restriction = gtk.Combo()
50 restriction.set_popdown_strings([u"partir après", u"arriver avant"])
53 vbox.add(from_location_label)
54 vbox.add(from_location)
56 vbox.add(to_location_label)
60 vbox.add(datetime_select)
68 tab_lines = tab_lines = gtk.Frame(None) #'Recherche par lignes')
70 list_lines = gtk.combo_box_new_text()
71 list_lines.connect('changed', self.show_line_timetable)
73 for line in self.stan.lines():
74 list_lines.append_text( '-'.join(line['numbers']) + "\t" + line['name'] )
78 alignment_list = gtk.Alignment(xalign=0.0, yalign=0.0, xscale=1.0, yscale=0.10)
79 alignment_list.add(list_lines)
80 vbox.add(alignment_list)
82 self.timetable = StanTimetable()
83 self.timetable.create()
84 self.timetable.set_activated_callback(self.timetable_row_clicked)
86 alignment_tt = gtk.Alignment(xalign=0.0, yalign=0.0, xscale=1.0, yscale=0.90)
87 alignment_tt.add(self.timetable)
88 vbox.add(alignment_tt)
93 def show_line_timetable(self, selection):
94 self.timetable.load( self.stan.lines()[selection.get_active()], '08/03/2009', '12' )
96 def timetable_row_clicked(self, station_name):
97 if self.last_station != station_name:
98 if self.last_station != False:
99 self.tabs.remove(self.tab_map)
100 self.last_station = station_name
101 self.tab_map = self.tab_geomap(station=station_name)
102 self.tabs.append_page(self.tab_map, gtk.Label(station_name))
104 self.tabs.set_current_page(1)
106 def tab_stations(self):
107 tab_stations = gtk.Frame(None) #'Recherche par arrets')
109 list_stations = gtk.Combo()
110 list_stations.set_popdown_strings([])
112 tab_stations.add(list_stations)
116 def tab_geomap(self, station):
117 tab_map = gtk.Frame(None)
118 map_button = gtk.Button()
119 #map_label = gtk.Label(u"Link to map")
120 map_button.connect('clicked', self.open_map, 'http://www.google.fr')
122 tab_map.add(map_button)
125 def open_map(self, data, url):
129 self.window.show_all()