Changeset 621:4f7dbaa010d1 for src/mlx
- Timestamp:
- 04/04/15 08:47:36 (10 years ago)
- Branch:
- default
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/mlx/gui/flight.py
r619 r621 50 50 #----------------------------------------------------------------------------- 51 51 52 comboModel = gtk.ListStore(gobject.TYPE_STRING) 53 comboModel.append(("N/A",)) 54 comboModel.append(("VECTORS",)) 55 56 #----------------------------------------------------------------------------- 57 52 58 class Page(gtk.Alignment): 53 59 """A page in the flight wizard.""" … … 2151 2157 table.attach(label, 0, 1, row, row+1) 2152 2158 2153 self._sid = gtk.Entry() 2154 self._sid.set_width_chars(10) 2159 if pygobject: 2160 self._sid = gtk.ComboBox.new_with_model_and_entry(comboModel) 2161 else: 2162 self._sid = gtk.ComboBoxEntry(comboModel) 2163 2164 self._sid.set_entry_text_column(0) 2165 self._sid.get_child().set_width_chars(10) 2155 2166 self._sid.set_tooltip_text(xstr("takeoff_sid_tooltip")) 2156 self._sid.connect("changed", self._upperChanged )2167 self._sid.connect("changed", self._upperChangedComboBox) 2157 2168 table.attach(self._sid, 1, 3, row, row+1) 2158 2169 label.set_mnemonic_widget(self._sid) … … 2263 2274 def sid(self): 2264 2275 """Get the SID.""" 2265 return self._sid.get_text() 2276 text = self._sid.get_child().get_text() 2277 return text if self._sid.get_active()!=0 and text and text!="N/A" \ 2278 else None 2266 2279 2267 2280 @property … … 2325 2338 self._runway.set_text("") 2326 2339 self._runway.set_sensitive(True) 2327 self._sid.set_ text("")2340 self._sid.set_active(0) 2328 2341 self._sid.set_sensitive(True) 2329 2342 self._v1.set_int(None) … … 2393 2406 def _updateForwardButton(self): 2394 2407 """Update the sensitivity of the forward button based on some conditions.""" 2395 2396 2408 sensitive = self._forwardAllowed and \ 2397 2409 self._metar.get_text()!="" and \ 2398 2410 self._runway.get_text()!="" and \ 2399 self. _sid.get_text()!=""and \2411 self.sid is not None and \ 2400 2412 self.v1 is not None and \ 2401 2413 self.vr is not None and \ … … 2422 2434 entry.set_text(entry.get_text().upper()) 2423 2435 self._valueChanged(entry, arg) 2436 2437 def _upperChangedComboBox(self, comboBox): 2438 """Called for combo box widgets that must be converted to uppercase.""" 2439 entry = comboBox.get_child() 2440 if comboBox.get_active()==-1: 2441 entry.set_text(entry.get_text().upper()) 2442 self._valueChanged(entry) 2424 2443 2425 2444 def _derateChanged(self, entry): … … 2709 2728 row += 1 2710 2729 2711 self._starButton = gtk.CheckButton()2712 self._starButton.connect("clicked", self._starButtonClicked)2713 table.attach(self._starButton, 0, 1, row, row + 1)2714 2715 2730 label = gtk.Label(xstr("landing_star")) 2716 2731 label.set_use_underline(True) … … 2718 2733 table.attach(label, 1, 2, row, row + 1) 2719 2734 2720 self._star = gtk.Entry() 2721 self._star.set_width_chars(10) 2735 if pygobject: 2736 self._star = gtk.ComboBox.new_with_model_and_entry(comboModel) 2737 else: 2738 self._star = gtk.ComboBoxEntry(comboModel) 2739 2740 self._star.set_entry_text_column(0) 2741 self._star.get_child().set_width_chars(10) 2722 2742 self._star.set_tooltip_text(xstr("landing_star_tooltip")) 2723 self._star.connect("changed", self._upperChanged )2743 self._star.connect("changed", self._upperChangedComboBox) 2724 2744 self._star.set_sensitive(False) 2725 2745 table.attach(self._star, 2, 4, row, row + 1) 2726 label.set_mnemonic_widget(self._star Button)2746 label.set_mnemonic_widget(self._star) 2727 2747 2728 2748 row += 1 2729 2730 self._transitionButton = gtk.CheckButton()2731 self._transitionButton.connect("clicked", self._transitionButtonClicked)2732 table.attach(self._transitionButton, 0, 1, row, row + 1)2733 2749 2734 2750 label = gtk.Label(xstr("landing_transition")) … … 2737 2753 table.attach(label, 1, 2, row, row + 1) 2738 2754 2739 self._transition = gtk.Entry() 2740 self._transition.set_width_chars(10) 2755 if pygobject: 2756 self._transition = gtk.ComboBox.new_with_model_and_entry(comboModel) 2757 else: 2758 self._transition = gtk.ComboBoxEntry(comboModel) 2759 2760 self._transition.set_entry_text_column(0) 2761 self._transition.get_child().set_width_chars(10) 2741 2762 self._transition.set_tooltip_text(xstr("landing_transition_tooltip")) 2742 self._transition.connect("changed", self._upperChanged )2763 self._transition.connect("changed", self._upperChangedComboBox) 2743 2764 self._transition.set_sensitive(False) 2744 2765 table.attach(self._transition, 2, 4, row, row + 1) 2745 label.set_mnemonic_widget(self._transition Button)2766 label.set_mnemonic_widget(self._transition) 2746 2767 2747 2768 row += 1 … … 2804 2825 self._button = self.addNextButton(clicked = self._forwardClicked) 2805 2826 2806 # These are needed for correct size calculations2807 self._starButton.set_active(True)2808 self._transitionButton.set_active(True)2809 2810 2827 self._active = False 2811 2828 … … 2813 2830 def star(self): 2814 2831 """Get the STAR or None if none entered.""" 2815 return self._star.get_text() if self._starButton.get_active() else None 2832 text = self._star.get_child().get_text() 2833 return text if self._star.get_active()!=0 and text and text!="N/A" \ 2834 else None 2816 2835 2817 2836 @property 2818 2837 def transition(self): 2819 2838 """Get the transition or None if none entered.""" 2820 return self._transition.get_text() \ 2821 if self._transitionButton.get_active() else None 2839 text = self._transition.get_child().get_text() 2840 return text if self._transition.get_active()!=0 and text and text!="N/A" \ 2841 else None 2822 2842 2823 2843 @property … … 2860 2880 self._updatingMETAR = False 2861 2881 2862 self._starButton.set_sensitive(True) 2863 self._starButton.set_active(False) 2864 self._star.set_text("") 2865 2866 self._transitionButton.set_sensitive(True) 2867 self._transitionButton.set_active(False) 2868 self._transition.set_text("") 2882 self._star.set_active(0) 2883 self._star.set_sensitive(True) 2884 2885 self._transition.set_active(0) 2886 self._transition.set_sensitive(True) 2869 2887 2870 2888 self._runway.set_text("") … … 2905 2923 self._updateForwardButton() 2906 2924 2907 def _starButtonClicked(self, button):2908 """Called when the STAR button is clicked."""2909 active = button.get_active()2910 self._star.set_sensitive(active)2911 if active:2912 self._star.grab_focus()2913 self._updateForwardButton()2914 2915 def _transitionButtonClicked(self, button):2916 """Called when the Transition button is clicked."""2917 active = button.get_active()2918 self._transition.set_sensitive(active)2919 if active:2920 self._transition.grab_focus()2921 self._updateForwardButton()2922 2923 2925 def _updateForwardButton(self): 2924 2926 """Update the sensitivity of the forward button.""" 2927 self._flightEnded = True 2925 2928 sensitive = self._flightEnded and \ 2926 2929 self._metar.get_text()!="" and \ 2927 (self._starButton.get_active() or \ 2928 self._transitionButton.get_active()) and \ 2929 (self._star.get_text()!="" or 2930 not self._starButton.get_active()) and \ 2931 (self._transition.get_text()!="" or 2932 not self._transitionButton.get_active()) and \ 2930 (self.star is not None or 2931 self.transition is not None) and \ 2933 2932 self._runway.get_text()!="" and \ 2934 2933 self._approachType.get_text()!="" and \ … … 2939 2938 """Called for entry widgets that must be converted to uppercase.""" 2940 2939 entry.set_text(entry.get_text().upper()) 2940 self._updateForwardButton() 2941 2942 def _upperChangedComboBox(self, comboBox): 2943 """Called for combo box widgets that must be converted to uppercase.""" 2944 if comboBox.get_active()==-1: 2945 entry = comboBox.get_child() 2946 entry.set_text(entry.get_text().upper()) 2941 2947 self._updateForwardButton() 2942 2948 … … 3883 3889 3884 3890 self.setCurrentPage(firstPage) 3885 #self.setCurrentPage(1 3)3891 #self.setCurrentPage(10) 3886 3892 3887 3893 def login(self, callback, pilotID, password, entranceExam):
Note:
See TracChangeset
for help on using the changeset viewer.