Changeset 996:8035d80d5feb for src/mlx/gui/pirep.py
- Timestamp:
- 07/04/19 17:57:45 (5 years ago)
- Branch:
- python3
- hg-Phase:
- (<MercurialRepository 1 'hg:/home/ivaradi/mlx/hg' '/'>, 'public')
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/mlx/gui/pirep.py
r994 r996 26 26 #------------------------------------------------------------------------------ 27 27 28 class MessageFrame( gtk.Frame):28 class MessageFrame(Gtk.Frame): 29 29 """A frame containing the information about a PIREP message. 30 30 … … 33 33 def __init__(self, message, senderPID, senderName): 34 34 """Construct the frame.""" 35 gtk.Frame.__init__(self)36 37 vbox = gtk.VBox()38 39 self._heading = heading = gtk.TextView()35 Gtk.Frame.__init__(self) 36 37 vbox = Gtk.VBox() 38 39 self._heading = heading = Gtk.TextView() 40 40 heading.set_editable(False) 41 41 heading.set_can_focus(False) … … 49 49 buffer.get_start_iter(), buffer.get_end_iter()) 50 50 51 headingAlignment = gtk.Alignment(xalign = 0.0, yalign = 0.0,51 headingAlignment = Gtk.Alignment(xalign = 0.0, yalign = 0.0, 52 52 xscale = 1.0, yscale = 0.0) 53 53 headingAlignment.set_padding(padding_top = 0, padding_bottom = 0, … … 56 56 vbox.pack_start(headingAlignment, True, True, 4) 57 57 58 self._messageView = messageView = gtk.TextView()58 self._messageView = messageView = Gtk.TextView() 59 59 messageView.set_wrap_mode(WRAP_WORD) 60 60 messageView.set_editable(False) … … 72 72 73 73 styleContext = self.get_style_context() 74 color = styleContext.get_background_color( gtk.StateFlags.NORMAL)74 color = styleContext.get_background_color(Gtk.StateFlags.NORMAL) 75 75 heading.override_background_color(0, color) 76 76 … … 78 78 #------------------------------------------------------------------------------- 79 79 80 class MessagesWidget( gtk.Frame):80 class MessagesWidget(Gtk.Frame): 81 81 """The widget for the messages.""" 82 82 @staticmethod … … 86 86 87 87 def __init__(self, gui): 88 gtk.Frame.__init__(self)88 Gtk.Frame.__init__(self) 89 89 90 90 self._gui = gui … … 93 93 label.set_use_underline(True) 94 94 95 alignment = gtk.Alignment(xalign = 0.5, yalign = 0.5,95 alignment = Gtk.Alignment(xalign = 0.5, yalign = 0.5, 96 96 xscale = 1.0, yscale = 1.0) 97 97 alignment.set_padding(padding_top = 4, padding_bottom = 4, 98 98 padding_left = 4, padding_right = 4) 99 99 100 self._outerBox = outerBox = gtk.EventBox()100 self._outerBox = outerBox = Gtk.EventBox() 101 101 outerBox.add(alignment) 102 102 103 self._innerBox = innerBox = gtk.EventBox()103 self._innerBox = innerBox = Gtk.EventBox() 104 104 alignment.add(self._innerBox) 105 105 106 alignment = gtk.Alignment(xalign = 0.5, yalign = 0.5,106 alignment = Gtk.Alignment(xalign = 0.5, yalign = 0.5, 107 107 xscale = 1.0, yscale = 1.0) 108 108 alignment.set_padding(padding_top = 0, padding_bottom = 0, … … 111 111 innerBox.add(alignment) 112 112 113 scroller = gtk.ScrolledWindow()113 scroller = Gtk.ScrolledWindow() 114 114 scroller.set_policy(POLICY_AUTOMATIC, POLICY_AUTOMATIC) 115 115 scroller.set_shadow_type(SHADOW_NONE) 116 116 117 self._messages = gtk.VBox()117 self._messages = Gtk.VBox() 118 118 self._messages.set_homogeneous(False) 119 119 scroller.add_with_viewport(self._messages) … … 129 129 """Add a message from the given sender.""" 130 130 131 alignment = gtk.Alignment(xalign = 0.0, yalign = 0.0,131 alignment = Gtk.Alignment(xalign = 0.0, yalign = 0.0, 132 132 xscale = 1.0, yscale = 0.0) 133 133 alignment.set_padding(padding_top = 2, padding_bottom = 2, … … 154 154 #------------------------------------------------------------------------------ 155 155 156 class PIREPViewer( gtk.Dialog):156 class PIREPViewer(Gtk.Dialog): 157 157 """The dialog for PIREP viewing.""" 158 158 @staticmethod … … 167 167 - the frame, 168 168 - the inner VBox.""" 169 frame = gtk.Frame(label = label)170 171 alignment = gtk.Alignment(xalign = 0.0, yalign = 0.0,169 frame = Gtk.Frame(label = label) 170 171 alignment = Gtk.Alignment(xalign = 0.0, yalign = 0.0, 172 172 xscale = 1.0, yscale = 1.0) 173 173 frame.add(alignment) 174 174 alignment.set_padding(padding_top = 4, padding_bottom = 4, 175 175 padding_left = 4, padding_right = 4) 176 box = gtk.VBox()176 box = Gtk.VBox() 177 177 alignment.add(box) 178 178 … … 182 182 def getLabel(text, extraText = ""): 183 183 """Get a bold label with the given text.""" 184 label = gtk.Label("<b>" + text + "</b>" + extraText)184 label = Gtk.Label("<b>" + text + "</b>" + extraText) 185 185 label.set_use_markup(True) 186 186 label.set_alignment(0.0, 0.5) … … 190 190 def getDataLabel(width = None, xAlignment = 0.0): 191 191 """Get a bold label with the given text.""" 192 label = gtk.Label()192 label = Gtk.Label() 193 193 if width is not None: 194 194 label.set_width_chars(width) … … 203 203 - the window, 204 204 - the text view.""" 205 scrolledWindow = gtk.ScrolledWindow()205 scrolledWindow = Gtk.ScrolledWindow() 206 206 scrolledWindow.set_shadow_type(SHADOW_IN) 207 207 scrolledWindow.set_policy(POLICY_AUTOMATIC, POLICY_AUTOMATIC) 208 208 209 textView = gtk.TextView()209 textView = Gtk.TextView() 210 210 textView.set_wrap_mode(WRAP_WORD) 211 211 textView.set_editable(editable) … … 226 226 227 227 Returns the data label attached.""" 228 dataBox = gtk.HBox()228 dataBox = Gtk.HBox() 229 229 table.attach(dataBox, column, column+1, row, row+1) 230 230 … … 251 251 def addHFiller(hBox, width = 8): 252 252 """Add a filler to the given horizontal box.""" 253 filler = gtk.Alignment(xalign = 0.0, yalign = 0.0,253 filler = Gtk.Alignment(xalign = 0.0, yalign = 0.0, 254 254 xscale = 1.0, yscale = 1.0) 255 255 filler.set_size_request(width, -1) … … 259 259 def addVFiller(vBox, height = 4): 260 260 """Add a filler to the given vertical box.""" 261 filler = gtk.Alignment(xalign = 0.0, yalign = 0.0,261 filler = Gtk.Alignment(xalign = 0.0, yalign = 0.0, 262 262 xscale = 1.0, yscale = 1.0) 263 263 filler.set_size_request(-1, height) … … 284 284 contentArea = self.get_content_area() 285 285 286 self._notebook = gtk.Notebook()286 self._notebook = Gtk.Notebook() 287 287 contentArea.pack_start(self._notebook, False, False, 4) 288 288 289 289 dataTab = self._buildDataTab() 290 label = gtk.Label(xstr("pirepView_tab_data"))290 label = Gtk.Label(xstr("pirepView_tab_data")) 291 291 label.set_use_underline(True) 292 292 label.set_tooltip_text(xstr("pirepView_tab_data_tooltip")) … … 294 294 295 295 commentsTab = self._buildCommentsTab() 296 label = gtk.Label(xstr("pirepView_tab_comments"))296 label = Gtk.Label(xstr("pirepView_tab_comments")) 297 297 label.set_use_underline(True) 298 298 label.set_tooltip_text(xstr("pirepView_tab_comments_tooltip")) … … 300 300 301 301 logTab = self._buildLogTab() 302 label = gtk.Label(xstr("pirepView_tab_log"))302 label = Gtk.Label(xstr("pirepView_tab_log")) 303 303 label.set_use_underline(True) 304 304 label.set_tooltip_text(xstr("pirepView_tab_log_tooltip")) … … 308 308 if showMessages: 309 309 messagesTab = self._buildMessagesTab() 310 label = gtk.Label(xstr("pirepView_tab_messages"))310 label = Gtk.Label(xstr("pirepView_tab_messages")) 311 311 label.set_use_underline(True) 312 312 label.set_tooltip_text(xstr("pirepView_tab_messages_tooltip")) … … 417 417 def _buildDataTab(self): 418 418 """Build the data tab of the viewer.""" 419 table = gtk.Table(1, 2)419 table = Gtk.Table(1, 2) 420 420 table.set_row_spacings(4) 421 421 table.set_col_spacings(16) 422 422 table.set_homogeneous(True) 423 423 424 box1 = gtk.VBox()424 box1 = Gtk.VBox() 425 425 table.attach(box1, 0, 1, 0, 1) 426 426 427 box2 = gtk.VBox()427 box2 = Gtk.VBox() 428 428 table.attach(box2, 1, 2, 0, 1) 429 429 … … 453 453 (frame, mainBox) = PIREPViewer.createFrame(xstr("pirepView_frame_flight")) 454 454 455 dataBox = gtk.HBox()455 dataBox = Gtk.HBox() 456 456 mainBox.pack_start(dataBox, False, False, 0) 457 457 … … 468 468 PIREPViewer.addVFiller(mainBox) 469 469 470 dataBox = gtk.HBox()470 dataBox = Gtk.HBox() 471 471 mainBox.pack_start(dataBox, False, False, 0) 472 472 … … 478 478 PIREPViewer.addVFiller(mainBox) 479 479 480 table = gtk.Table(3, 2)480 table = Gtk.Table(3, 2) 481 481 mainBox.pack_start(table, False, False, 0) 482 482 table.set_row_spacings(4) … … 503 503 width = 6) 504 504 505 table = gtk.Table(3, 2)505 table = Gtk.Table(3, 2) 506 506 mainBox.pack_start(table, False, False, 0) 507 507 table.set_row_spacings(4) … … 549 549 (frame, mainBox) = PIREPViewer.createFrame(xstr("pirepView_frame_route")) 550 550 551 levelBox = gtk.HBox()551 levelBox = Gtk.HBox() 552 552 mainBox.pack_start(levelBox, False, False, 0) 553 553 … … 581 581 PIREPViewer.addVFiller(mainBox) 582 582 583 dataBox = gtk.HBox()583 dataBox = Gtk.HBox() 584 584 mainBox.pack_start(dataBox, False, False, 0) 585 585 … … 608 608 PIREPViewer.addVFiller(mainBox) 609 609 610 table = gtk.Table(2, 2)610 table = Gtk.Table(2, 2) 611 611 mainBox.pack_start(table, False, False, 0) 612 612 table.set_row_spacings(4) … … 639 639 (frame, mainBox) = PIREPViewer.createFrame(xstr("pirepView_frame_statistics")) 640 640 641 table = gtk.Table(4, 2)641 table = Gtk.Table(4, 2) 642 642 mainBox.pack_start(table, False, False, 0) 643 643 table.set_row_spacings(4) … … 685 685 (frame, mainBox) = PIREPViewer.createFrame(xstr("pirepView_frame_miscellaneous")) 686 686 687 table = gtk.Table(3, 2)687 table = Gtk.Table(3, 2) 688 688 mainBox.pack_start(table, False, False, 0) 689 689 table.set_row_spacings(4) … … 737 737 def _buildCommentsTab(self): 738 738 """Build the tab with the comments and flight defects.""" 739 table = gtk.Table(2, 1)739 table = Gtk.Table(2, 1) 740 740 table.set_col_spacings(16) 741 741 … … 760 760 def _buildLogTab(self): 761 761 """Build the log tab.""" 762 mainBox = gtk.VBox()762 mainBox = Gtk.VBox() 763 763 764 764 (logWindow, self._log) = PIREPViewer.getTextWindow(heightRequest = -1) … … 770 770 def _buildMessagesTab(self): 771 771 """Build the messages tab.""" 772 mainBox = gtk.VBox()772 mainBox = Gtk.VBox() 773 773 774 774 self._messages = MessagesWidget(self._gui) … … 779 779 #------------------------------------------------------------------------------ 780 780 781 class PIREPEditor( gtk.Dialog):781 class PIREPEditor(Gtk.Dialog): 782 782 """A PIREP editor dialog.""" 783 783 _delayCodeRE = re.compile("([0-9]{2,3})( \([^\)]*\))") … … 789 789 The label will got to cell (column, row), the widget to cell 790 790 (column+1, row).""" 791 label = gtk.Label("<b>" + labelText + "</b>")791 label = Gtk.Label("<b>" + labelText + "</b>") 792 792 label.set_use_markup(True) 793 alignment = gtk.Alignment(xalign = 0.0, yalign = 0.5,793 alignment = Gtk.Alignment(xalign = 0.0, yalign = 0.5, 794 794 xscale = 0.0, yscale = 0.0) 795 795 alignment.add(label) … … 807 807 The label will got to cell (column, row), the spin button to cell 808 808 (column+1, row).""" 809 button = gtk.SpinButton()809 button = Gtk.SpinButton() 810 810 button.set_range(min = minValue, max = maxValue) 811 811 button.set_increments(step = stepIncrement, page = pageIncrement) … … 847 847 contentArea = self.get_content_area() 848 848 849 self._notebook = gtk.Notebook()849 self._notebook = Gtk.Notebook() 850 850 contentArea.pack_start(self._notebook, False, False, 4) 851 851 852 852 dataTab = self._buildDataTab() 853 label = gtk.Label(xstr("pirepView_tab_data"))853 label = Gtk.Label(xstr("pirepView_tab_data")) 854 854 label.set_use_underline(True) 855 855 label.set_tooltip_text(xstr("pirepView_tab_data_tooltip")) … … 857 857 858 858 self._flightInfo = self._buildCommentsTab() 859 label = gtk.Label(xstr("pirepView_tab_comments"))859 label = Gtk.Label(xstr("pirepView_tab_comments")) 860 860 label.set_use_underline(True) 861 861 label.set_tooltip_text(xstr("pirepView_tab_comments_tooltip")) … … 863 863 864 864 logTab = self._buildLogTab() 865 label = gtk.Label(xstr("pirepView_tab_log"))865 label = Gtk.Label(xstr("pirepView_tab_log")) 866 866 label.set_use_underline(True) 867 867 label.set_tooltip_text(xstr("pirepView_tab_log_tooltip")) … … 1014 1014 def _buildDataTab(self): 1015 1015 """Build the data tab of the viewer.""" 1016 table = gtk.Table(1, 2)1016 table = Gtk.Table(1, 2) 1017 1017 table.set_row_spacings(4) 1018 1018 table.set_col_spacings(16) 1019 1019 table.set_homogeneous(True) 1020 1020 1021 box1 = gtk.VBox()1021 box1 = Gtk.VBox() 1022 1022 table.attach(box1, 0, 1, 0, 1) 1023 1023 1024 box2 = gtk.VBox()1024 box2 = Gtk.VBox() 1025 1025 table.attach(box2, 1, 2, 0, 1) 1026 1026 … … 1050 1050 (frame, mainBox) = PIREPViewer.createFrame(xstr("pirepView_frame_flight")) 1051 1051 1052 dataBox = gtk.HBox()1052 dataBox = Gtk.HBox() 1053 1053 mainBox.pack_start(dataBox, False, False, 0) 1054 1054 … … 1065 1065 PIREPViewer.addVFiller(mainBox) 1066 1066 1067 dataBox = gtk.HBox()1067 dataBox = Gtk.HBox() 1068 1068 mainBox.pack_start(dataBox, False, False, 0) 1069 1069 … … 1075 1075 PIREPViewer.addVFiller(mainBox) 1076 1076 1077 table = gtk.Table(3, 2)1077 table = Gtk.Table(3, 2) 1078 1078 mainBox.pack_start(table, False, False, 0) 1079 1079 table.set_row_spacings(4) … … 1100 1100 width = 6) 1101 1101 1102 table = gtk.Table(3, 2)1102 table = Gtk.Table(3, 2) 1103 1103 mainBox.pack_start(table, False, False, 0) 1104 1104 table.set_row_spacings(4) … … 1145 1145 (frame, mainBox) = PIREPViewer.createFrame(xstr("pirepView_frame_route")) 1146 1146 1147 levelBox = gtk.HBox()1147 levelBox = Gtk.HBox() 1148 1148 mainBox.pack_start(levelBox, False, False, 0) 1149 1149 … … 1152 1152 levelBox.pack_start(label, False, False, 0) 1153 1153 1154 self._filedCruiseLevel = gtk.SpinButton()1154 self._filedCruiseLevel = Gtk.SpinButton() 1155 1155 self._filedCruiseLevel.set_increments(step = 10, page = 100) 1156 1156 self._filedCruiseLevel.set_range(min = 0, max = 500) … … 1167 1167 levelBox.pack_start(label, False, False, 0) 1168 1168 1169 self._modifiedCruiseLevel = gtk.SpinButton()1169 self._modifiedCruiseLevel = Gtk.SpinButton() 1170 1170 self._modifiedCruiseLevel.set_increments(step = 10, page = 100) 1171 1171 self._modifiedCruiseLevel.set_range(min = 0, max = 500) … … 1201 1201 PIREPViewer.addVFiller(mainBox) 1202 1202 1203 dataBox = gtk.HBox()1203 dataBox = Gtk.HBox() 1204 1204 mainBox.pack_start(dataBox, False, False, 0) 1205 1205 1206 label = gtk.Label("<b>" + xstr("pirepView_runway") + "</b>")1206 label = Gtk.Label("<b>" + xstr("pirepView_runway") + "</b>") 1207 1207 label.set_use_markup(True) 1208 1208 dataBox.pack_start(label, False, False, 0) 1209 1209 1210 1210 # FIXME: quite the same as the runway entry boxes in the wizard 1211 self._departureRunway = gtk.Entry()1211 self._departureRunway = Gtk.Entry() 1212 1212 self._departureRunway.set_width_chars(5) 1213 1213 self._departureRunway.set_tooltip_text(xstr("takeoff_runway_tooltip")) … … 1215 1215 dataBox.pack_start(self._departureRunway, False, False, 8) 1216 1216 1217 label = gtk.Label("<b>" + xstr("pirepView_sid") + "</b>")1217 label = Gtk.Label("<b>" + xstr("pirepView_sid") + "</b>") 1218 1218 label.set_use_markup(True) 1219 1219 dataBox.pack_start(label, False, False, 0) … … 1221 1221 # FIXME: quite the same as the SID combo box in 1222 1222 # the flight wizard 1223 self._sid = gtk.ComboBox.new_with_model_and_entry(comboModel)1223 self._sid = Gtk.ComboBox.new_with_model_and_entry(comboModel) 1224 1224 1225 1225 self._sid.set_entry_text_column(0) … … 1247 1247 PIREPViewer.addVFiller(mainBox) 1248 1248 1249 table = gtk.Table(2, 4)1249 table = Gtk.Table(2, 4) 1250 1250 mainBox.pack_start(table, False, False, 0) 1251 1251 table.set_row_spacings(4) … … 1253 1253 1254 1254 # FIXME: quite the same as in the wizard 1255 self._star = gtk.ComboBox.new_with_model_and_entry(comboModel)1255 self._star = Gtk.ComboBox.new_with_model_and_entry(comboModel) 1256 1256 1257 1257 self._star.set_entry_text_column(0) … … 1265 1265 1266 1266 # FIXME: quite the same as in the wizard 1267 self._transition = gtk.ComboBox.new_with_model_and_entry(comboModel)1267 self._transition = Gtk.ComboBox.new_with_model_and_entry(comboModel) 1268 1268 1269 1269 self._transition.set_entry_text_column(0) … … 1278 1278 1279 1279 # FIXME: quite the same as in the wizard 1280 self._approachType = gtk.Entry()1280 self._approachType = Gtk.Entry() 1281 1281 self._approachType.set_width_chars(10) 1282 1282 self._approachType.set_tooltip_text(xstr("landing_approach_tooltip")) … … 1288 1288 1289 1289 # FIXME: quite the same as in the wizard 1290 self._arrivalRunway = gtk.Entry()1290 self._arrivalRunway = Gtk.Entry() 1291 1291 self._arrivalRunway.set_width_chars(10) 1292 1292 self._arrivalRunway.set_tooltip_text(xstr("landing_runway_tooltip")) … … 1303 1303 (frame, mainBox) = PIREPViewer.createFrame(xstr("pirepView_frame_statistics")) 1304 1304 1305 table = gtk.Table(4, 4)1305 table = Gtk.Table(4, 4) 1306 1306 mainBox.pack_start(table, False, False, 0) 1307 1307 table.set_row_spacings(4) … … 1355 1355 (frame, mainBox) = PIREPViewer.createFrame(xstr("pirepView_frame_miscellaneous")) 1356 1356 1357 table = gtk.Table(6, 2)1357 table = Gtk.Table(6, 2) 1358 1358 mainBox.pack_start(table, False, False, 0) 1359 1359 table.set_row_spacings(4) … … 1403 1403 self._flightType.set_tooltip_text(xstr("pirepEdit_flight_type_tooltip")) 1404 1404 1405 self._online = gtk.CheckButton(xstr("pirepEdit_online"))1405 self._online = Gtk.CheckButton(xstr("pirepEdit_online")) 1406 1406 table.attach(self._online, 2, 3, 2, 3) 1407 1407 self._online.connect("toggled", self._updateButtons) … … 1425 1425 def _buildLogTab(self): 1426 1426 """Build the log tab.""" 1427 mainBox = gtk.VBox()1427 mainBox = Gtk.VBox() 1428 1428 1429 1429 (logWindow, self._log) = PIREPViewer.getTextWindow(heightRequest = -1)
Note:
See TracChangeset
for help on using the changeset viewer.