Changeset 62:b9bf44d0c527 for src/mlx
- Timestamp:
- 04/07/12 11:42:11 (13 years ago)
- Branch:
- default
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/mlx/gui/flight.py
r61 r62 273 273 gtk.PolicyType.ALWAYS if pygobject 274 274 else gtk.POLICY_ALWAYS) 275 scrolledWindow.set_shadow_type(gtk.ShadowType.IN if pygobject 276 else gtk.SHADOW_IN) 275 277 276 278 alignment = gtk.Alignment(xalign = 0.5, yalign = 0.0, xscale = 0.0, yscale = 1.0) … … 369 371 gtk.PolicyType.ALWAYS if pygobject 370 372 else gtk.POLICY_ALWAYS) 373 scrolledWindow.set_shadow_type(gtk.ShadowType.IN if pygobject 374 else gtk.SHADOW_IN) 371 375 372 376 alignment = gtk.Alignment(xalign = 0.5, yalign = 0.0, xscale = 0.0, yscale = 1.0) … … 759 763 #----------------------------------------------------------------------------- 760 764 765 class RoutePage(Page): 766 """The page containing the route and the flight level.""" 767 def __init__(self, wizard): 768 help = "Set your cruise flight level below, and\n" \ 769 "if necessary, edit the flight plan." 770 771 super(RoutePage, self).__init__(wizard, "Route", help) 772 773 alignment = gtk.Alignment(xalign = 0.5, yalign = 0.5, 774 xscale = 0.0, yscale = 0.0) 775 776 mainBox = gtk.VBox() 777 alignment.add(mainBox) 778 self.setMainWidget(alignment) 779 780 levelBox = gtk.HBox() 781 782 label = gtk.Label("_Cruise level") 783 label.set_use_underline(True) 784 levelBox.pack_start(label, True, True, 0) 785 786 self._cruiseLevel = gtk.SpinButton() 787 self._cruiseLevel.set_increments(step = 10, page = 100) 788 self._cruiseLevel.set_range(min = 50, max = 500) 789 self._cruiseLevel.set_value(240) 790 self._cruiseLevel.set_tooltip_text("The cruise flight level.") 791 self._cruiseLevel.set_numeric(True) 792 self._cruiseLevel.connect("value-changed", self._cruiseLevelChanged) 793 label.set_mnemonic_widget(self._cruiseLevel) 794 795 levelBox.pack_start(self._cruiseLevel, False, False, 8) 796 797 alignment = gtk.Alignment(xalign = 0.0, yalign = 0.5, 798 xscale = 0.0, yscale = 0.0) 799 alignment.add(levelBox) 800 801 mainBox.pack_start(alignment, False, False, 0) 802 803 804 routeBox = gtk.VBox() 805 806 alignment = gtk.Alignment(xalign = 0.0, yalign = 0.5, 807 xscale = 0.0, yscale = 0.0) 808 label = gtk.Label("_Route") 809 label.set_use_underline(True) 810 alignment.add(label) 811 routeBox.pack_start(alignment, True, True, 0) 812 813 routeWindow = gtk.ScrolledWindow() 814 routeWindow.set_size_request(400, 80) 815 routeWindow.set_shadow_type(gtk.ShadowType.IN if pygobject 816 else gtk.SHADOW_IN) 817 818 self._route = gtk.TextView() 819 self._route.set_tooltip_text("The planned flight route.") 820 self._route.get_buffer().connect("changed", self._routeChanged) 821 routeWindow.add(self._route) 822 823 label.set_mnemonic_widget(self._route) 824 routeBox.pack_start(routeWindow, True, True, 0) 825 826 mainBox.pack_start(routeBox, True, True, 8) 827 828 self._button = self.addButton(gtk.STOCK_GO_FORWARD, default = True) 829 self._button.set_use_stock(True) 830 self._button.connect("clicked", self._forwardClicked) 831 832 def activate(self): 833 """Setup the route from the booked flight.""" 834 self._route.get_buffer().set_text(self._wizard._bookedFlight.route) 835 self._updateForwardButton() 836 837 def _getRoute(self): 838 """Get the text of the route.""" 839 buffer = self._route.get_buffer() 840 return buffer.get_text(buffer.get_start_iter(), 841 buffer.get_end_iter(), True) 842 843 def _updateForwardButton(self): 844 """Update the sensitivity of the forward button.""" 845 self._button.set_sensitive(self._cruiseLevel.get_value_as_int()>=50 and \ 846 self._getRoute()) 847 848 def _cruiseLevelChanged(self, spinButton): 849 """Called when the cruise level has changed.""" 850 self._updateForwardButton() 851 852 def _routeChanged(self, textBuffer): 853 """Called when the route has changed.""" 854 self._updateForwardButton() 855 856 def _forwardClicked(self, button): 857 """Called when the Forward button is clicked.""" 858 self._wizard._cruiseAltitude = self._cruiseLevel.get_value_as_int() * 100 859 self._wizard._route = self._getRoute() 860 self._wizard.nextPage() 861 862 #----------------------------------------------------------------------------- 863 761 864 class Wizard(gtk.VBox): 762 865 """The flight wizard.""" … … 776 879 self._pages.append(PayloadPage(self)) 777 880 self._pages.append(TimePage(self)) 881 self._pages.append(RoutePage(self)) 778 882 779 883 maxWidth = 0 … … 844 948 self._departureGate = "-" 845 949 self._zfw = None 846 950 self._cruiseAltitude = None 951 self._route = None 952 847 953 self.setCurrentPage(0) 848 954
Note:
See TracChangeset
for help on using the changeset viewer.