Changeset 1033:330058d37574 for src/mlx/gui/flight.py
- Timestamp:
- 03/14/22 08:46:34 (2 years ago)
- Branch:
- python3
- hg-Phase:
- (<MercurialRepository 1 'hg:/home/ivaradi/mlx/hg' '/'>, 'public')
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/mlx/gui/flight.py
r1008 r1033 15 15 from mlx.i18n import xstr, getLanguage 16 16 from mlx.sound import startSound 17 from mlx.rpc import BookedFlight 17 18 import mlx.web as web 18 19 … … 2105 2106 super(PayloadPage, self).__init__(wizard, "payload", 2106 2107 xstr("payload_title"), 2107 xstr("payload_help") ,2108 xstr("payload_help") + "\n\n \n \n", 2108 2109 completedHelp = xstr("payload_chelp")) 2109 2110 … … 2118 2119 self.setMainWidget(alignment) 2119 2120 2120 label = Gtk.Label(xstr("payload_crew"))2121 self._crewLabel = label = Gtk.Label(xstr("payload_crew")) 2121 2122 label.set_use_underline(True) 2122 2123 label.set_alignment(0.0, 0.5) 2123 2124 table.attach(label, 0, 1, 0, 1) 2124 2125 2125 self._numCrew = IntegerEntry(defaultValue = 0) 2126 self._numCrew.set_width_chars(6) 2127 self._numCrew.connect("integer-changed", self._weightChanged) 2128 self._numCrew.set_tooltip_text(xstr("payload_crew_tooltip")) 2129 table.attach(self._numCrew, 1, 2, 0, 1) 2130 label.set_mnemonic_widget(self._numCrew) 2131 2132 label = Gtk.Label(xstr("payload_pax")) 2126 self._numCockpitCrew = Gtk.Label() 2127 2128 self._numCabinCrew = IntegerEntry(defaultValue = 0) 2129 self._numCabinCrew.set_width_chars(6) 2130 self._numCabinCrew.connect("integer-changed", self._weightChanged) 2131 self._numCabinCrew.set_tooltip_text(xstr("payload_crew_tooltip")) 2132 2133 crewBox = Gtk.HBox() 2134 crewBox.pack_start(self._numCockpitCrew, False, False, 0) 2135 crewBox.pack_start(Gtk.Label("+"), False, False, 4) 2136 crewBox.pack_start(self._numCabinCrew, False, False, 0) 2137 crewBox.set_halign(Gtk.Align.END) 2138 2139 table.attach(crewBox, 1, 2, 0, 1) 2140 label.set_mnemonic_widget(self._numCabinCrew) 2141 2142 label = Gtk.Label(xstr("payload_crew_info")) 2143 label.set_halign(Gtk.Align.START) 2144 table.attach(label, 2, 3, 0, 1) 2145 2146 self._paxLabel = label = Gtk.Label(xstr("payload_pax")) 2133 2147 label.set_use_underline(True) 2134 2148 label.set_alignment(0.0, 0.5) … … 2139 2153 self._numPassengers.connect("integer-changed", self._weightChanged) 2140 2154 self._numPassengers.set_tooltip_text(xstr("payload_pax_tooltip")) 2141 table.attach(self._numPassengers, 1, 2, 1, 2) 2155 2156 self._numChildren = IntegerEntry(defaultValue = 0) 2157 self._numChildren.set_width_chars(6) 2158 self._numChildren.connect("integer-changed", self._weightChanged) 2159 self._numChildren.set_tooltip_text(xstr("payload_pax_children_tooltip")) 2160 2161 self._numInfants = IntegerEntry(defaultValue = 0) 2162 self._numInfants.set_width_chars(6) 2163 self._numInfants.connect("integer-changed", self._weightChanged) 2164 self._numInfants.set_tooltip_text(xstr("payload_pax_infants_tooltip")) 2165 2166 paxBox = Gtk.HBox() 2167 paxBox.pack_start(self._numPassengers, False, False, 0) 2168 paxBox.pack_start(Gtk.Label("+"), False, False, 4) 2169 paxBox.pack_start(self._numChildren, False, False, 0) 2170 paxBox.pack_start(Gtk.Label("+"), False, False, 4) 2171 paxBox.pack_start(self._numInfants, False, False, 0) 2172 2173 table.attach(paxBox, 1, 2, 1, 2) 2142 2174 label.set_mnemonic_widget(self._numPassengers) 2175 2176 label = Gtk.Label(xstr("payload_pax_info")) 2177 label.set_halign(Gtk.Align.START) 2178 table.attach(label, 2, 3, 1, 2) 2143 2179 2144 2180 label = Gtk.Label(xstr("payload_bag")) … … 2151 2187 self._bagWeight.connect("integer-changed", self._weightChanged) 2152 2188 self._bagWeight.set_tooltip_text(xstr("payload_bag_tooltip")) 2189 self._bagWeight.set_hexpand(False) 2190 self._bagWeight.set_halign(Gtk.Align.END) 2153 2191 table.attach(self._bagWeight, 1, 2, 2, 3) 2154 2192 label.set_mnemonic_widget(self._bagWeight) 2155 2193 2156 table.attach(Gtk.Label("kg"), 2, 3, 2, 3) 2194 label = Gtk.Label("kg") 2195 label.set_halign(Gtk.Align.START) 2196 table.attach(label, 2, 3, 2, 3) 2157 2197 2158 2198 label = Gtk.Label(xstr("payload_cargo")) … … 2165 2205 self._cargoWeight.connect("integer-changed", self._weightChanged) 2166 2206 self._cargoWeight.set_tooltip_text(xstr("payload_cargo_tooltip")) 2207 self._cargoWeight.set_hexpand(False) 2208 self._cargoWeight.set_halign(Gtk.Align.END) 2167 2209 table.attach(self._cargoWeight, 1, 2, 3, 4) 2168 2210 label.set_mnemonic_widget(self._cargoWeight) 2169 2211 2170 table.attach(Gtk.Label("kg"), 2, 3, 3, 4) 2212 label = Gtk.Label("kg") 2213 label.set_halign(Gtk.Align.START) 2214 table.attach(label, 2, 3, 3, 4) 2171 2215 2172 2216 label = Gtk.Label(xstr("payload_mail")) … … 2179 2223 self._mailWeight.connect("integer-changed", self._weightChanged) 2180 2224 self._mailWeight.set_tooltip_text(xstr("payload_mail_tooltip")) 2225 self._mailWeight.set_hexpand(False) 2226 self._mailWeight.set_halign(Gtk.Align.END) 2181 2227 table.attach(self._mailWeight, 1, 2, 4, 5) 2182 2228 label.set_mnemonic_widget(self._mailWeight) 2183 2229 2184 table.attach(Gtk.Label("kg"), 2, 3, 4, 5) 2230 label = Gtk.Label("kg") 2231 label.set_halign(Gtk.Align.START) 2232 table.attach(label, 2, 3, 4, 5) 2185 2233 2186 2234 label = Gtk.Label("<b>" + xstr("payload_zfw") + "</b>") … … 2194 2242 table.attach(self._calculatedZFW, 1, 2, 5, 6) 2195 2243 2196 table.attach(Gtk.Label("kg"), 2, 3, 5, 6) 2244 label = Gtk.Label("kg") 2245 label.set_halign(Gtk.Align.START) 2246 table.attach(label, 2, 3, 5, 6) 2197 2247 2198 2248 self._zfwButton = Gtk.Button(xstr("payload_fszfw")) … … 2208 2258 self._simulatorZFWValue = None 2209 2259 2210 table.attach(Gtk.Label("kg"), 2, 3, 6, 7) 2260 label = Gtk.Label("kg") 2261 label.set_halign(Gtk.Align.START) 2262 table.attach(label, 2, 3, 6, 7) 2211 2263 2212 2264 self.addCancelFlightButton() … … 2215 2267 2216 2268 @property 2217 def numCrew(self): 2218 """The number of the crew members on the flight.""" 2219 return self._numCrew.get_int() 2269 def numCockpitCrew(self): 2270 """The number of the cockpit crew members on the flight.""" 2271 return self._wizard._bookedFlight.numCockpitCrew 2272 2273 @property 2274 def numCabinCrew(self): 2275 """The number of the cabin members on the flight.""" 2276 return self._numCabinCrew.get_int() 2220 2277 2221 2278 @property 2222 2279 def numPassengers(self): 2223 """The number of the passengers on the flight."""2280 """The number of the adult passengers on the flight.""" 2224 2281 return self._numPassengers.get_int() 2282 2283 @property 2284 def numChildren(self): 2285 """The number of the child passengers on the flight.""" 2286 return self._numChildren.get_int() 2287 2288 @property 2289 def numInfants(self): 2290 """The number of the infant passengers on the flight.""" 2291 return self._numInfants.get_int() 2225 2292 2226 2293 @property … … 2243 2310 bookedFlight = self._wizard._bookedFlight 2244 2311 2245 self._numCrew.set_int(bookedFlight.numCrew) 2246 self._numCrew.set_sensitive(True) 2312 self._numCockpitCrew.set_markup("<b>" + 2313 str(bookedFlight.numCockpitCrew) + 2314 "</b>") 2315 self._numCabinCrew.set_int(bookedFlight.numCabinCrew) 2316 self._numCabinCrew.set_sensitive(True) 2317 2318 2247 2319 self._numPassengers.set_int(bookedFlight.numPassengers) 2248 2320 self._numPassengers.set_sensitive(True) 2249 2321 2322 self._numChildren.set_int(bookedFlight.numChildren) 2323 self._numChildren.set_sensitive(True) 2324 2325 self._numInfants.set_int(bookedFlight.numInfants) 2326 self._numInfants.set_sensitive(True) 2327 2250 2328 self._bagWeight.set_int(bookedFlight.bagWeight) 2251 2329 self._bagWeight.set_sensitive(True) 2252 self._cargoWeight.set_int(bookedFlight.cargoWeight) 2253 self._cargoWeight.set_sensitive(True) 2254 self._mailWeight.set_int(bookedFlight.mailWeight) 2255 self._mailWeight.set_sensitive(True) 2330 2331 if bookedFlight.flightType==BookedFlight.FLIGHT_TYPE_CHARTER: 2332 self._cargoWeight.set_int(0) 2333 self._cargoWeight.set_sensitive(False) 2334 self._mailWeight.set_int(0) 2335 self._mailWeight.set_sensitive(False) 2336 else: 2337 self._cargoWeight.set_int(bookedFlight.cargoWeight) 2338 self._cargoWeight.set_sensitive(True) 2339 self._mailWeight.set_int(bookedFlight.mailWeight) 2340 self._mailWeight.set_sensitive(True) 2256 2341 2257 2342 self._simulatorZFW.set_text("-") … … 2262 2347 def finalize(self): 2263 2348 """Finalize the payload page.""" 2264 self._numC rew.set_sensitive(False)2349 self._numCabinCrew.set_sensitive(False) 2265 2350 self._numPassengers.set_sensitive(False) 2351 self._numChildren.set_sensitive(False) 2352 self._numInfants.set_sensitive(False) 2266 2353 self._bagWeight.set_sensitive(False) 2267 2354 self._cargoWeight.set_sensitive(False) … … 2271 2358 def calculateZFW(self): 2272 2359 """Calculate the ZFW value.""" 2273 zfw = self._wizard.gui._flight.aircraft.dow 2274 zfw += (self._numCrew.get_int() + self._numPassengers.get_int()) * 82 2360 bookedFlight = self._wizard._bookedFlight 2361 2362 zfw = bookedFlight.dow 2363 zfw += (self._numCabinCrew.get_int() - bookedFlight.dowNumCabinCrew) * \ 2364 const.WEIGHT_CABIN_CREW 2365 zfw += self._numPassengers.get_int() * \ 2366 (const.WEIGHT_PASSENGER_CHARTER 2367 if bookedFlight.flightType==BookedFlight.FLIGHT_TYPE_CHARTER 2368 else const.WEIGHT_PASSENGER) 2369 zfw += self._numChildren.get_int() * const.WEIGHT_CHILD 2370 zfw += self._numInfants.get_int() * const.WEIGHT_INFANT 2275 2371 zfw += self._bagWeight.get_int() 2276 2372 zfw += self._cargoWeight.get_int() … … 2291 2387 2292 2388 def _weightChanged(self, entry, weight): 2293 """Called when one of the weight values or humanm counts has changed.""" 2389 """Called when one of the weight values or humanm counts has 2390 changed.""" 2391 bookedFlight = self._wizard._bookedFlight 2392 numPassengers = \ 2393 self._numPassengers.get_int() + \ 2394 self._numChildren.get_int() + \ 2395 self._numInfants.get_int() 2396 minCabinCrew = 0 if numPassengers==0 else \ 2397 (bookedFlight.maxPassengers // 50) + 1 2398 2399 extraHelp = [] 2400 enoughCrew = self._numCabinCrew.get_int() >= minCabinCrew 2401 if enoughCrew: 2402 self._crewLabel.set_text(xstr("payload_crew")) 2403 self.setHelp(xstr("payload_help")) 2404 else: 2405 self._crewLabel.set_markup("<b><span foreground=\"red\">" + 2406 xstr("payload_crew") + 2407 "</span></b>") 2408 extraHelp.append(xstr("payload_help_few_crew") % (minCabinCrew,)) 2409 self._crewLabel.set_use_underline(True) 2410 2411 tooManyPassengers = numPassengers>bookedFlight.maxPassengers 2412 if tooManyPassengers: 2413 self._paxLabel.set_markup("<b><span foreground=\"red\">" + 2414 xstr("payload_pax") + 2415 "</span></b>") 2416 extraHelp.append(xstr("payload_help_many_pax") % (bookedFlight.maxPassengers,)) 2417 else: 2418 self._paxLabel.set_text(xstr("payload_pax")) 2419 self._paxLabel.set_use_underline(True) 2420 2421 hlp = xstr("payload_help") + "\n\n" 2422 for eh in extraHelp: 2423 hlp += "<b><span foreground=\"red\">" + eh + "</span></b>\n" 2424 hlp += " \n" * (2-len(extraHelp)) 2425 self.setHelp(hlp) 2426 2427 self._button.set_sensitive(enoughCrew and not tooManyPassengers) 2428 2429 2294 2430 self._updateCalculatedZFW() 2295 2431 … … 5539 5675 5540 5676 @property 5541 def numCrew(self): 5542 """Get the number of crew members.""" 5543 return self._payloadPage.numCrew 5677 def numCockpitCrew(self): 5678 """Get the number of cockpit crew members.""" 5679 return self._payloadPage.numCockpitCrew 5680 5681 @property 5682 def numCabinCrew(self): 5683 """Get the number of cabin crew members.""" 5684 return self._payloadPage.numCabinCrew 5544 5685 5545 5686 @property … … 5547 5688 """Get the number of passengers.""" 5548 5689 return self._payloadPage.numPassengers 5690 5691 @property 5692 def numChildren(self): 5693 """Get the number of child passengers.""" 5694 return self._payloadPage.numChildren 5695 5696 @property 5697 def numInfants(self): 5698 """Get the number of infant passengers.""" 5699 return self._payloadPage.numInfants 5549 5700 5550 5701 @property
Note:
See TracChangeset
for help on using the changeset viewer.