Ignore:
Timestamp:
07/04/19 17:57:45 (5 years ago)
Author:
István Váradi <ivaradi@…>
Branch:
python3
hg-Phase:
(<MercurialRepository 1 'hg:/home/ivaradi/mlx/hg' '/'>, 'public')
Message:

Using 'Gtk' instead of 'gtk' (re #347)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/mlx/gui/pirep.py

    r994 r996  
    2626#------------------------------------------------------------------------------
    2727
    28 class MessageFrame(gtk.Frame):
     28class MessageFrame(Gtk.Frame):
    2929    """A frame containing the information about a PIREP message.
    3030
     
    3333    def __init__(self, message, senderPID, senderName):
    3434        """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()
    4040        heading.set_editable(False)
    4141        heading.set_can_focus(False)
     
    4949                         buffer.get_start_iter(), buffer.get_end_iter())
    5050
    51         headingAlignment = gtk.Alignment(xalign = 0.0, yalign = 0.0,
     51        headingAlignment = Gtk.Alignment(xalign = 0.0, yalign = 0.0,
    5252                                         xscale = 1.0, yscale = 0.0)
    5353        headingAlignment.set_padding(padding_top = 0, padding_bottom = 0,
     
    5656        vbox.pack_start(headingAlignment, True, True, 4)
    5757
    58         self._messageView = messageView = gtk.TextView()
     58        self._messageView = messageView = Gtk.TextView()
    5959        messageView.set_wrap_mode(WRAP_WORD)
    6060        messageView.set_editable(False)
     
    7272
    7373        styleContext = self.get_style_context()
    74         color = styleContext.get_background_color(gtk.StateFlags.NORMAL)
     74        color = styleContext.get_background_color(Gtk.StateFlags.NORMAL)
    7575        heading.override_background_color(0, color)
    7676
     
    7878#-------------------------------------------------------------------------------
    7979
    80 class MessagesWidget(gtk.Frame):
     80class MessagesWidget(Gtk.Frame):
    8181    """The widget for the messages."""
    8282    @staticmethod
     
    8686
    8787    def __init__(self, gui):
    88         gtk.Frame.__init__(self)
     88        Gtk.Frame.__init__(self)
    8989
    9090        self._gui = gui
     
    9393        label.set_use_underline(True)
    9494
    95         alignment = gtk.Alignment(xalign = 0.5, yalign = 0.5,
     95        alignment = Gtk.Alignment(xalign = 0.5, yalign = 0.5,
    9696                                  xscale = 1.0, yscale = 1.0)
    9797        alignment.set_padding(padding_top = 4, padding_bottom = 4,
    9898                              padding_left = 4, padding_right = 4)
    9999
    100         self._outerBox = outerBox = gtk.EventBox()
     100        self._outerBox = outerBox = Gtk.EventBox()
    101101        outerBox.add(alignment)
    102102
    103         self._innerBox = innerBox = gtk.EventBox()
     103        self._innerBox = innerBox = Gtk.EventBox()
    104104        alignment.add(self._innerBox)
    105105
    106         alignment = gtk.Alignment(xalign = 0.5, yalign = 0.5,
     106        alignment = Gtk.Alignment(xalign = 0.5, yalign = 0.5,
    107107                                  xscale = 1.0, yscale = 1.0)
    108108        alignment.set_padding(padding_top = 0, padding_bottom = 0,
     
    111111        innerBox.add(alignment)
    112112
    113         scroller = gtk.ScrolledWindow()
     113        scroller = Gtk.ScrolledWindow()
    114114        scroller.set_policy(POLICY_AUTOMATIC, POLICY_AUTOMATIC)
    115115        scroller.set_shadow_type(SHADOW_NONE)
    116116
    117         self._messages = gtk.VBox()
     117        self._messages = Gtk.VBox()
    118118        self._messages.set_homogeneous(False)
    119119        scroller.add_with_viewport(self._messages)
     
    129129        """Add a message from the given sender."""
    130130
    131         alignment = gtk.Alignment(xalign = 0.0, yalign = 0.0,
     131        alignment = Gtk.Alignment(xalign = 0.0, yalign = 0.0,
    132132                                      xscale = 1.0, yscale = 0.0)
    133133        alignment.set_padding(padding_top = 2, padding_bottom = 2,
     
    154154#------------------------------------------------------------------------------
    155155
    156 class PIREPViewer(gtk.Dialog):
     156class PIREPViewer(Gtk.Dialog):
    157157    """The dialog for PIREP viewing."""
    158158    @staticmethod
     
    167167        - the frame,
    168168        - 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,
    172172                                  xscale = 1.0, yscale = 1.0)
    173173        frame.add(alignment)
    174174        alignment.set_padding(padding_top = 4, padding_bottom = 4,
    175175                              padding_left = 4, padding_right = 4)
    176         box = gtk.VBox()
     176        box = Gtk.VBox()
    177177        alignment.add(box)
    178178
     
    182182    def getLabel(text, extraText = ""):
    183183        """Get a bold label with the given text."""
    184         label = gtk.Label("<b>" + text + "</b>" + extraText)
     184        label = Gtk.Label("<b>" + text + "</b>" + extraText)
    185185        label.set_use_markup(True)
    186186        label.set_alignment(0.0, 0.5)
     
    190190    def getDataLabel(width = None, xAlignment = 0.0):
    191191        """Get a bold label with the given text."""
    192         label = gtk.Label()
     192        label = Gtk.Label()
    193193        if width is not None:
    194194            label.set_width_chars(width)
     
    203203        - the window,
    204204        - the text view."""
    205         scrolledWindow = gtk.ScrolledWindow()
     205        scrolledWindow = Gtk.ScrolledWindow()
    206206        scrolledWindow.set_shadow_type(SHADOW_IN)
    207207        scrolledWindow.set_policy(POLICY_AUTOMATIC, POLICY_AUTOMATIC)
    208208
    209         textView = gtk.TextView()
     209        textView = Gtk.TextView()
    210210        textView.set_wrap_mode(WRAP_WORD)
    211211        textView.set_editable(editable)
     
    226226
    227227        Returns the data label attached."""
    228         dataBox = gtk.HBox()
     228        dataBox = Gtk.HBox()
    229229        table.attach(dataBox, column, column+1, row, row+1)
    230230
     
    251251    def addHFiller(hBox, width = 8):
    252252        """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,
    254254                               xscale = 1.0, yscale = 1.0)
    255255        filler.set_size_request(width, -1)
     
    259259    def addVFiller(vBox, height = 4):
    260260        """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,
    262262                               xscale = 1.0, yscale = 1.0)
    263263        filler.set_size_request(-1, height)
     
    284284        contentArea = self.get_content_area()
    285285
    286         self._notebook = gtk.Notebook()
     286        self._notebook = Gtk.Notebook()
    287287        contentArea.pack_start(self._notebook, False, False, 4)
    288288
    289289        dataTab = self._buildDataTab()
    290         label = gtk.Label(xstr("pirepView_tab_data"))
     290        label = Gtk.Label(xstr("pirepView_tab_data"))
    291291        label.set_use_underline(True)
    292292        label.set_tooltip_text(xstr("pirepView_tab_data_tooltip"))
     
    294294
    295295        commentsTab = self._buildCommentsTab()
    296         label = gtk.Label(xstr("pirepView_tab_comments"))
     296        label = Gtk.Label(xstr("pirepView_tab_comments"))
    297297        label.set_use_underline(True)
    298298        label.set_tooltip_text(xstr("pirepView_tab_comments_tooltip"))
     
    300300
    301301        logTab = self._buildLogTab()
    302         label = gtk.Label(xstr("pirepView_tab_log"))
     302        label = Gtk.Label(xstr("pirepView_tab_log"))
    303303        label.set_use_underline(True)
    304304        label.set_tooltip_text(xstr("pirepView_tab_log_tooltip"))
     
    308308        if showMessages:
    309309            messagesTab = self._buildMessagesTab()
    310             label = gtk.Label(xstr("pirepView_tab_messages"))
     310            label = Gtk.Label(xstr("pirepView_tab_messages"))
    311311            label.set_use_underline(True)
    312312            label.set_tooltip_text(xstr("pirepView_tab_messages_tooltip"))
     
    417417    def _buildDataTab(self):
    418418        """Build the data tab of the viewer."""
    419         table = gtk.Table(1, 2)
     419        table = Gtk.Table(1, 2)
    420420        table.set_row_spacings(4)
    421421        table.set_col_spacings(16)
    422422        table.set_homogeneous(True)
    423423
    424         box1 = gtk.VBox()
     424        box1 = Gtk.VBox()
    425425        table.attach(box1, 0, 1, 0, 1)
    426426
    427         box2 = gtk.VBox()
     427        box2 = Gtk.VBox()
    428428        table.attach(box2, 1, 2, 0, 1)
    429429
     
    453453        (frame, mainBox) = PIREPViewer.createFrame(xstr("pirepView_frame_flight"))
    454454
    455         dataBox = gtk.HBox()
     455        dataBox = Gtk.HBox()
    456456        mainBox.pack_start(dataBox, False, False, 0)
    457457
     
    468468        PIREPViewer.addVFiller(mainBox)
    469469
    470         dataBox = gtk.HBox()
     470        dataBox = Gtk.HBox()
    471471        mainBox.pack_start(dataBox, False, False, 0)
    472472
     
    478478        PIREPViewer.addVFiller(mainBox)
    479479
    480         table = gtk.Table(3, 2)
     480        table = Gtk.Table(3, 2)
    481481        mainBox.pack_start(table, False, False, 0)
    482482        table.set_row_spacings(4)
     
    503503                                    width = 6)
    504504
    505         table = gtk.Table(3, 2)
     505        table = Gtk.Table(3, 2)
    506506        mainBox.pack_start(table, False, False, 0)
    507507        table.set_row_spacings(4)
     
    549549        (frame, mainBox) = PIREPViewer.createFrame(xstr("pirepView_frame_route"))
    550550
    551         levelBox = gtk.HBox()
     551        levelBox = Gtk.HBox()
    552552        mainBox.pack_start(levelBox, False, False, 0)
    553553
     
    581581        PIREPViewer.addVFiller(mainBox)
    582582
    583         dataBox = gtk.HBox()
     583        dataBox = Gtk.HBox()
    584584        mainBox.pack_start(dataBox, False, False, 0)
    585585
     
    608608        PIREPViewer.addVFiller(mainBox)
    609609
    610         table = gtk.Table(2, 2)
     610        table = Gtk.Table(2, 2)
    611611        mainBox.pack_start(table, False, False, 0)
    612612        table.set_row_spacings(4)
     
    639639        (frame, mainBox) = PIREPViewer.createFrame(xstr("pirepView_frame_statistics"))
    640640
    641         table = gtk.Table(4, 2)
     641        table = Gtk.Table(4, 2)
    642642        mainBox.pack_start(table, False, False, 0)
    643643        table.set_row_spacings(4)
     
    685685        (frame, mainBox) = PIREPViewer.createFrame(xstr("pirepView_frame_miscellaneous"))
    686686
    687         table = gtk.Table(3, 2)
     687        table = Gtk.Table(3, 2)
    688688        mainBox.pack_start(table, False, False, 0)
    689689        table.set_row_spacings(4)
     
    737737    def _buildCommentsTab(self):
    738738        """Build the tab with the comments and flight defects."""
    739         table = gtk.Table(2, 1)
     739        table = Gtk.Table(2, 1)
    740740        table.set_col_spacings(16)
    741741
     
    760760    def _buildLogTab(self):
    761761        """Build the log tab."""
    762         mainBox = gtk.VBox()
     762        mainBox = Gtk.VBox()
    763763
    764764        (logWindow, self._log) = PIREPViewer.getTextWindow(heightRequest = -1)
     
    770770    def _buildMessagesTab(self):
    771771        """Build the messages tab."""
    772         mainBox = gtk.VBox()
     772        mainBox = Gtk.VBox()
    773773
    774774        self._messages = MessagesWidget(self._gui)
     
    779779#------------------------------------------------------------------------------
    780780
    781 class PIREPEditor(gtk.Dialog):
     781class PIREPEditor(Gtk.Dialog):
    782782    """A PIREP editor dialog."""
    783783    _delayCodeRE = re.compile("([0-9]{2,3})( \([^\)]*\))")
     
    789789        The label will got to cell (column, row), the widget to cell
    790790        (column+1, row)."""
    791         label = gtk.Label("<b>" + labelText + "</b>")
     791        label = Gtk.Label("<b>" + labelText + "</b>")
    792792        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,
    794794                                  xscale = 0.0, yscale = 0.0)
    795795        alignment.add(label)
     
    807807        The label will got to cell (column, row), the spin button to cell
    808808        (column+1, row)."""
    809         button = gtk.SpinButton()
     809        button = Gtk.SpinButton()
    810810        button.set_range(min = minValue, max = maxValue)
    811811        button.set_increments(step = stepIncrement, page = pageIncrement)
     
    847847        contentArea = self.get_content_area()
    848848
    849         self._notebook = gtk.Notebook()
     849        self._notebook = Gtk.Notebook()
    850850        contentArea.pack_start(self._notebook, False, False, 4)
    851851
    852852        dataTab = self._buildDataTab()
    853         label = gtk.Label(xstr("pirepView_tab_data"))
     853        label = Gtk.Label(xstr("pirepView_tab_data"))
    854854        label.set_use_underline(True)
    855855        label.set_tooltip_text(xstr("pirepView_tab_data_tooltip"))
     
    857857
    858858        self._flightInfo = self._buildCommentsTab()
    859         label = gtk.Label(xstr("pirepView_tab_comments"))
     859        label = Gtk.Label(xstr("pirepView_tab_comments"))
    860860        label.set_use_underline(True)
    861861        label.set_tooltip_text(xstr("pirepView_tab_comments_tooltip"))
     
    863863
    864864        logTab = self._buildLogTab()
    865         label = gtk.Label(xstr("pirepView_tab_log"))
     865        label = Gtk.Label(xstr("pirepView_tab_log"))
    866866        label.set_use_underline(True)
    867867        label.set_tooltip_text(xstr("pirepView_tab_log_tooltip"))
     
    10141014    def _buildDataTab(self):
    10151015        """Build the data tab of the viewer."""
    1016         table = gtk.Table(1, 2)
     1016        table = Gtk.Table(1, 2)
    10171017        table.set_row_spacings(4)
    10181018        table.set_col_spacings(16)
    10191019        table.set_homogeneous(True)
    10201020
    1021         box1 = gtk.VBox()
     1021        box1 = Gtk.VBox()
    10221022        table.attach(box1, 0, 1, 0, 1)
    10231023
    1024         box2 = gtk.VBox()
     1024        box2 = Gtk.VBox()
    10251025        table.attach(box2, 1, 2, 0, 1)
    10261026
     
    10501050        (frame, mainBox) = PIREPViewer.createFrame(xstr("pirepView_frame_flight"))
    10511051
    1052         dataBox = gtk.HBox()
     1052        dataBox = Gtk.HBox()
    10531053        mainBox.pack_start(dataBox, False, False, 0)
    10541054
     
    10651065        PIREPViewer.addVFiller(mainBox)
    10661066
    1067         dataBox = gtk.HBox()
     1067        dataBox = Gtk.HBox()
    10681068        mainBox.pack_start(dataBox, False, False, 0)
    10691069
     
    10751075        PIREPViewer.addVFiller(mainBox)
    10761076
    1077         table = gtk.Table(3, 2)
     1077        table = Gtk.Table(3, 2)
    10781078        mainBox.pack_start(table, False, False, 0)
    10791079        table.set_row_spacings(4)
     
    11001100                                    width = 6)
    11011101
    1102         table = gtk.Table(3, 2)
     1102        table = Gtk.Table(3, 2)
    11031103        mainBox.pack_start(table, False, False, 0)
    11041104        table.set_row_spacings(4)
     
    11451145        (frame, mainBox) = PIREPViewer.createFrame(xstr("pirepView_frame_route"))
    11461146
    1147         levelBox = gtk.HBox()
     1147        levelBox = Gtk.HBox()
    11481148        mainBox.pack_start(levelBox, False, False, 0)
    11491149
     
    11521152        levelBox.pack_start(label, False, False, 0)
    11531153
    1154         self._filedCruiseLevel = gtk.SpinButton()
     1154        self._filedCruiseLevel = Gtk.SpinButton()
    11551155        self._filedCruiseLevel.set_increments(step = 10, page = 100)
    11561156        self._filedCruiseLevel.set_range(min = 0, max = 500)
     
    11671167        levelBox.pack_start(label, False, False, 0)
    11681168
    1169         self._modifiedCruiseLevel = gtk.SpinButton()
     1169        self._modifiedCruiseLevel = Gtk.SpinButton()
    11701170        self._modifiedCruiseLevel.set_increments(step = 10, page = 100)
    11711171        self._modifiedCruiseLevel.set_range(min = 0, max = 500)
     
    12011201        PIREPViewer.addVFiller(mainBox)
    12021202
    1203         dataBox = gtk.HBox()
     1203        dataBox = Gtk.HBox()
    12041204        mainBox.pack_start(dataBox, False, False, 0)
    12051205
    1206         label = gtk.Label("<b>" + xstr("pirepView_runway") + "</b>")
     1206        label = Gtk.Label("<b>" + xstr("pirepView_runway") + "</b>")
    12071207        label.set_use_markup(True)
    12081208        dataBox.pack_start(label, False, False, 0)
    12091209
    12101210        # FIXME: quite the same as the runway entry boxes in the wizard
    1211         self._departureRunway = gtk.Entry()
     1211        self._departureRunway = Gtk.Entry()
    12121212        self._departureRunway.set_width_chars(5)
    12131213        self._departureRunway.set_tooltip_text(xstr("takeoff_runway_tooltip"))
     
    12151215        dataBox.pack_start(self._departureRunway, False, False, 8)
    12161216
    1217         label = gtk.Label("<b>" + xstr("pirepView_sid") + "</b>")
     1217        label = Gtk.Label("<b>" + xstr("pirepView_sid") + "</b>")
    12181218        label.set_use_markup(True)
    12191219        dataBox.pack_start(label, False, False, 0)
     
    12211221        # FIXME: quite the same as the SID combo box in
    12221222        # 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)
    12241224
    12251225        self._sid.set_entry_text_column(0)
     
    12471247        PIREPViewer.addVFiller(mainBox)
    12481248
    1249         table = gtk.Table(2, 4)
     1249        table = Gtk.Table(2, 4)
    12501250        mainBox.pack_start(table, False, False, 0)
    12511251        table.set_row_spacings(4)
     
    12531253
    12541254        # 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)
    12561256
    12571257        self._star.set_entry_text_column(0)
     
    12651265
    12661266        # 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)
    12681268
    12691269        self._transition.set_entry_text_column(0)
     
    12781278
    12791279        # FIXME: quite the same as in the wizard
    1280         self._approachType = gtk.Entry()
     1280        self._approachType = Gtk.Entry()
    12811281        self._approachType.set_width_chars(10)
    12821282        self._approachType.set_tooltip_text(xstr("landing_approach_tooltip"))
     
    12881288
    12891289        # FIXME: quite the same as in the wizard
    1290         self._arrivalRunway = gtk.Entry()
     1290        self._arrivalRunway = Gtk.Entry()
    12911291        self._arrivalRunway.set_width_chars(10)
    12921292        self._arrivalRunway.set_tooltip_text(xstr("landing_runway_tooltip"))
     
    13031303        (frame, mainBox) = PIREPViewer.createFrame(xstr("pirepView_frame_statistics"))
    13041304
    1305         table = gtk.Table(4, 4)
     1305        table = Gtk.Table(4, 4)
    13061306        mainBox.pack_start(table, False, False, 0)
    13071307        table.set_row_spacings(4)
     
    13551355        (frame, mainBox) = PIREPViewer.createFrame(xstr("pirepView_frame_miscellaneous"))
    13561356
    1357         table = gtk.Table(6, 2)
     1357        table = Gtk.Table(6, 2)
    13581358        mainBox.pack_start(table, False, False, 0)
    13591359        table.set_row_spacings(4)
     
    14031403        self._flightType.set_tooltip_text(xstr("pirepEdit_flight_type_tooltip"))
    14041404
    1405         self._online = gtk.CheckButton(xstr("pirepEdit_online"))
     1405        self._online = Gtk.CheckButton(xstr("pirepEdit_online"))
    14061406        table.attach(self._online, 2, 3, 2, 3)
    14071407        self._online.connect("toggled", self._updateButtons)
     
    14251425    def _buildLogTab(self):
    14261426        """Build the log tab."""
    1427         mainBox = gtk.VBox()
     1427        mainBox = Gtk.VBox()
    14281428
    14291429        (logWindow, self._log) = PIREPViewer.getTextWindow(heightRequest = -1)
Note: See TracChangeset for help on using the changeset viewer.