Changeset 29:5bcc0ef808c5 for src/mlx
- Timestamp:
- 02/25/12 13:40:17 (13 years ago)
- Branch:
- default
- Phase:
- public
- Location:
- src/mlx
- Files:
-
- 1 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
src/mlx/acft.py
r27 r29 481 481 This implementation checks the RPM values to be 0.""" 482 482 for rpm in aircraftState.rpm: 483 if rpm>0: return 484 self._setStage(aircraftState, const.STAGE_END)483 if rpm>0: return False 484 return True 485 485 486 486 def logFuel(self, aircraftState): -
src/mlx/flight.py
r27 r29 23 23 It is also the hub for the other main objects participating in the handling of 24 24 the flight.""" 25 def __init__(self, logger ):25 def __init__(self, logger, gui): 26 26 """Construct the flight.""" 27 27 self._stage = None 28 28 self.logger = logger 29 self._gui = gui 29 30 30 31 self.cruiseAltitude = None -
src/mlx/gui/common.py
r28 r29 9 9 pygobject = False 10 10 import pygtk 11 import gtk.gdk as gdk 11 12 import gtk 12 13 import gobject … … 19 20 print "Using PyGObject" 20 21 pygobject = True 22 from gi.repository import Gdk as gdk 21 23 from gi.repository import Gtk as gtk 22 24 from gi.repository import GObject as gobject -
src/mlx/gui/gui.py
r28 r29 1 1 # The main file for the GUI 2 2 3 from common import * 3 from statusicon import StatusIcon 4 from mlx.gui.common import * 4 5 5 6 import mlx.const as const … … 32 33 def __init__(self): 33 34 """Construct the GUI.""" 34 35 35 gobject.threads_init() 36 36 … … 41 41 self._simulator = None 42 42 43 def build(self ):43 def build(self, iconDirectory): 44 44 """Build the GUI.""" 45 45 46 win = gtk.Window() 46 47 win.set_title("MAVA Logger X " + const.VERSION) 47 48 win.set_icon_from_file("logo.ico") 48 win.connect("delete-event", gtk.main_quit) 49 win.connect("delete-event", lambda a, b: self.hideMainWindow()) 50 win.connect("window-state-event", self._handleMainWindowState) 49 51 50 52 mainVBox = gtk.VBox() … … 62 64 logFrame.set_border_width(8) 63 65 mainVBox.pack_start(logFrame, True, True, 0) 64 66 65 67 win.show_all() 68 69 self._mainWindow = win 70 71 self._statusIcon = StatusIcon(iconDirectory, self) 66 72 67 73 def run(self): … … 93 99 gobject.idle_add(self._setData, state) 94 100 101 def _handleMainWindowState(self, window, event): 102 """Hande a change in the state of the window""" 103 iconified = gdk.WindowState.ICONIFIED if pygobject \ 104 else gdk.WINDOW_STATE_ICONIFIED 105 if (event.changed_mask&iconified)!=0 and (event.new_window_state&iconified)!=0: 106 self.hideMainWindow() 107 108 def hideMainWindow(self): 109 """Hide the main window and save its position.""" 110 (self._mainWindowX, self._mainWindowY) = \ 111 self._mainWindow.get_window().get_root_origin() 112 self._mainWindow.hide() 113 self._statusIcon.mainWindowHidden() 114 return True 115 116 def showMainWindow(self): 117 """Show the main window at its former position.""" 118 self._mainWindow.move(self._mainWindowX, self._mainWindowY) 119 self._mainWindow.deiconify() 120 self._mainWindow.show() 121 self._statusIcon.mainWindowShown() 122 123 def toggleMainWindow(self): 124 """Toggle the main window.""" 125 if self._mainWindow.get_visible(): 126 self.hideMainWindow() 127 else: 128 self.showMainWindow() 129 95 130 def _drawConnState(self, connStateArea, eventOrContext): 96 131 """Draw the connection state.""" … … 254 289 255 290 setupBox.pack_start(alignment, False, False, 8) 291 292 setupBox.pack_start(gtk.VSeparator(), False, False, 8) 293 294 self._quitButton = gtk.Button(label = "Quit") 295 self._quitButton.set_tooltip_text("Quit the program.") 296 297 self._quitButton.connect("clicked", gtk.main_quit) 298 299 setupBox.pack_start(self._quitButton, False, False, 0) 256 300 257 301 return setupFrame -
src/mlx/mlx.py
r28 r29 2 2 3 3 from .gui.gui import GUI 4 from .gui.common import * 4 5 5 def main(): 6 import os 7 8 def main(iconDirectory): 6 9 """The main operation of the program.""" 7 # menu = gtk.Menu() 8 # item = gtk.MenuItem() 9 # item.set_label("Menu Item") 10 # item.show() 11 # menu.append(item) 10 gui = GUI() 12 11 13 # menu.show()12 gui.build(iconDirectory) 14 13 15 # if appIndicator:16 # if pygobject:17 # ind = appindicator.Indicator.new ("mava-logger-x",18 # "/home/vi/munka/repules/mlx/src/logo.ico",19 # #"indicator-messages",20 # appindicator.IndicatorCategory.APPLICATION_STATUS)21 # ind.set_status (appindicator.IndicatorStatus.ACTIVE)22 # else:23 # ind = appindicator.Indicator ("mava-logger-x",24 # "/home/vi/munka/repules/mlx/src/logo.ico",25 # appindicator.CATEGORY_APPLICATION_STATUS)26 # ind.set_status (appindicator.STATUS_ACTIVE)27 28 # ind.set_menu(menu)29 # #ind.set_icon("distributor-logo")30 # else:31 # def popup_menu(status, button, time):32 # menu.popup(None, None, gtk.status_icon_position_menu,33 # button, time, status)34 # statusIcon = gtk.StatusIcon()35 # #statusIcon.set_from_stock(gtk.STOCK_FIND)36 # statusIcon.set_from_file("logo.ico")37 # statusIcon.set_tooltip_markup("MAVA Logger X")38 # statusIcon.set_visible(True)39 # statusIcon.connect('popup-menu', popup_menu)40 41 gui = GUI()42 gui.build()43 14 gui.run() 44 15 45 16 if __name__ == "__main__": 46 main( )17 main(os.path.dirname(__file__)) 47 18 48 19
Note:
See TracChangeset
for help on using the changeset viewer.