Changeset 94:dc8fbc53a90c for src
- Timestamp:
- 04/21/12 08:32:39 (13 years ago)
- Branch:
- default
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/mlx/gui/flight.py
r93 r94 33 33 class Page(gtk.Alignment): 34 34 """A page in the flight wizard.""" 35 def __init__(self, wizard, title, help ):35 def __init__(self, wizard, title, help, completedHelp = None): 36 36 """Construct the page.""" 37 37 super(Page, self).__init__(xalign = 0.0, yalign = 0.0, … … 75 75 76 76 alignment = gtk.Alignment(xalign = 0.5, yalign = 0.0, 77 xscale = 0 , yscale = 0.0)77 xscale = 0.0, yscale = 0.0) 78 78 alignment.set_padding(padding_top = 0, padding_bottom = 16, 79 79 padding_left = 0, padding_right = 0) 80 80 81 label = gtk.Label(help) 82 label.set_justify(gtk.Justification.CENTER if pygobject 83 else gtk.JUSTIFY_CENTER) 84 label.set_use_markup(True) 85 alignment.add(label) 81 self._help = help 82 self._completedHelp = completedHelp 83 84 if self._completedHelp is None or \ 85 len(help.splitlines())>=len(completedHelp.splitlines()): 86 longerHelp = help 87 else: 88 longerHelp = completedHelp 89 90 self._helpLabel = gtk.Label(completedHelp) 91 # FIXME: should be a constant in common 92 self._helpLabel.set_justify(gtk.Justification.CENTER if pygobject 93 else gtk.JUSTIFY_CENTER) 94 self._helpLabel.set_use_markup(True) 95 alignment.add(self._helpLabel) 86 96 mainBox.pack_start(alignment, False, False, 0) 87 97 … … 103 113 self._wizard = wizard 104 114 105 self._ finalized = False115 self._completed = False 106 116 self._fromPage = None 107 117 … … 122 132 return button 123 133 134 def initialize(self): 135 """Initialize the page. 136 137 It sets up the primary help, and calls the activate() function.""" 138 self._helpLabel.set_markup(self._help) 139 self._helpLabel.set_sensitive(True) 140 self.activate() 141 124 142 def activate(self): 125 143 """Called when this page becomes active. … … 127 145 This default implementation does nothing.""" 128 146 pass 147 148 def complete(self): 149 """Called when the page is completed. 150 151 It greys out/changes the help text and then calls finalize().""" 152 self.finalize() 153 if self._completedHelp is None: 154 self._helpLabel.set_sensitive(False) 155 else: 156 self._helpLabel.set_markup(self._completedHelp) 157 self._completed = True 129 158 130 159 def finalize(self): … … 139 168 def reset(self): 140 169 """Reset the page if the wizard is reset.""" 141 self._ finalized = False170 self._completed = False 142 171 self._fromPage = None 143 172 … … 282 311 def __init__(self, wizard): 283 312 """Construct the flight selection page.""" 313 help = "Select the flight you want to perform." 314 completedHelp = "You have selected the flight highlighted below." 284 315 super(FlightSelectionPage, self).__init__(wizard, "Flight selection", 285 "Select the flight you want " 286 "to perform.") 316 help, completedHelp = completedHelp) 287 317 288 318 … … 349 379 def _forwardClicked(self, button): 350 380 """Called when the forward button was clicked.""" 351 if self._ finalized:381 if self._completed: 352 382 self._wizard.jumpPage(self._nextDistance, finalize = False) 353 383 else: … … 466 496 def _forwardClicked(self, button): 467 497 """Called when the forward button is clicked.""" 468 if not self._ finalized:498 if not self._completed: 469 499 selection = self._gateList.get_selection() 470 500 (listStore, iter) = selection.get_selected() … … 510 540 "at the given airport, at the gate below, if present.\n\n" \ 511 541 "Then press the Connect button to connect to the simulator." 542 completedHelp = "The basic data of your flight can be read below." 512 543 super(ConnectPage, self).__init__(wizard, 513 544 "Connect to the simulator", 514 help )545 help, completedHelp = completedHelp) 515 546 516 547 alignment = gtk.Alignment(xalign = 0.5, yalign = 0.5, … … 643 674 "Setup the cargo weight here and the payload weight in the simulator.\n\n" \ 644 675 "You can also check here what the simulator reports as ZFW." 645 646 super(PayloadPage, self).__init__(wizard, "Payload", help) 676 completedHelp = "You can see the weights in the briefing\n" \ 677 "and the cargo weight you have selected below.\n\n" \ 678 "You can also query the ZFW reported by the simulator." 679 super(PayloadPage, self).__init__(wizard, "Payload", help, 680 completedHelp = completedHelp) 647 681 648 682 alignment = gtk.Alignment(xalign = 0.5, yalign = 0.5, … … 760 794 """Finalize the payload page.""" 761 795 self._cargoWeight.set_sensitive(False) 762 self._zfwButton.set_sensitive(False)763 796 764 797 def calculateZFW(self): … … 828 861 "You can also query the current UTC time from the simulator.\n" \ 829 862 "Ensure that you have enough time to properly prepare for the flight." 830 831 super(TimePage, self).__init__(wizard, "Time", help) 863 completedHelp = "The departure and arrival times are displayed below in UTC.\n\n" \ 864 "You can also query the current UTC time from the simulator.\n" 865 super(TimePage, self).__init__(wizard, "Time", help, 866 completedHelp = completedHelp) 832 867 833 868 alignment = gtk.Alignment(xalign = 0.5, yalign = 0.5, … … 881 916 self._arrival.set_text(str(bookedFlight.arrivalTime.time())) 882 917 self._simulatorTime.set_text("-") 883 884 def finalize(self):885 """Finalize the page."""886 self._timeButton.set_sensitive(False)887 918 888 919 def _timeRequested(self, button): … … 939 970 help = "Set your cruise flight level below, and\n" \ 940 971 "if necessary, edit the flight plan." 941 942 super(RoutePage, self).__init__(wizard, "Route", help) 972 completedHelp = "If necessary, you can modify the cruise level and\n" \ 973 "the flight plan below during flight.\n" \ 974 "If so, please, add a comment on why " \ 975 "the modification became necessary." 976 super(RoutePage, self).__init__(wizard, "Route", help, 977 completedHelp = completedHelp) 943 978 944 979 alignment = gtk.Alignment(xalign = 0.5, yalign = 0.5, … … 1015 1050 def activate(self): 1016 1051 """Setup the route from the booked flight.""" 1017 self._route.set_sensitive(True)1018 1052 self._cruiseLevel.set_value(240) 1019 self._cruiseLevel.set_sensitive(True)1020 1053 self._route.get_buffer().set_text(self._wizard._bookedFlight.route) 1021 1054 self._updateForwardButton() 1022 1023 def finalize(self):1024 """Finalize the page."""1025 self._route.set_sensitive(False)1026 self._cruiseLevel.set_sensitive(False)1027 1055 1028 1056 def _getRoute(self): … … 1051 1079 def _forwardClicked(self, button): 1052 1080 """Called when the Forward button is clicked.""" 1053 if self._ finalized:1081 if self._completed: 1054 1082 self._wizard.nextPage() 1055 1083 else: 1056 self._backButton.set_sensitive(False)1057 self._button.set_sensitive(False)1058 self._cruiseLevel.set_sensitive(False)1059 self._route.set_sensitive(False)1060 1061 1084 bookedFlight = self._wizard._bookedFlight 1062 1085 self._wizard.gui.beginBusy("Downloading NOTAMs...") … … 1116 1139 else "arrival") 1117 1140 1118 help = "Read carefully the NOTAMs and METAR below." 1119 1120 super(BriefingPage, self).__init__(wizard, title, help) 1141 help = "Read carefully the NOTAMs and METAR below.\n\n" \ 1142 "You can edit the METAR if your simulator or network\n" \ 1143 "provides different weather." 1144 completedHelp = "If your simulator or network provides a different\n" \ 1145 "weather, you can edit the METAR below." 1146 super(BriefingPage, self).__init__(wizard, title, help, 1147 completedHelp = completedHelp) 1121 1148 1122 1149 alignment = gtk.Alignment(xalign = 0.5, yalign = 0.5, … … 1131 1158 scrolledWindow = gtk.ScrolledWindow() 1132 1159 scrolledWindow.set_size_request(-1, 128) 1160 # FIXME: these constants should be in common 1133 1161 scrolledWindow.set_policy(gtk.PolicyType.AUTOMATIC if pygobject 1134 1162 else gtk.POLICY_AUTOMATIC, … … 1157 1185 else gtk.POLICY_AUTOMATIC) 1158 1186 self._metar = gtk.TextView() 1159 self._metar.set_editable(False)1160 1187 self._metar.set_accepts_tab(False) 1161 1188 self._metar.set_wrap_mode(gtk.WrapMode.WORD if pygobject else gtk.WRAP_WORD) … … 1227 1254 """Called when the forward button is clicked.""" 1228 1255 if not self._departure: 1229 if not self._ finalized:1256 if not self._completed: 1230 1257 self._wizard.gui.startMonitoring() 1231 1258 self._button.set_use_stock(True) 1232 1259 self._button.set_label(gtk.STOCK_GO_FORWARD) 1233 self. _finalized = True1260 self.complete() 1234 1261 1235 1262 self._wizard.nextPage() … … 1242 1269 """Construct the takeoff page.""" 1243 1270 help = "Enter the runway and SID used, as well as the speeds." 1244 1245 super(TakeoffPage, self).__init__(wizard, "Takeoff", help) 1271 completedHelp = "The runway, SID and takeoff speeds logged can be seen below." 1272 1273 super(TakeoffPage, self).__init__(wizard, "Takeoff", help, 1274 completedHelp = completedHelp) 1246 1275 1247 1276 alignment = gtk.Alignment(xalign = 0.5, yalign = 0.5, … … 1381 1410 help = "Enter the STAR and/or transition, runway,\n" \ 1382 1411 "approach type and V<sub>Ref</sub> used." 1383 1384 super(LandingPage, self).__init__(wizard, "Landing", help) 1412 completedHelp = "The STAR and/or transition, runway, approach\n" \ 1413 "type and V<sub>Ref</sub> logged can be seen below." 1414 1415 super(LandingPage, self).__init__(wizard, "Landing", help, 1416 completedHelp = completedHelp) 1385 1417 1386 1418 self._flightEnded = False … … 1658 1690 table.attach(labelAlignment, 1, 2, 4, 5) 1659 1691 1692 button = self.addButton(gtk.STOCK_GO_BACK) 1693 button.set_use_stock(True) 1694 button.connect("clicked", self._backClicked) 1695 1660 1696 self._saveButton = self.addButton("S_ave PIREP...") 1661 1697 self._saveButton.set_use_underline(True) 1698 self._saveButton.set_sensitive(False) 1662 1699 #self._saveButton.connect("clicked", self._saveClicked) 1663 1700 1664 1701 self._sendButton = self.addButton("_Send PIREP...", True) 1665 1702 self._sendButton.set_use_underline(True) 1703 self._sendButton.set_sensitive(False) 1666 1704 #self._sendButton.connect("clicked", self._sendClicked) 1667 1705 … … 1689 1727 (flight.endFuel - flight.startFuel,)) 1690 1728 1729 def _backClicked(self, button): 1730 """Called when the Back button is pressed.""" 1731 self.goBack() 1732 1691 1733 #----------------------------------------------------------------------------- 1692 1734 … … 1746 1788 if fromPage is not None: 1747 1789 page = self._pages[fromPage] 1748 if finalize and not page._finalized: 1749 page.finalize() 1750 page._finalized = True 1790 if finalize and not page._completed: 1791 page.complete() 1751 1792 self.remove(page) 1752 1793 … … 1756 1797 if page._fromPage is None: 1757 1798 page._fromPage = fromPage 1758 page. activate()1799 page.initialize() 1759 1800 self.show_all() 1760 1801 if fromPage is not None:
Note:
See TracChangeset
for help on using the changeset viewer.