Changeset 64:1764c7271057 for src/mlx
- Timestamp:
- 04/07/12 12:59:00 (13 years ago)
- Branch:
- default
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/mlx/gui/flight.py
r62 r64 858 858 self._wizard._cruiseAltitude = self._cruiseLevel.get_value_as_int() * 100 859 859 self._wizard._route = self._getRoute() 860 861 bookedFlight = self._wizard._bookedFlight 862 self._wizard.gui.beginBusy("Downloading NOTAMs...") 863 self._wizard.gui.webHandler.getNOTAMs(self._notamsCallback, 864 bookedFlight.departureICAO, 865 bookedFlight.arrivalICAO) 866 867 def _notamsCallback(self, returned, result): 868 """Callback for the NOTAMs.""" 869 gobject.idle_add(self._handleNOTAMs, returned, result) 870 871 def _handleNOTAMs(self, returned, result): 872 """Handle the NOTAMs.""" 873 self._wizard.gui.endBusy() 874 if returned: 875 self._wizard._departureNOTAMs = result.departureNOTAMs 876 self._wizard._arrivalNOTAMs = result.arrivalNOTAMs 877 860 878 self._wizard.nextPage() 879 880 #----------------------------------------------------------------------------- 881 882 class NOTAMPage(Page): 883 """Page for the NOTAMs.""" 884 def __init__(self, wizard): 885 help = "Read carefully the NOTAMs below." 886 887 super(NOTAMPage, self).__init__(wizard, "NOTAMs", help) 888 889 alignment = gtk.Alignment(xalign = 0.5, yalign = 0.5, 890 xscale = 1.0, yscale = 1.0) 891 892 mainBox = gtk.VBox() 893 alignment.add(mainBox) 894 self.setMainWidget(alignment) 895 896 self._departureNOTAMsFrame = gtk.Frame() 897 self._departureNOTAMsFrame.set_label("LHBP NOTAMs") 898 scrolledWindow = gtk.ScrolledWindow() 899 scrolledWindow.set_size_request(-1, 80) 900 self._departureNOTAMs = gtk.TextView() 901 self._departureNOTAMs.set_wrap_mode(gtk.WrapMode.WORD if pygobject else 902 gtk.WRAP_WORD) 903 scrolledWindow.add(self._departureNOTAMs) 904 self._departureNOTAMsFrame.add(scrolledWindow) 905 mainBox.pack_start(self._departureNOTAMsFrame, True, True, 4) 906 907 self._arrivalNOTAMsFrame = gtk.Frame() 908 self._arrivalNOTAMsFrame.set_label("LIRF NOTAMs") 909 scrolledWindow = gtk.ScrolledWindow() 910 scrolledWindow.set_size_request(-1, 80) 911 self._arrivalNOTAMs = gtk.TextView() 912 self._arrivalNOTAMs.set_wrap_mode(gtk.WrapMode.WORD if pygobject else 913 gtk.WRAP_WORD) 914 scrolledWindow.add(self._arrivalNOTAMs) 915 self._arrivalNOTAMsFrame.add(scrolledWindow) 916 mainBox.pack_start(self._arrivalNOTAMsFrame, True, True, 4) 917 918 # metarBox = gtk.HBox() 919 920 # departureMETARFrame = gtk.Frame() 921 # departureMETARFrame.set_label("LHBP METAR") 922 # scrolledWindow = gtk.ScrolledWindow() 923 # self._departureMETAR = gtk.TextView() 924 # scrolledWindow.add(self._departureMETAR) 925 # departureMETARFrame.add(scrolledWindow) 926 # metarBox.pack_start(departureMETARFrame, True, True, 4) 927 928 # arrivalMETARFrame = gtk.Frame() 929 # arrivalMETARFrame.set_label("EPWA METAR") 930 # scrolledWindow = gtk.ScrolledWindow() 931 # self._arrivalMETAR = gtk.TextView() 932 # scrolledWindow.add(self._arrivalMETAR) 933 # arrivalMETARFrame.add(scrolledWindow) 934 # metarBox.pack_start(arrivalMETARFrame, True, True, 4) 935 936 # mainBox.pack_start(metarBox, True, True, 4) 937 938 self._button = self.addButton(gtk.STOCK_GO_FORWARD, default = True) 939 self._button.set_use_stock(True) 940 self._button.connect("clicked", self._forwardClicked) 941 942 def activate(self): 943 """Activate the page.""" 944 bookedFlight = self._wizard._bookedFlight 945 self._setupNOTAMs(self._departureNOTAMsFrame, self._departureNOTAMs, 946 bookedFlight.departureICAO, self._wizard._departureNOTAMs) 947 self._setupNOTAMs(self._arrivalNOTAMsFrame, self._arrivalNOTAMs, 948 bookedFlight.arrivalICAO, self._wizard._arrivalNOTAMs) 949 950 def _setupNOTAMs(self, frame, textView, icao, notams): 951 """Setup the NOTAMs.""" 952 frame.set_label(icao + " NOTAMs") 953 buffer = textView.get_buffer() 954 if notams is None: 955 buffer.set_text("Could not download NOTAMs") 956 else: 957 s = "" 958 for notam in notams: 959 s += str(notam.begin) 960 if notam.end is not None: 961 s += " - " + str(notam.end) 962 elif notam.permanent: 963 s += " - PERMANENT" 964 s += "\n" 965 if notam.repeatCycle: 966 s += "Repeat cycle: " + notam.repeatCycle + "\n" 967 s += notam.notice + "\n" 968 s += "-------------------- * --------------------\n" 969 buffer.set_text(s) 970 971 972 def _forwardClicked(self): 973 """Called when the forward button is clicked.""" 861 974 862 975 #----------------------------------------------------------------------------- … … 880 993 self._pages.append(TimePage(self)) 881 994 self._pages.append(RoutePage(self)) 995 self._pages.append(NOTAMPage(self)) 882 996 883 997 maxWidth = 0 … … 950 1064 self._cruiseAltitude = None 951 1065 self._route = None 1066 self._departureNOTAMs = None 1067 self._arrivalNOTAMs = None 952 1068 953 1069 self.setCurrentPage(0)
Note:
See TracChangeset
for help on using the changeset viewer.