Changeset 46:43e46847479a


Ignore:
Timestamp:
03/18/12 19:18:36 (12 years ago)
Author:
István Váradi <locvais@…>
Branch:
default
Phase:
public
Message:

Some further enhancements on the GUI

Location:
src/mlx/gui
Files:
2 edited

Legend:

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

    r45 r46  
    1717        self.add(frame)
    1818
    19         print self.get_style()
    2019        style = self.get_style() if pygobject else self.rc_get_style()
    2120
     
    5655
    5756        self._buttonBox = gtk.HButtonBox()
     57        self._defaultButton = None
    5858        buttonAlignment.add(self._buttonBox)
    5959
     
    6666        self._mainAlignment.add(widget)
    6767
    68     def addButton(self, label):
     68    def addButton(self, label, default = False):
    6969        """Add a button with the given label.
    7070
     
    7272        button = gtk.Button(label)
    7373        self._buttonBox.add(button)
     74        if default:
     75            button.set_can_default(True)
     76            self._defaultButton = button
    7477        return button
    7578
     79    def grabDefault(self):
     80        """If the page has a default button, make it the default one."""
     81        if self._defaultButton is not None:
     82            self._defaultButton.grab_default()
     83   
    7684#-----------------------------------------------------------------------------
    7785
     
    128136        table.attach(self._rememberButton, 1, 2, 2, 3, ypadding = 8)
    129137
    130         self._loginButton = self.addButton("_Login")
     138        self._loginButton = self.addButton("_Login", default = True)
    131139        self._loginButton.set_sensitive(False)
    132140        self._loginButton.set_use_underline(True)
     
    232240        """Go to the next page."""
    233241        self.setCurrentPage(self._currentPage + 1)
     242
     243    def grabDefault(self):
     244        """Make the default button of the current page the default."""
     245        self._pages[self._currentPage].grabDefault()
    234246   
    235247#-----------------------------------------------------------------------------
  • src/mlx/gui/gui.py

    r42 r46  
    7373        mainVBox.add(notebook)
    7474
    75         notebook.append_page(Wizard(self), gtk.Label("Flight"))
     75        self._wizard = Wizard(self)
     76        label = gtk.Label("_Flight")
     77        label.set_use_underline(True)
     78        label.set_tooltip_text("Flight wizard")
     79        notebook.append_page(self._wizard, label)
    7680
    7781        dataVBox = gtk.VBox()
    78         notebook.append_page(dataVBox, gtk.Label("Data"))
     82        label = gtk.Label("_Data")
     83        label.set_use_underline(True)
     84        label.set_tooltip_text("FSUIPC data access")
     85        notebook.append_page(dataVBox, label)
    7986
    8087        setupFrame = self._buildSetupFrame()
     
    8794
    8895        logVBox = gtk.VBox()
    89         notebook.append_page(logVBox, gtk.Label("Log"))
     96        label = gtk.Label("_Log")
     97        label.set_use_underline(True)
     98        label.set_tooltip_text("Flight log")
     99        notebook.append_page(logVBox, label)
    90100       
    91101        logFrame = self._buildLogFrame()
     
    98108        mainVBox.pack_start(self._statusbar, False, False, 0)
    99109
    100         window.show_all()       
     110        notebook.connect("switch-page", self._notebookPageSwitch)
     111
     112        window.show_all()
     113        self._wizard.grabDefault()
    101114
    102115        self._mainWindow = window
     
    374387        setupBox.pack_start(gtk.VSeparator(), False, False, 8)   
    375388
    376         self._quitButton = gtk.Button(label = "Quit")
     389        self._quitButton = gtk.Button(label = "_Quit", use_underline = True)
     390        self._quitButton.set_can_default(True)
    377391        self._quitButton.set_tooltip_text("Quit the program.")
    378392       
     
    707721        return gtk.main_quit()
    708722
     723    def _notebookPageSwitch(self, notebook, page, page_num):
     724        """Called when the current page of the notebook has changed."""
     725        if page_num==0:
     726            self._wizard.grabDefault()
     727        elif page_num==1:
     728            self._quitButton.grab_default()
     729        else:
     730            self._mainWindow.set_default(None)
     731
    709732class TrackerStatusIcon(gtk.StatusIcon):
    710733        def __init__(self):
Note: See TracChangeset for help on using the changeset viewer.