Changeset 555:e62f78ae65a0 for src
- Timestamp:
- 02/01/14 09:18:39 (11 years ago)
- Branch:
- default
- Phase:
- public
- Location:
- src/mlx/gui
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
src/mlx/gui/delaycodes.py
r439 r555 233 233 class DelayCodeTable(DelayCodeTableBase): 234 234 """The delay code table.""" 235 def __init__(self ):235 def __init__(self, info): 236 236 """Construct the delay code table.""" 237 237 super(DelayCodeTable, self).__init__() 238 239 self._info = info 238 240 239 241 self._delayCodeData = None … … 271 273 272 274 return codes 275 276 @property 277 def hasDelayCode(self): 278 """Determine if there is at least one delay code selected.""" 279 if self._delayCodeData is not None: 280 for checkButton in self._checkButtons: 281 if checkButton.get_active(): 282 return True 283 284 return False 273 285 274 286 def allocate_column_sizes(self, allocation): … … 332 344 elif type==DELAYCODE: 333 345 checkButton = CheckButton(elements) 346 checkButton.connect("toggled", self._delayCodesChanged) 334 347 self._checkButtons.append(checkButton) 335 348 alignment = Alignment(xalign = 0.5, yalign = 0.5, xscale = 1.0) … … 366 379 self.show_all() 367 380 368 #------------------------------------------------------------------------------ 381 def _delayCodesChanged(self, button): 382 """Called when one of the delay codes have changed.""" 383 self._info.delayCodesChanged() 384 385 #------------------------------------------------------------------------------ -
src/mlx/gui/flight.py
r554 r555 2821 2821 self.setMainWidget(alignment) 2822 2822 2823 row = 0 2824 2823 2825 labelAlignment = gtk.Alignment(xalign=1.0, xscale=0.0) 2824 2826 label = gtk.Label(xstr("finish_rating")) 2825 2827 labelAlignment.add(label) 2826 table.attach(labelAlignment, 0, 1, 0,1)2828 table.attach(labelAlignment, 0, 1, row, row+1) 2827 2829 2828 2830 labelAlignment = gtk.Alignment(xalign=0.0, xscale=0.0) … … 2832 2834 self._flightRating.set_use_markup(True) 2833 2835 labelAlignment.add(self._flightRating) 2834 table.attach(labelAlignment, 1, 2, 0, 1) 2836 table.attach(labelAlignment, 1, 2, row, row+1) 2837 2838 row += 1 2839 2840 labelAlignment = gtk.Alignment(xalign=1.0, xscale=0.0) 2841 label = gtk.Label(xstr("finish_dep_time")) 2842 labelAlignment.add(label) 2843 table.attach(labelAlignment, 0, 1, row, row+1) 2844 2845 labelAlignment = gtk.Alignment(xalign=0.0, xscale=0.0) 2846 self._depTime = gtk.Label() 2847 self._depTime.set_width_chars(10) 2848 self._depTime.set_alignment(0.0, 0.5) 2849 self._depTime.set_use_markup(True) 2850 labelAlignment.add(self._depTime) 2851 table.attach(labelAlignment, 1, 2, row, row+1) 2852 2853 row += 1 2835 2854 2836 2855 labelAlignment = gtk.Alignment(xalign=1.0, xscale=0.0) 2837 2856 label = gtk.Label(xstr("finish_flight_time")) 2838 2857 labelAlignment.add(label) 2839 table.attach(labelAlignment, 0, 1, 1, 2)2858 table.attach(labelAlignment, 0, 1, row, row+1) 2840 2859 2841 2860 labelAlignment = gtk.Alignment(xalign=0.0, xscale=0.0) … … 2845 2864 self._flightTime.set_use_markup(True) 2846 2865 labelAlignment.add(self._flightTime) 2847 table.attach(labelAlignment, 1, 2, 1, 2) 2866 table.attach(labelAlignment, 1, 2, row, row+1) 2867 2868 row += 1 2848 2869 2849 2870 labelAlignment = gtk.Alignment(xalign=1.0, xscale=0.0) 2850 2871 label = gtk.Label(xstr("finish_block_time")) 2851 2872 labelAlignment.add(label) 2852 table.attach(labelAlignment, 0, 1, 2, 3)2873 table.attach(labelAlignment, 0, 1, row, row+1) 2853 2874 2854 2875 labelAlignment = gtk.Alignment(xalign=0.0, xscale=0.0) … … 2858 2879 self._blockTime.set_use_markup(True) 2859 2880 labelAlignment.add(self._blockTime) 2860 table.attach(labelAlignment, 1, 2, 2, 3) 2881 table.attach(labelAlignment, 1, 2, row, row+1) 2882 2883 row += 1 2884 2885 labelAlignment = gtk.Alignment(xalign=1.0, xscale=0.0) 2886 label = gtk.Label(xstr("finish_arr_time")) 2887 labelAlignment.add(label) 2888 table.attach(labelAlignment, 0, 1, row, row+1) 2889 2890 labelAlignment = gtk.Alignment(xalign=0.0, xscale=0.0) 2891 self._arrTime = gtk.Label() 2892 self._arrTime.set_width_chars(10) 2893 self._arrTime.set_alignment(0.0, 0.5) 2894 self._arrTime.set_use_markup(True) 2895 labelAlignment.add(self._arrTime) 2896 table.attach(labelAlignment, 1, 2, row, row+1) 2897 2898 row += 1 2861 2899 2862 2900 labelAlignment = gtk.Alignment(xalign=1.0, xscale=0.0) 2863 2901 label = gtk.Label(xstr("finish_distance")) 2864 2902 labelAlignment.add(label) 2865 table.attach(labelAlignment, 0, 1, 3, 4)2903 table.attach(labelAlignment, 0, 1, row, row+1) 2866 2904 2867 2905 labelAlignment = gtk.Alignment(xalign=0.0, xscale=0.0) … … 2871 2909 self._distanceFlown.set_use_markup(True) 2872 2910 labelAlignment.add(self._distanceFlown) 2873 table.attach(labelAlignment, 1, 2, 3, 4) 2911 table.attach(labelAlignment, 1, 2, row, row+1) 2912 2913 row += 1 2874 2914 2875 2915 labelAlignment = gtk.Alignment(xalign=1.0, xscale=0.0) 2876 2916 label = gtk.Label(xstr("finish_fuel")) 2877 2917 labelAlignment.add(label) 2878 table.attach(labelAlignment, 0, 1, 4, 5)2918 table.attach(labelAlignment, 0, 1, row, row+1) 2879 2919 2880 2920 labelAlignment = gtk.Alignment(xalign=0.0, xscale=0.0) … … 2884 2924 self._fuelUsed.set_use_markup(True) 2885 2925 labelAlignment.add(self._fuelUsed) 2886 table.attach(labelAlignment, 1, 2, 4, 5) 2926 table.attach(labelAlignment, 1, 2, row, row+1) 2927 2928 row += 1 2887 2929 2888 2930 labelAlignment = gtk.Alignment(xalign = 1.0, xscale = 0.0, … … 2891 2933 label.set_use_underline(True) 2892 2934 labelAlignment.add(label) 2893 table.attach(labelAlignment, 0, 1, 5, 6)2935 table.attach(labelAlignment, 0, 1, row, row+1) 2894 2936 2895 2937 flightTypeModel = gtk.ListStore(str, int) … … 2906 2948 flightTypeAlignment = gtk.Alignment(xalign=0.0, xscale=0.0) 2907 2949 flightTypeAlignment.add(self._flightType) 2908 table.attach(flightTypeAlignment, 1, 2, 5, 6)2950 table.attach(flightTypeAlignment, 1, 2, row, row+1) 2909 2951 label.set_mnemonic_widget(self._flightType) 2952 2953 row += 1 2910 2954 2911 2955 self._onlineFlight = gtk.CheckButton(xstr("finish_online")) … … 2914 2958 onlineFlightAlignment = gtk.Alignment(xalign=0.0, xscale=0.0) 2915 2959 onlineFlightAlignment.add(self._onlineFlight) 2916 table.attach(onlineFlightAlignment, 1, 2, 6, 7) 2960 table.attach(onlineFlightAlignment, 1, 2, row, row + 1) 2961 2962 row += 1 2917 2963 2918 2964 labelAlignment = gtk.Alignment(xalign = 1.0, xscale = 0.0, … … 2921 2967 self._gateLabel.set_use_underline(True) 2922 2968 labelAlignment.add(self._gateLabel) 2923 table.attach(labelAlignment, 0, 1, 7, 8)2969 table.attach(labelAlignment, 0, 1, row, row+1) 2924 2970 2925 2971 self._gatesModel = gtk.ListStore(str) … … 2933 2979 gateAlignment = gtk.Alignment(xalign=0.0, xscale=1.0) 2934 2980 gateAlignment.add(self._gate) 2935 table.attach(gateAlignment, 1, 2, 7, 8)2981 table.attach(gateAlignment, 1, 2, row, row+1) 2936 2982 self._gateLabel.set_mnemonic_widget(self._gate) 2937 2983 … … 2951 2997 self._lastSavePath = None 2952 2998 2999 self._tooBigTimeDifference = False 3000 self._deferredAutoSave = False 2953 3001 self._pirepSaved = False 2954 3002 self._pirepSent = False … … 2959 3007 tooltip = xstr("sendPIREP_tooltip")) 2960 3008 3009 # self._formatTime(datetime.datetime(1970, 1, 1, 0, 10), 10*60.0) 3010 # self._formatTime(datetime.datetime(1970, 1, 1, 0, 10), 20*60.0) 3011 # self._formatTime(datetime.datetime(1970, 1, 1, 0, 10), 0*60.0) 3012 # self._formatTime(datetime.datetime(1970, 1, 1, 0, 10), (23*60.0+50)*60.0) 3013 # self._formatTime(datetime.datetime(1970, 1, 1, 1, 0), (1*60.0+5)*60.0) 3014 # self._formatTime(datetime.datetime(1970, 1, 1, 1, 0), (0*60.0+50)*60.0) 3015 # self._formatTime(datetime.datetime(1970, 1, 1, 23, 55), (0*60.0+5)*60.0) 3016 # self._formatTime(datetime.datetime(1970, 1, 1, 23, 55), (23*60.0+45)*60.0) 3017 2961 3018 @property 2962 3019 def flightType(self): … … 2972 3029 def activate(self): 2973 3030 """Activate the page.""" 3031 self._deferredAutoSave = False 2974 3032 self._pirepSaved = False 2975 3033 self._pirepSent = False … … 2982 3040 self._flightRating.set_markup("<b>%.1f %%</b>" % (rating,)) 2983 3041 3042 bookedFlight = self._wizard.bookedFlight 3043 3044 (markup, tooBigDeparture) = \ 3045 self._formatTime(bookedFlight.departureTime, flight.blockTimeStart) 3046 3047 self._depTime.set_markup(markup) 3048 2984 3049 flightLength = flight.flightTimeEnd - flight.flightTimeStart 2985 3050 self._flightTime.set_markup("<b>%s</b>" % \ … … 2989 3054 self._blockTime.set_markup("<b>%s</b>" % \ 2990 3055 (util.getTimeIntervalString(blockLength),)) 3056 3057 (markup, tooBigArrival) = \ 3058 self._formatTime(bookedFlight.arrivalTime, flight.blockTimeEnd) 3059 3060 self._tooBigTimeDifference = tooBigDeparture or tooBigArrival 3061 3062 self._arrTime.set_markup(markup) 2991 3063 2992 3064 self._distanceFlown.set_markup("<b>%.2f NM</b>" % \ … … 3015 3087 self._gate.set_sensitive(False) 3016 3088 3089 self.updateButtons() 3090 3091 def updateButtons(self): 3092 """Update the sensitivity state of the buttons.""" 3093 gui = self._wizard.gui 3094 sensitive = self._flightType.get_active()>=0 and \ 3095 (self._gatesModel.get_iter_first() is None or 3096 self._gate.get_active()>=0) and \ 3097 (not self._tooBigTimeDifference or 3098 gui.hasComments or gui.hasDelayCode) 3099 3100 wasSensitive = self._saveButton.get_sensitive() 3101 3102 if gui.config.pirepAutoSave and sensitive and not wasSensitive: 3103 if gui.isWizardActive(): 3104 self._autoSavePIREP() 3105 else: 3106 self._deferredAutoSave = True 3107 3108 if not sensitive: 3109 self._deferredAutoSave = False 3110 3111 self._saveButton.set_sensitive(sensitive) 3112 self._sendButton.set_sensitive(sensitive and 3113 self._wizard.bookedFlight.id is not None) 3114 3115 def grabDefault(self): 3116 """If the page has a default button, make it the default one.""" 3117 super(FinishPage, self).grabDefault() 3118 if self._deferredAutoSave: 3119 self._autoSavePIREP() 3120 self._deferredAutoSave = False 3121 3122 def _autoSavePIREP(self): 3123 """Perform the automatic saving of the PIREP.""" 3124 self._lastSavePath = os.path.join(self._wizard.gui.config.pirepDirectory, 3125 self._getDefaultPIREPName()) 3126 self._lastSavePath = text2unicode(self._lastSavePath) 3127 self._savePIREP(automatic = True) 3128 3017 3129 def _backClicked(self, button): 3018 3130 """Called when the Back button is pressed.""" 3019 3131 self.goBack() 3020 3132 3021 def _updateButtons(self):3022 """Update the sensitivity state of the buttons."""3023 sensitive = self._flightType.get_active()>=0 and \3024 (self._gatesModel.get_iter_first() is None or3025 self._gate.get_active()>=0)3026 3027 wasSensitive = self._saveButton.get_sensitive()3028 3029 gui = self._wizard.gui3030 config = gui.config3031 if config.pirepAutoSave and sensitive and not wasSensitive:3032 self._lastSavePath = os.path.join(config.pirepDirectory,3033 self._getDefaultPIREPName())3034 self._lastSavePath = text2unicode(self._lastSavePath)3035 self._savePIREP(automatic = True)3036 3037 self._saveButton.set_sensitive(sensitive)3038 self._sendButton.set_sensitive(sensitive and3039 self._wizard.bookedFlight.id is not None)3040 3041 3133 def _flightTypeChanged(self, comboBox): 3042 3134 """Called when the flight type has changed.""" 3043 self. _updateButtons()3135 self.updateButtons() 3044 3136 3045 3137 def _gateChanged(self, comboBox): 3046 3138 """Called when the arrival gate has changed.""" 3047 self. _updateButtons()3139 self.updateButtons() 3048 3140 3049 3141 def _newFlightClicked(self, button): … … 3203 3295 """Callback for the plane updating.""" 3204 3296 pass 3297 3298 def _formatTime(self, scheduledTime, realTimestamp): 3299 """Format the departure or arrival time based on the given data as a 3300 markup for a label. 3301 3302 If the difference is greater than 15 minutes, the text should be 3303 red. Otherwise, if the difference is greater that 5 minutes, the text 3304 should be yellow. Otherwise it should be black. 3305 3306 scheduledTime is the scheduled time as a datetime object 3307 realTimestamp is the real time as a timestamp (i.e. seconds 3308 since the epoch) 3309 3310 Returns a tuple consisting of: 3311 - the markup, 3312 - a boolean indicating if the difference is greater than 15 minutes.""" 3313 realTime = time.gmtime(realTimestamp) 3314 3315 scheduledMinute = scheduledTime.hour * 60 + scheduledTime.minute 3316 realMinute = realTime.tm_hour * 60 + realTime.tm_min 3317 3318 diff1 = scheduledMinute - realMinute 3319 diff2 = -1 * diff1 3320 3321 if diff1 < 0: diff1 += 60*24 3322 else: diff2 += 60*24 3323 3324 diff = min(diff1, diff2) 3325 3326 if diff>5: 3327 colour = "red" if diff>15 else "orange" 3328 markupBegin = '<span foreground="%s">' % (colour,) 3329 markupEnd = '</span>' 3330 else: 3331 markupBegin = markupEnd = "" 3332 3333 markup = "<b>%s%02d:%02d [%02d:%02d]%s</b>" % \ 3334 (markupBegin, 3335 realTime.tm_hour, realTime.tm_min, 3336 scheduledTime.hour, scheduledTime.minute, 3337 markupEnd) 3338 3339 # print "mlx.gui.flight.FinishPage._formatTime: markup='%s', diff=%d" % \ 3340 # (markup, diff) 3341 3342 return (markup, diff>15) 3205 3343 3206 3344 #----------------------------------------------------------------------------- … … 3563 3701 """Handle the login result.""" 3564 3702 self.gui.endBusy() 3703 returned = True 3704 result.pilotID = "P096" 3705 result.password = "V5fwj" 3706 result.loggedIn = True 3707 result.flights = [] 3565 3708 isReload = self._loginResult is not None 3566 3709 if returned: … … 3634 3777 self._takeoffPage.setRTOEnabled(rtoEnabled) 3635 3778 3779 def commentsChanged(self): 3780 """Called when the comments have changed.""" 3781 self.updateRTO() 3782 self._finishPage.updateButtons() 3783 3784 def delayCodesChanged(self): 3785 """Called when the delay codes have changed.""" 3786 self._finishPage.updateButtons() 3787 3636 3788 def rtoToggled(self, indicated): 3637 3789 """Called when the RTO indication has changed.""" -
src/mlx/gui/gui.py
r501 r555 403 403 return self._flightInfo.delayCodes 404 404 405 @property 406 def hasDelayCode(self): 407 """Determine if there is at least one delay code selected.""" 408 return self._flightInfo.hasDelayCode 409 405 410 def run(self): 406 411 """Run the GUI.""" … … 782 787 else: 783 788 callback(self._fleet) 789 790 def commentsChanged(self): 791 """Indicate that the comments have changed.""" 792 self._wizard.commentsChanged() 793 794 def delayCodesChanged(self): 795 """Called when the delay codes have changed.""" 796 self._wizard.delayCodesChanged() 784 797 785 798 def updateRTO(self, inLoop = False): … … 1133 1146 else: 1134 1147 self._mainWindow.set_default(None) 1148 1149 def isWizardActive(self): 1150 """Determine if the flight wizard is active.""" 1151 return self._notebook.get_current_page()==0 1135 1152 1136 1153 def _editChecklist(self, menuItem): -
src/mlx/gui/info.py
r441 r555 82 82 padding_left = 8, padding_right = 8) 83 83 84 self._delayCodeTable = table = DelayCodeTable( )84 self._delayCodeTable = table = DelayCodeTable(self) 85 85 self._delayWindow = scrolledWindow = gtk.ScrolledWindow() 86 86 scrolledWindow.add(table) … … 124 124 return self._delayCodeTable.delayCodes 125 125 126 @property 127 def hasDelayCode(self): 128 """Determine if there is at least one delay code selected.""" 129 return self._delayCodeTable.hasDelayCode 130 126 131 def enable(self, aircraftType): 127 132 """Enable the flight info tab.""" … … 145 150 self._delayCodeTable.reset() 146 151 152 def delayCodesChanged(self): 153 """Callewd when the delay codes have changed.""" 154 self._gui.delayCodesChanged() 155 147 156 def _commentsChanged(self, textbuffer): 148 157 """Called when the comments have changed.""" 149 self._gui. updateRTO(inLoop = True)158 self._gui.commentsChanged()
Note:
See TracChangeset
for help on using the changeset viewer.