Changeset 48:53b2648cfb30 for src
- Timestamp:
- 03/23/12 13:31:41 (13 years ago)
- Branch:
- default
- Phase:
- public
- Location:
- src/mlx
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
src/mlx/gui/flight.py
r46 r48 20 20 21 21 self._vbox = gtk.VBox() 22 self._vbox.set_homogeneous(False) 22 23 frame.add(self._vbox) 23 24 … … 38 39 self._vbox.pack_start(eventBox, False, False, 0) 39 40 40 alignment = gtk.Alignment(xalign = 0.5, yalign = 0.5, 41 xscale = 0, yscale = 0.3) 41 table = gtk.Table(3, 1) 42 table.set_homogeneous(True) 43 44 alignment = gtk.Alignment(xalign = 0.0, yalign = 0.0, 45 xscale = 1.0, yscale = 1.0) 46 alignment.set_padding(padding_top = 16, padding_bottom = 16, 47 padding_left = 16, padding_right = 16) 48 alignment.add(table) 49 self._vbox.pack_start(alignment, True, True, 0) 50 51 alignment = gtk.Alignment(xalign = 0.5, yalign = 0.0, 52 xscale = 0, yscale = 0.0) 53 42 54 label = gtk.Label(help) 43 55 label.set_justify(gtk.Justification.CENTER if pygobject 44 56 else gtk.JUSTIFY_CENTER) 45 57 alignment.add(label) 46 self._vbox.pack_start(alignment, True, True, 0)58 table.attach(alignment, 0, 1, 0, 1) 47 59 48 60 self._mainAlignment = gtk.Alignment(xalign = 0.5, yalign = 0.5, 49 xscale = 0, yscale = 0.0)50 self._vbox.pack_start(self._mainAlignment, True, True, 0)51 52 buttonAlignment = gtk.Alignment(xalign = 1.0, xscale=0.0 )61 xscale = 1.0, yscale = 1.0) 62 table.attach(self._mainAlignment, 0, 1, 1, 3) 63 64 buttonAlignment = gtk.Alignment(xalign = 1.0, xscale=0.0, yscale = 0.0) 53 65 buttonAlignment.set_padding(padding_top = 4, padding_bottom = 10, 54 66 padding_left = 16, padding_right = 16) … … 72 84 button = gtk.Button(label) 73 85 self._buttonBox.add(button) 86 button.set_use_underline(True) 74 87 if default: 75 88 button.set_can_default(True) 76 89 self._defaultButton = button 77 90 return button 91 92 def activate(self): 93 """Called when this page becomes active. 94 95 This default implementation does nothing.""" 96 pass 78 97 79 98 def grabDefault(self): … … 93 112 super(LoginPage, self).__init__(wizard, "Login", help) 94 113 114 alignment = gtk.Alignment(xalign = 0.5, yalign = 0.5, 115 xscale = 0.0, yscale = 0.0) 116 95 117 table = gtk.Table(2, 3) 96 118 table.set_row_spacings(4) 97 119 table.set_col_spacings(32) 98 self.setMainWidget(table) 120 alignment.add(table) 121 self.setMainWidget(alignment) 99 122 100 123 labelAlignment = gtk.Alignment(xalign=1.0, xscale=0.0) … … 138 161 self._loginButton = self.addButton("_Login", default = True) 139 162 self._loginButton.set_sensitive(False) 140 self._loginButton.set_use_underline(True)141 163 self._loginButton.connect("clicked", self._loginClicked) 142 164 self._loginButton.set_tooltip_text("Click to log in.") … … 180 202 181 203 config.save() 204 self._wizard._loginResult = result 182 205 self._wizard.nextPage() 183 206 else: … … 206 229 """Construct the flight selection page.""" 207 230 super(FlightSelectionPage, self).__init__(wizard, "Flight selection", 208 "Hello, te lo!") 231 "Select the flight you want " 232 "to perform.") 233 234 235 self._listStore = gtk.ListStore(str, str, str, str) 236 self._flightList = gtk.TreeView(self._listStore) 237 column = gtk.TreeViewColumn("Flight no.", gtk.CellRendererText(), 238 text = 1) 239 column.set_expand(True) 240 self._flightList.append_column(column) 241 column = gtk.TreeViewColumn("Departure time [UTC]", gtk.CellRendererText(), 242 text = 0) 243 column.set_expand(True) 244 self._flightList.append_column(column) 245 column = gtk.TreeViewColumn("From", gtk.CellRendererText(), 246 text = 2) 247 column.set_expand(True) 248 self._flightList.append_column(column) 249 column = gtk.TreeViewColumn("To", gtk.CellRendererText(), 250 text = 3) 251 column.set_expand(True) 252 self._flightList.append_column(column) 253 254 flightSelection = self._flightList.get_selection() 255 flightSelection.connect("changed", self._selectionChanged) 256 257 scrolledWindow = gtk.ScrolledWindow() 258 scrolledWindow.add(self._flightList) 259 scrolledWindow.set_size_request(400, -1) 260 scrolledWindow.set_policy(gtk.PolicyType.AUTOMATIC if pygobject 261 else gtk.POLICY_AUTOMATIC, 262 gtk.PolicyType.ALWAYS if pygobject 263 else gtk.POLICY_ALWAYS) 264 265 alignment = gtk.Alignment(xalign = 0.5, yalign = 0.0, xscale = 0.0, yscale = 1.0) 266 alignment.add(scrolledWindow) 267 268 self.setMainWidget(alignment) 269 270 self._button = self.addButton(gtk.STOCK_GO_FORWARD, default = True) 271 self._button.set_use_stock(True) 272 self._button.set_sensitive(False) 273 274 self._activated = False 275 276 def activate(self): 277 """Fill the flight list.""" 278 if not self._activated: 279 for flight in self._wizard.loginResult.flights: 280 self._listStore.append([str(flight.departureTime), 281 flight.callsign, 282 flight.departureICAO, 283 flight.arrivalICAO]) 284 self._activated = True 285 286 def _selectionChanged(self, selection): 287 """Called when the selection is changed.""" 288 self._button.set_sensitive(selection.count_selected_rows()==1) 209 289 210 290 #----------------------------------------------------------------------------- … … 224 304 self._pages.append(FlightSelectionPage(self)) 225 305 306 self._loginResult = None 307 226 308 self.setCurrentPage(0) 309 310 @property 311 def loginResult(self): 312 """Get the login result.""" 313 return self._loginResult 227 314 228 315 def setCurrentPage(self, index): … … 235 322 self._currentPage = index 236 323 self.add(self._pages[index]) 324 self._pages[index].activate() 237 325 self.show_all() 238 326 … … 240 328 """Go to the next page.""" 241 329 self.setCurrentPage(self._currentPage + 1) 330 self.grabDefault() 242 331 243 332 def grabDefault(self): -
src/mlx/gui/gui.py
r47 r48 725 725 """Called when the current page of the notebook has changed.""" 726 726 if page_num==0: 727 self._wizard.grabDefault()727 gobject.idle_add(self._wizard.grabDefault) 728 728 elif page_num==1: 729 self._connectButton.grab_default()729 gobject.idle_add(self._connectButton.grab_default) 730 730 else: 731 731 self._mainWindow.set_default(None) -
src/mlx/web.py
r41 r48 201 201 result.flights.append(flight) 202 202 203 result.flights.sort(cmp = lambda flight1, flight2: 204 cmp(flight1.departureTime, 205 flight2.departureTime)) 206 203 207 return result 204 208
Note:
See TracChangeset
for help on using the changeset viewer.