source: src/mlx/gui/flightlist.py@ 859:1e789c934953

Last change on this file since 859:1e789c934953 was 859:1e789c934953, checked in by István Váradi <ivaradi@…>, 7 years ago

Flight booking works (re #304).

File size: 26.1 KB
Line 
1# A widget which is a generic list of flights
2
3#-----------------------------------------------------------------------------
4
5from mlx.gui.common import *
6
7import mlx.const as const
8
9#-----------------------------------------------------------------------------
10
11class ColumnDescriptor(object):
12 """A descriptor for a column in the list."""
13 def __init__(self, attribute, heading, type = str,
14 convertFn = None, renderer = None,
15 extraColumnAttributes = None, sortable = False,
16 defaultSortable = False, defaultDescending = False,
17 cellDataFn = None):
18 """Construct the descriptor."""
19 self._attribute = attribute
20 self._heading = heading
21 self._type = type
22 self._convertFn = convertFn
23 self._renderer = \
24 gtk.CellRendererText() if renderer is None else renderer
25 self._extraColumnAttributes = extraColumnAttributes
26 self._sortable = sortable
27 self._defaultSortable = defaultSortable
28 self._defaultDescending = defaultDescending
29 self._cellDataFn = cellDataFn
30
31 @property
32 def attribute(self):
33 """Get the attribute the column belongs to."""
34 return self._attribute
35
36 @property
37 def defaultSortable(self):
38 """Determine if this column is the default sortable one."""
39 return self._defaultSortable
40
41 def appendType(self, types):
42 """Append the type of this column to the given list of types."""
43 types.append(self._type)
44
45 def getViewColumn(self, index):
46 """Get a new column object for a tree view.
47
48 @param index is the 0-based index of the column."""
49 if isinstance(self._renderer, gtk.CellRendererText):
50 column = gtk.TreeViewColumn(self._heading, self._renderer,
51 text = index)
52 elif isinstance(self._renderer, gtk.CellRendererToggle):
53 column = gtk.TreeViewColumn(self._heading, self._renderer,
54 active = index)
55 else:
56 column = gtk.TreeViewColumn(self._heading, self._renderer)
57 column.set_expand(True)
58 if self._sortable:
59 column.set_sort_column_id(index)
60 column.set_sort_indicator(True)
61
62 if self._extraColumnAttributes is not None:
63 for (key, value) in self._extraColumnAttributes.iteritems():
64 if key=="alignment":
65 self._renderer.set_alignment(value, 0.5)
66 else:
67 raise Exception("unhandled extra column attribute '" +
68 key + "'")
69 if self._cellDataFn is not None:
70 column.set_cell_data_func(self._renderer, self._cellDataFn)
71
72 return column
73
74 def getValueFrom(self, flight):
75 """Get the value from the given flight."""
76 attributes = self._attribute.split(".")
77 value = getattr(flight, attributes[0])
78 for attr in attributes[1:]:
79 value = getattr(value, attr)
80 return self._type(value) if self._convertFn is None \
81 else self._convertFn(value, flight)
82
83#-----------------------------------------------------------------------------
84
85class FlightList(gtk.Alignment):
86 """Construct the flight list.
87
88 This is a complete widget with a scroll window. It is alignment centered
89 horizontally and expandable vertically."""
90
91 defaultColumnDescriptors = [
92 ColumnDescriptor("callsign", xstr("flightsel_no")),
93 ColumnDescriptor("departureTime", xstr("flightsel_deptime"),
94 sortable = True, defaultSortable = True),
95 ColumnDescriptor("departureICAO", xstr("flightsel_from"),
96 sortable = True),
97 ColumnDescriptor("arrivalICAO", xstr("flightsel_to"), sortable = True)
98 ]
99
100 def __init__(self, columnDescriptors = defaultColumnDescriptors,
101 popupMenuProducer = None, widthRequest = None,
102 multiSelection = False):
103 """Construct the flight list with the given column descriptors."""
104
105 self._columnDescriptors = columnDescriptors
106 self._popupMenuProducer = popupMenuProducer
107 self._popupMenu = None
108
109 types = [int]
110 defaultSortableIndex = None
111 for columnDescriptor in self._columnDescriptors:
112 if columnDescriptor.defaultSortable:
113 defaultSortableIndex = len(types)
114 columnDescriptor.appendType(types)
115
116 self._model = gtk.ListStore(*types)
117 if defaultSortableIndex is not None:
118 sortOrder = SORT_DESCENDING \
119 if self._columnDescriptors[defaultSortableIndex-1]._defaultDescending \
120 else SORT_ASCENDING
121 self._model.set_sort_column_id(defaultSortableIndex, sortOrder)
122 self._view = gtk.TreeView(self._model)
123
124 flightIndexColumn = gtk.TreeViewColumn()
125 flightIndexColumn.set_visible(False)
126 self._view.append_column(flightIndexColumn)
127
128 index = 1
129 for columnDescriptor in self._columnDescriptors:
130 column = columnDescriptor.getViewColumn(index)
131 self._view.append_column(column)
132 index += 1
133
134 self._view.connect("row-activated", self._rowActivated)
135 self._view.connect("button-press-event", self._buttonPressEvent)
136
137 selection = self._view.get_selection()
138 selection.connect("changed", self._selectionChanged)
139 if multiSelection:
140 selection.set_mode(SELECTION_MULTIPLE)
141
142 scrolledWindow = gtk.ScrolledWindow()
143 scrolledWindow.add(self._view)
144 if widthRequest is not None:
145 scrolledWindow.set_size_request(widthRequest, -1)
146 # FIXME: these should be constants in common.py
147 scrolledWindow.set_policy(gtk.PolicyType.AUTOMATIC if pygobject
148 else gtk.POLICY_AUTOMATIC,
149 gtk.PolicyType.AUTOMATIC if pygobject
150 else gtk.POLICY_AUTOMATIC)
151 scrolledWindow.set_shadow_type(gtk.ShadowType.IN if pygobject
152 else gtk.SHADOW_IN)
153
154 super(FlightList, self).__init__(xalign = 0.5, yalign = 0.0,
155 xscale = 0.0, yscale = 1.0)
156 self.add(scrolledWindow)
157
158 @property
159 def selectedIndexes(self):
160 """Get the indexes of the selected entries, if any.
161
162 The indexes are sorted."""
163 selection = self._view.get_selection()
164 (model, rows) = selection.get_selected_rows()
165
166 indexes = [self._getIndexForPath(path) for path in rows]
167 indexes.sort()
168 return indexes
169
170 @property
171 def hasFlights(self):
172 """Determine if there are any flights in the list."""
173 return self._model.get_iter_root() is not None
174
175 def clear(self):
176 """Clear the model."""
177 self._model.clear()
178
179 def addFlight(self, flight):
180 """Add the given booked flight."""
181 values = [self._model.iter_n_children(None)]
182 for columnDescriptor in self._columnDescriptors:
183 values.append(columnDescriptor.getValueFrom(flight))
184 self._model.append(values)
185
186 def removeFlights(self, indexes):
187 """Remove the flights with the given indexes."""
188 model = self._model
189 idx = 0
190 iter = model.get_iter_first()
191 while iter is not None:
192 nextIter = model.iter_next(iter)
193 if model.get_value(iter, 0) in indexes:
194 model.remove(iter)
195 else:
196 model.set_value(iter, 0, idx)
197 idx += 1
198 iter = nextIter
199
200 def _getIndexForPath(self, path):
201 """Get the index for the given path."""
202 iter = self._model.get_iter(path)
203 return self._model.get_value(iter, 0)
204
205 def _rowActivated(self, flightList, path, column):
206 """Called when a row is selected."""
207 self.emit("row-activated", self._getIndexForPath(path))
208
209 def _buttonPressEvent(self, widget, event):
210 """Called when a mouse button is pressed or released."""
211 if event.type!=EVENT_BUTTON_PRESS or event.button!=3 or \
212 self._popupMenuProducer is None:
213 return
214
215 (path, _, _, _) = self._view.get_path_at_pos(int(event.x),
216 int(event.y))
217 selection = self._view.get_selection()
218 selection.unselect_all()
219 selection.select_path(path)
220
221 if self._popupMenu is None:
222 self._popupMenu = self._popupMenuProducer()
223 menu = self._popupMenu
224 if pygobject:
225 menu.popup(None, None, None, None, event.button, event.time)
226 else:
227 menu.popup(None, None, None, event.button, event.time)
228
229 def _selectionChanged(self, selection):
230 """Called when the selection has changed."""
231 self.emit("selection-changed", self.selectedIndexes)
232
233#-------------------------------------------------------------------------------
234
235gobject.signal_new("row-activated", FlightList, gobject.SIGNAL_RUN_FIRST,
236 None, (int,))
237
238gobject.signal_new("selection-changed", FlightList, gobject.SIGNAL_RUN_FIRST,
239 None, (object,))
240
241#-----------------------------------------------------------------------------
242
243class PendingFlightsFrame(gtk.Frame):
244 """A frame for a list of pending (reported or rejected) flights.
245
246 It contains the list and the buttons available."""
247 @staticmethod
248 def getAircraft(tailNumber, bookedFlight):
249 """Get the aircraft from the given booked flight.
250
251 This is the tail number followed by the ICAO code of the aircraft's
252 type."""
253 return tailNumber + \
254 " (" + const.icaoCodes[bookedFlight.aircraftType] + ")"
255
256 def _getAcft(tailNumber, bookedFlight):
257 return PendingFlightsFrame.getAircraft(tailNumber, bookedFlight)
258
259 columnDescriptors = [
260 ColumnDescriptor("callsign", xstr("flightsel_no")),
261 ColumnDescriptor("departureTime", xstr("flightsel_deptime"),
262 sortable = True, defaultSortable = True),
263 ColumnDescriptor("departureICAO", xstr("flightsel_from"),
264 sortable = True),
265 ColumnDescriptor("arrivalICAO", xstr("flightsel_to"),
266 sortable = True),
267 ColumnDescriptor("tailNumber", xstr("pendflt_acft"),
268 convertFn = _getAcft)
269 ]
270
271 def __init__(self, which, wizard, window, pirepEditable = False):
272 """Construct the frame with the given title."""
273 super(PendingFlightsFrame, self).__init__(xstr("pendflt_title_" + which))
274
275 self._which = which
276 self._wizard = wizard
277 self._window = window
278 self._pirepEditable = pirepEditable
279
280 alignment = gtk.Alignment(xscale = 1.0, yscale = 1.0)
281 alignment.set_padding(padding_top = 2, padding_bottom = 8,
282 padding_left = 4, padding_right = 4)
283
284 hbox = gtk.HBox()
285
286 self._flights = []
287 self._flightList = FlightList(columnDescriptors =
288 PendingFlightsFrame.columnDescriptors,
289 widthRequest = 500, multiSelection = True)
290 self._flightList.connect("selection-changed", self._selectionChanged)
291
292 hbox.pack_start(self._flightList, True, True, 4)
293
294 buttonBox = gtk.VBox()
295
296 self._editButton = gtk.Button(xstr("pendflt_" +
297 ("edit" if pirepEditable else
298 "view") + "_" + which))
299 self._editButton.set_sensitive(False)
300 self._editButton.connect("clicked", self._editClicked)
301 buttonBox.pack_start(self._editButton, False, False, 2)
302
303 self._reflyButton = gtk.Button(xstr("pendflt_refly_" + which))
304 self._reflyButton.set_sensitive(False)
305 self._reflyButton.connect("clicked", self._reflyClicked)
306 buttonBox.pack_start(self._reflyButton, False, False, 2)
307
308 self._deleteButton = gtk.Button(xstr("pendflt_delete_" + which))
309 self._deleteButton.set_sensitive(False)
310 self._deleteButton.connect("clicked", self._deleteClicked)
311 buttonBox.pack_start(self._deleteButton, False, False, 2)
312
313 hbox.pack_start(buttonBox, False, False, 4)
314
315 alignment.add(hbox)
316 self.add(alignment)
317
318 @property
319 def hasFlights(self):
320 """Determine if there are any flights in the list."""
321 return self._flightList.hasFlights
322
323 def clear(self):
324 """Clear the lists."""
325 self._flights = []
326 self._flightList.clear()
327
328 def addFlight(self, flight):
329 """Add a flight to the list."""
330 self._flights.append(flight)
331 self._flightList.addFlight(flight)
332
333 def _selectionChanged(self, flightList, selectedIndexes):
334 """Called when the selection in the list has changed."""
335 self._editButton.set_sensitive(len(selectedIndexes)==1)
336 self._reflyButton.set_sensitive(len(selectedIndexes)>0)
337 self._deleteButton.set_sensitive(len(selectedIndexes)>0)
338
339 def _editClicked(self, button):
340 """Called when the Edit button is clicked."""
341 gui = self._wizard.gui
342 gui.beginBusy(xstr("pendflt_pirep_busy"))
343 self.set_sensitive(False)
344
345 indexes = self._flightList.selectedIndexes
346 assert(len(indexes)==1)
347
348 flightID = self._flights[indexes[0]].id
349 gui.webHandler.getPIREP(self._pirepResultCallback, flightID)
350
351 def _pirepResultCallback(self, returned, result):
352 """Called when the PIREP query result is available."""
353 gobject.idle_add(self._handlePIREPResult, returned, result)
354
355 def _handlePIREPResult(self, returned, result):
356 """Handle the refly result."""
357
358 self.set_sensitive(True)
359 gui = self._wizard.gui
360 gui.endBusy()
361
362 if returned:
363 if self._pirepEditable:
364 gui.editPIREP(result.pirep)
365 else:
366 gui.viewMessagedPIREP(result.pirep)
367
368 def _reflyClicked(self, button):
369 """Called when the Refly button is clicked."""
370 if askYesNo(xstr("pendflt_refly_question"), parent = self._window):
371 gui = self._wizard.gui
372 gui.beginBusy(xstr("pendflt_refly_busy"))
373 self.set_sensitive(False)
374
375 flightIDs = [self._flights[i].id
376 for i in self._flightList.selectedIndexes]
377 gui.webHandler.reflyFlights(self._reflyResultCallback, flightIDs)
378
379 def _reflyResultCallback(self, returned, result):
380 """Called when the refly result is available."""
381 gobject.idle_add(self._handleReflyResult, returned, result)
382
383 def _handleReflyResult(self, returned, result):
384 """Handle the refly result."""
385
386 self.set_sensitive(True)
387 gui = self._wizard.gui
388 gui.endBusy()
389
390 print "PendingFlightsFrame._handleReflyResult", returned, result
391
392 if returned:
393 indexes = self._flightList.selectedIndexes
394
395 flights = [self._flights[index] for index in indexes]
396
397 self._flightList.removeFlights(indexes)
398 for index in indexes[::-1]:
399 del self._flights[index]
400
401 for flight in flights:
402 self._wizard.reflyFlight(flight)
403 self._window.checkFlights()
404 else:
405 communicationErrorDialog()
406
407 def _deleteClicked(self, button):
408 """Called when the Delete button is clicked."""
409 if askYesNo(xstr("flight_delete_question"), parent = self._window):
410 gui = self._wizard.gui
411 gui.beginBusy(xstr("pendflt_refly_busy"))
412 self.set_sensitive(False)
413
414 flightIDs = [self._flights[i].id
415 for i in self._flightList.selectedIndexes]
416 gui.webHandler.deleteFlights(self._deleteResultCallback, flightIDs)
417
418 def _deleteResultCallback(self, returned, result):
419 """Called when the deletion result is available."""
420 gobject.idle_add(self._handleDeleteResult, returned, result)
421
422 def _handleDeleteResult(self, returned, result):
423 """Handle the delete result."""
424
425 self.set_sensitive(True)
426 gui = self._wizard.gui
427 gui.endBusy()
428
429 print "PendingFlightsFrame._handleDeleteResult", returned, result
430
431 if returned:
432 indexes = self._flightList.selectedIndexes
433
434 flights = [self._flights[index] for index in indexes]
435
436 self._flightList.removeFlights(indexes)
437 for index in indexes[::-1]:
438 del self._flights[index]
439
440 for flight in flights:
441 self._wizard.deleteFlight(flight)
442 self._window.checkFlights()
443 else:
444 communicationErrorDialog()
445
446#-----------------------------------------------------------------------------
447
448class PendingFlightsWindow(gtk.Window):
449 """The window to display the lists of the pending (reported or rejected)
450 flights."""
451 def __init__(self, wizard):
452 """Construct the window"""
453 super(PendingFlightsWindow, self).__init__()
454
455 gui = wizard.gui
456
457 self.set_title(WINDOW_TITLE_BASE + " - " + xstr("pendflt_title"))
458 self.set_size_request(-1, 450)
459 self.set_transient_for(gui.mainWindow)
460 self.set_modal(True)
461
462 mainAlignment = gtk.Alignment(xalign = 0.5, yalign = 0.5,
463 xscale = 1.0, yscale = 1.0)
464 mainAlignment.set_padding(padding_top = 0, padding_bottom = 12,
465 padding_left = 8, padding_right = 8)
466
467 vbox = gtk.VBox()
468
469 self._reportedFrame = PendingFlightsFrame("reported", wizard, self,
470 True)
471 vbox.pack_start(self._reportedFrame, True, True, 2)
472
473 self._rejectedFrame = PendingFlightsFrame("rejected", wizard, self)
474 vbox.pack_start(self._rejectedFrame, True, True, 2)
475
476 alignment = gtk.Alignment(xalign = 0.5, yalign = 0.5,
477 xscale = 0.0, yscale = 0.0)
478 self._closeButton = gtk.Button(xstr("button_ok"))
479 self._closeButton.connect("clicked", self._closeClicked)
480 alignment.add(self._closeButton)
481 vbox.pack_start(alignment, False, False, 2)
482
483 mainAlignment.add(vbox)
484
485 self.add(mainAlignment)
486
487 self.connect("key-press-event", self._keyPressed)
488
489 @property
490 def hasFlights(self):
491 """Determine if the window has any flights."""
492 return self._reportedFrame.hasFlights or self._rejectedFrame.hasFlights
493
494 def clear(self):
495 """Clear the lists."""
496 self._reportedFrame.clear()
497 self._rejectedFrame.clear()
498
499 def addReportedFlight(self, flight):
500 """Add a reported flight."""
501 self._reportedFrame.addFlight(flight)
502
503 def addRejectedFlight(self, flight):
504 """Add a rejected flight."""
505 self._rejectedFrame.addFlight(flight)
506
507 def checkFlights(self):
508 """Check if there are any flights in any of the lists, and close the
509 window if not."""
510 if not self.hasFlights:
511 self.emit("delete-event", None)
512
513 def _closeClicked(self, button):
514 """Called when the Close button is clicked.
515
516 A 'delete-event' is emitted to close the window."""
517 self.emit("delete-event", None)
518
519 def _keyPressed(self, window, event):
520 """Called when a key is pressed in the window.
521
522 If the Escape key is pressed, 'delete-event' is emitted to close the
523 window."""
524 if gdk.keyval_name(event.keyval) == "Escape":
525 self.emit("delete-event", None)
526 return True
527
528#-----------------------------------------------------------------------------
529
530class AcceptedFlightsWindow(gtk.Window):
531 """A window for a list of accepted flights."""
532 def getFlightDuration(flightTimeStart, flight):
533 """Get the flight duration for the given flight."""
534 minutes = int(round((flight.flightTimeEnd - flightTimeStart)/60.0))
535 return "%02d:%02d" % (minutes/60, minutes%60)
536
537 columnDescriptors = [
538 ColumnDescriptor("bookedFlight.callsign", xstr("flightsel_no")),
539 ColumnDescriptor("bookedFlight.departureTime", xstr("flightsel_deptime"),
540 sortable = True, defaultSortable = True,
541 defaultDescending = True),
542 ColumnDescriptor("bookedFlight.departureICAO", xstr("flightsel_from"),
543 sortable = True),
544 ColumnDescriptor("bookedFlight.arrivalICAO", xstr("flightsel_to"),
545 sortable = True),
546 ColumnDescriptor("bookedFlight.tailNumber", xstr("pendflt_acft"),
547 convertFn = lambda value, flight:
548 PendingFlightsFrame.getAircraft(value,
549 flight.bookedFlight)),
550 ColumnDescriptor("flightTimeStart", xstr("acceptedflt_flight_duration"),
551 convertFn = getFlightDuration, sortable = True,
552 extraColumnAttributes =
553 { "alignment": 0.5 } ),
554 ColumnDescriptor("numPassengers", xstr("acceptedflt_num_pax"),
555 type = int, sortable = True,
556 extraColumnAttributes =
557 { "alignment": 1.0 } ),
558 ColumnDescriptor("fuelUsed", xstr("acceptedflt_fuel"),
559 type = int, sortable = True,
560 extraColumnAttributes =
561 { "alignment": 1.0 } ),
562 ColumnDescriptor("rating", xstr("acceptedflt_rating"),
563 type = float, sortable = True,
564 extraColumnAttributes =
565 { "alignment": 1.0 },
566 cellDataFn = lambda col, cell, model, iter:
567 cell.set_property("text",
568 "%.0f" %
569 (model.get(iter, 9)[0],)))
570 ]
571
572 def __init__(self, gui):
573 """Construct the window."""
574 super(AcceptedFlightsWindow, self).__init__()
575
576 self._gui = gui
577
578 self.set_title(WINDOW_TITLE_BASE + " - " + xstr("acceptedflt_title"))
579 self.set_size_request(-1, 700)
580 self.set_transient_for(gui.mainWindow)
581
582 alignment = gtk.Alignment(xscale = 1.0, yscale = 1.0)
583 alignment.set_padding(padding_top = 2, padding_bottom = 8,
584 padding_left = 4, padding_right = 4)
585
586 vbox = gtk.VBox()
587
588 hbox = gtk.HBox()
589 vbox.pack_start(hbox, True, True, 4)
590
591 self._flights = []
592 self._flightList = FlightList(columnDescriptors =
593 AcceptedFlightsWindow.columnDescriptors,
594 widthRequest = 750,
595 multiSelection = False)
596 self._flightList.connect("selection-changed", self._selectionChanged)
597
598 hbox.pack_start(self._flightList, True, True, 4)
599
600 buttonBox = gtk.VBox()
601
602 self._refreshButton = gtk.Button(xstr("acceptedflt_refresh"))
603 self._refreshButton.set_sensitive(True)
604 self._refreshButton.connect("clicked", self._refreshClicked)
605 buttonBox.pack_start(self._refreshButton, False, False, 2)
606
607 filler = gtk.Alignment(xalign = 0.0, yalign = 0.0,
608 xscale = 1.0, yscale = 1.0)
609 filler.set_size_request(-1, 4)
610 buttonBox.pack_start(filler, False, False, 0)
611
612 self._viewButton = gtk.Button(xstr("acceptedflt_view"))
613 self._viewButton.set_sensitive(False)
614 self._viewButton.connect("clicked", self._viewClicked)
615 buttonBox.pack_start(self._viewButton, False, False, 2)
616
617 hbox.pack_start(buttonBox, False, False, 4)
618
619 buttonAlignment = gtk.Alignment(xscale = 0.0, yscale = 0.0,
620 xalign = 0.5, yalign = 0.5)
621
622 self._closeButton = gtk.Button(xstr("button_ok"))
623 self._closeButton.connect("clicked", self._closeClicked)
624
625 buttonAlignment.add(self._closeButton)
626 vbox.pack_start(buttonAlignment, False, False, 2)
627
628 alignment.add(vbox)
629
630 self.add(alignment)
631
632 self.connect("key-press-event", self._keyPressed)
633
634 @property
635 def hasFlights(self):
636 """Determine if there are any flights that we know of."""
637 return len(self._flights)>0
638
639 def clear(self):
640 """Clear the flight list."""
641 self._flights = []
642 self._flightList.clear()
643
644 def addFlight(self, flight):
645 """Add the given flight."""
646 self._flights.append(flight)
647 self._flightList.addFlight(flight)
648
649 def _selectionChanged(self, flightList, selectedIndexes):
650 """Called when the selection has changed."""
651 self._viewButton.set_sensitive(len(selectedIndexes)==1)
652
653 def _refreshClicked(self, button):
654 """Called when the refresh button has been clicked."""
655 self.clear()
656 self._gui.showFlights(None)
657
658 def _viewClicked(self, button):
659 """Called when the view button has been clicked."""
660 gui = self._gui
661 gui.beginBusy(xstr("pendflt_pirep_busy"))
662 self.set_sensitive(False)
663
664 indexes = self._flightList.selectedIndexes
665 assert(len(indexes)==1)
666
667 flightID = self._flights[indexes[0]].bookedFlight.id
668 gui.webHandler.getPIREP(self._pirepResultCallback, flightID)
669
670 def _pirepResultCallback(self, returned, result):
671 """Called when the PIREP query result is available."""
672 gobject.idle_add(self._handlePIREPResult, returned, result)
673
674 def _handlePIREPResult(self, returned, result):
675 """Handle the refly result."""
676 self.set_sensitive(True)
677 gui = self._gui
678 gui.endBusy()
679
680 if returned:
681 gui.viewMessagedPIREP(result.pirep)
682
683 def _closeClicked(self, button):
684 """Called when the Close button is clicked.
685
686 A 'delete-event' is emitted to close the window."""
687 self.emit("delete-event", None)
688
689 def _keyPressed(self, window, event):
690 """Called when a key is pressed in the window.
691
692 If the Escape key is pressed, 'delete-event' is emitted to close the
693 window."""
694 if gdk.keyval_name(event.keyval) == "Escape":
695 self.emit("delete-event", None)
696 return True
697
698#-----------------------------------------------------------------------------
Note: See TracBrowser for help on using the repository browser.