Changeset 564:695cde9818ea for src/mlx/gui
- Timestamp:
- 02/22/14 09:50:09 (11 years ago)
- Branch:
- default
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/mlx/gui/flight.py
r563 r564 2815 2815 def __init__(self, wizard): 2816 2816 """Construct the finish page.""" 2817 help = xstr("finish_help") + xstr("finish_help_ wrongtime")2817 help = xstr("finish_help") + xstr("finish_help_goodtime") 2818 2818 super(FinishPage, self).__init__(wizard, xstr("finish_title"), help) 2819 2819 … … 3049 3049 self._flightRating.set_markup("<b>%.1f %%</b>" % (rating,)) 3050 3050 3051 bookedFlight = self._wizard.bookedFlight3052 3053 (markup, tooBigDeparture) = \3054 self._formatTime(bookedFlight.departureTime, flight.blockTimeStart)3055 3056 self._depTime.set_markup(markup)3057 3058 3051 flightLength = flight.flightTimeEnd - flight.flightTimeStart 3059 3052 self._flightTime.set_markup("<b>%s</b>" % \ … … 3063 3056 self._blockTime.set_markup("<b>%s</b>" % \ 3064 3057 (util.getTimeIntervalString(blockLength),)) 3065 3066 (markup, tooBigArrival) = \3067 self._formatTime(bookedFlight.arrivalTime, flight.blockTimeEnd)3068 3069 self._tooBigTimeDifference = tooBigDeparture or tooBigArrival3070 3071 if self._tooBigTimeDifference:3072 self.setHelp(xstr("finish_help") + xstr("finish_help_wrongtime"))3073 else:3074 self.setHelp(xstr("finish_help"))3075 3076 self._arrTime.set_markup(markup)3077 3058 3078 3059 self._distanceFlown.set_markup("<b>%.2f NM</b>" % \ … … 3101 3082 self._gate.set_sensitive(False) 3102 3083 3103 self. updateButtons()3084 self._updateTimes() 3104 3085 3105 3086 def updateButtons(self): … … 3147 3128 def _flightTypeChanged(self, comboBox): 3148 3129 """Called when the flight type has changed.""" 3149 self. updateButtons()3130 self._updateTimes() 3150 3131 3151 3132 def _gateChanged(self, comboBox): … … 3310 3291 pass 3311 3292 3312 def _formatTime(self, scheduledTime, realTimestamp ):3293 def _formatTime(self, scheduledTime, realTimestamp, (warning, error)): 3313 3294 """Format the departure or arrival time based on the given data as a 3314 markup for a label. 3315 3316 If the difference is greater than 15 minutes, the text should be 3317 red. Otherwise, if the difference is greater that 5 minutes, the text 3318 should be yellow. Otherwise it should be black. 3319 3320 scheduledTime is the scheduled time as a datetime object 3321 realTimestamp is the real time as a timestamp (i.e. seconds 3322 since the epoch) 3323 3324 Returns a tuple consisting of: 3325 - the markup, 3326 - a boolean indicating if the difference is greater than 15 minutes.""" 3295 markup for a label.""" 3327 3296 realTime = time.gmtime(realTimestamp) 3328 3297 3329 scheduledMinute = scheduledTime.hour * 60 + scheduledTime.minute 3330 realMinute = realTime.tm_hour * 60 + realTime.tm_min 3331 3332 diff1 = scheduledMinute - realMinute 3333 diff2 = -1 * diff1 3334 3335 if diff1 < 0: diff1 += 60*24 3336 else: diff2 += 60*24 3337 3338 diff = min(diff1, diff2) 3339 3340 if diff>5: 3341 colour = "red" if diff>15 else "orange" 3298 if warning: 3299 colour = "red" if error else "orange" 3342 3300 markupBegin = '<span foreground="%s">' % (colour,) 3343 3301 markupEnd = '</span>' … … 3351 3309 markupEnd) 3352 3310 3353 # print "mlx.gui.flight.FinishPage._formatTime: markup='%s', diff=%d" % \ 3354 # (markup, diff) 3355 3356 return (markup, diff>15) 3311 return markup 3312 3313 def _updateTimes(self): 3314 """Format the flight times and the help text according to the flight 3315 type. 3316 3317 The buttons are also updated. 3318 """ 3319 flight = self._wizard.gui._flight 3320 bookedFlight = flight.bookedFlight 3321 3322 (departureWarning, departureError) = flight.blockTimeStartWrong 3323 (arrivalWarning, arrivalError) = flight.blockTimeEndWrong 3324 3325 if self.flightType==const.FLIGHTTYPE_VIP: 3326 departureError = arrivalError = False 3327 3328 self._tooBigTimeDifference = departureError or arrivalError 3329 3330 if self._tooBigTimeDifference and self.flightType is not None: 3331 self.setHelp(xstr("finish_help") + xstr("finish_help_wrongtime")) 3332 else: 3333 self.setHelp(xstr("finish_help") + xstr("finish_help_goodtime")) 3334 3335 self._depTime.set_markup(self._formatTime(bookedFlight.departureTime, 3336 flight.blockTimeStart, 3337 (departureWarning, 3338 departureError))) 3339 3340 self._arrTime.set_markup(self._formatTime(bookedFlight.arrivalTime, 3341 flight.blockTimeEnd, 3342 (arrivalWarning, 3343 arrivalError))) 3344 3345 self.updateButtons() 3357 3346 3358 3347 #-----------------------------------------------------------------------------
Note:
See TracChangeset
for help on using the changeset viewer.