Changeset 44:5d48f6c9f140 for src/mlx


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

The basics of the basic framework for the flight wizard work

Location:
src/mlx/gui
Files:
2 edited

Legend:

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

    r42 r44  
    1212    import gtk
    1313    import gobject
     14    import pango
    1415    try:
    1516        import appindicator
     
    2728    from gi.repository import GObject as gobject
    2829    from gi.repository import AppIndicator3 as appindicator
     30    from gi.repository import Pango as pango
    2931    appIndicator = True
    3032
  • src/mlx/gui/flight.py

    r43 r44  
    55#-----------------------------------------------------------------------------
    66
    7 class Page(gtk.VBox):
     7class Page(gtk.Alignment):
    88    """A page in the flight wizard."""
    9     def __init__(self, wizard):
     9    def __init__(self, wizard, title, help):
    1010        """Construct the page."""
    11         super(Page, self).__init__()
     11        super(Page, self).__init__(xalign = 0.0, yalign = 0.0,
     12                                   xscale = 1.0, yscale = 1.0)
     13        self.set_padding(padding_top = 4, padding_bottom = 4,
     14                         padding_left = 12, padding_right = 12)
     15
     16        frame = gtk.Frame()
     17        self.add(frame)
     18
     19        print self.get_style()
     20        style = self.get_style() if pygobject else self.rc_get_style()
     21
     22        self._vbox = gtk.VBox()
     23        frame.add(self._vbox)
     24
     25        eventBox = gtk.EventBox()
     26        eventBox.modify_bg(0, style.bg[3])
     27
     28        alignment = gtk.Alignment(xalign = 0.0, xscale = 0.0)
     29       
     30        label = gtk.Label(title)
     31        label.modify_fg(0, style.fg[3])
     32        label.modify_font(pango.FontDescription("bold 24"))
     33        alignment.set_padding(padding_top = 4, padding_bottom = 4,
     34                              padding_left = 6, padding_right = 0)
     35                             
     36        alignment.add(label)
     37        eventBox.add(alignment)
     38       
     39        self._vbox.pack_start(eventBox, False, False, 0)
     40
     41        alignment = gtk.Alignment(xalign = 0.5, yalign = 0.5,
     42                                  xscale = 0, yscale = 0.3)
     43        label = gtk.Label(help)
     44        label.set_justify(gtk.Justification.CENTER if pygobject
     45                          else gtk.JUSTIFY_CENTER)
     46        alignment.add(label)
     47        self._vbox.pack_start(alignment, True, True, 0)
     48
     49        self._mainAlignment = gtk.Alignment(xalign = 0.5, yalign = 0.5,
     50                                            xscale = 0, yscale = 0.0)
     51        self._vbox.pack_start(self._mainAlignment, True, True, 0)
     52
     53        buttonAlignment =  gtk.Alignment(xalign = 1.0, xscale=0.0)
     54        buttonAlignment.set_padding(padding_top = 4, padding_bottom = 10,
     55                                    padding_left = 16, padding_right = 16)
     56
     57        self._buttonBox = gtk.HButtonBox()
     58        buttonAlignment.add(self._buttonBox)
     59
     60        self._vbox.pack_start(buttonAlignment, False, False, 0)
     61
    1262        self._wizard = wizard
     63
     64    def setMainWidget(self, widget):
     65        """Set the given widget as the main one."""
     66        self._mainAlignment.add(widget)
     67
     68    def addButton(self, label):
     69        """Add a button with the given label.
     70
     71        Return the button object created."""
     72        button = gtk.Button(label)
     73        self._buttonBox.add(button)
     74        return button
    1375
    1476#-----------------------------------------------------------------------------
     
    1880    def __init__(self, wizard):
    1981        """Construct the login page."""
    20         super(LoginPage, self).__init__(wizard)
    21 
    22         alignment = gtk.Alignment(xalign = 0.5, yalign = 0.5,
    23                                   xscale = 0, yscale = 0.3)
    24         label = gtk.Label("Enter your pilot's ID and password to\n"
    25                           "log in to the MAVA website and download\n"
    26                           "your booked flights")
    27         label.set_justify(gtk.Justification.CENTER if pygobject
    28                           else gtk.JUSTIFY_CENTER)
    29         alignment.add(label)
    30         self.pack_start(alignment, True, True, 0)
    31 
    32         alignment = gtk.Alignment(xalign = 0.5, yalign = 0.5,
    33                                   xscale = 0, yscale = 0.0)
     82        help = "Enter your MAVA pilot's ID and password to\n" \
     83        "log in to the MAVA website and download\n" \
     84        "your booked flights."
     85        super(LoginPage, self).__init__(wizard, "Login", help)
    3486
    3587        table = gtk.Table(2, 2)
    3688        table.set_row_spacings(4)
    3789        table.set_col_spacings(32)
    38         alignment.add(table)
     90        self.setMainWidget(table)
    3991
    4092        labelAlignment = gtk.Alignment(xalign=1.0, xscale=0.0)
     
    55107        table.attach(self._password, 1, 2, 1, 2)
    56108
    57         self.pack_start(alignment, True, True, 0)
    58 
    59         alignment = gtk.Alignment(xalign = 1.0, xscale=0.0)
    60         alignment.set_padding(padding_top = 4, padding_bottom = 10,
    61                               padding_left = 16, padding_right = 16)
    62        
    63         self._loginButton = gtk.Button("Login")
     109        self._loginButton = self.addButton("Login")
    64110        self._loginButton.set_sensitive(False)
    65111        self._loginButton.connect("clicked", self._loginClicked)
    66112       
    67         alignment.add(self._loginButton)
    68         self.pack_start(alignment, False, False, 0)
    69 
    70113        config = self._wizard.gui.config
    71114        self._pilotID.set_text(config.pilotID)
     
    123166    def __init__(self, wizard):
    124167        """Construct the flight selection page."""
    125         super(FlightSelectionPage, self).__init__(wizard)
    126         self.pack_start(gtk.Label("Hello, te lo!"), False, False, 0)
     168        super(FlightSelectionPage, self).__init__(wizard, "Flight selection",
     169                                                  "Hello, te lo!")
    127170
    128171#-----------------------------------------------------------------------------
Note: See TracChangeset for help on using the changeset viewer.