Changeset 36:f79362793664 for src/mlx
- Timestamp:
- 03/04/12 06:27:05 (13 years ago)
- Branch:
- default
- Phase:
- public
- Location:
- src/mlx
- Files:
-
- 3 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
src/mlx/const.py
r34 r36 4 4 5 5 # The version of the program 6 VERSION="0.00 3"6 VERSION="0.004" 7 7 8 8 #------------------------------------------------------------------------------- -
src/mlx/gui/gui.py
r35 r36 3 3 from statusicon import StatusIcon 4 4 from statusbar import Statusbar 5 from update import Updater 5 6 from mlx.gui.common import * 6 7 … … 31 32 class GUI(fs.ConnectionListener): 32 33 """The main GUI class.""" 33 def __init__(self ):34 def __init__(self, programDirectory, config): 34 35 """Construct the GUI.""" 35 36 gobject.threads_init() 36 37 38 self._programDirectory = programDirectory 39 self._config = config 37 40 self._connecting = False 38 41 self._connected = False … … 40 43 self._flight = None 41 44 self._simulator = None 45 self._stdioAfterNewLine = True 42 46 43 47 def build(self, iconDirectory): 44 48 """Build the GUI.""" 45 49 46 win = gtk.Window()47 win .set_title("MAVA Logger X " + const.VERSION)48 win .set_icon_from_file("logo.ico")49 win .connect("delete-event",50 lambda a, b: self.hideMainWindow())51 win .connect("window-state-event", self._handleMainWindowState)50 window = gtk.Window() 51 window.set_title("MAVA Logger X " + const.VERSION) 52 window.set_icon_from_file(os.path.join(iconDirectory, "logo.ico")) 53 window.connect("delete-event", 54 lambda a, b: self.hideMainWindow()) 55 window.connect("window-state-event", self._handleMainWindowState) 52 56 53 57 mainVBox = gtk.VBox() 54 win .add(mainVBox)58 window.add(mainVBox) 55 59 56 60 setupFrame = self._buildSetupFrame() … … 71 75 mainVBox.pack_start(self._statusbar, False, False, 0) 72 76 73 win .show_all()74 75 self._mainWindow = win 77 window.show_all() 78 79 self._mainWindow = window 76 80 77 81 self._statusIcon = StatusIcon(iconDirectory, self) … … 79 83 def run(self): 80 84 """Run the GUI.""" 85 if self._config.autoUpdate: 86 self._updater = Updater(self._programDirectory, 87 self._config.updateURL, 88 self._mainWindow) 89 self._updater.start() 90 81 91 gtk.main() 92 82 93 if self._flight is not None: 83 94 simulator = self._flight.simulator … … 173 184 else: 174 185 self.showMainWindow() 186 187 def writeStdIO(self, text): 188 """Write the given text into standard I/O log.""" 189 gobject.idle_add(self._writeStdIO, text) 190 191 def _writeStdIO(self, text): 192 """Perform the real writing.""" 193 lines = text.splitlines() 194 if text[-1]=="\n": 195 text = "" 196 else: 197 text = lines[-1] 198 lines = lines[:-1] 199 200 for line in lines: 201 if self._stdioAfterNewLine: 202 line = "[STDIO] " + line 203 self._writeLog(line + "\n") 204 self._stdioAfterNewLine = True 205 206 if text: 207 if self._stdioAfterNewLine: 208 text = "[STDIO] " + text 209 self._writeLog(text) 210 self._stdioAfterNewLine = False 175 211 176 212 def _connectToggled(self, button): -
src/mlx/mlx.py
r29 r36 2 2 3 3 from .gui.gui import GUI 4 from .gui.common import * 4 5 from config import Config 5 6 6 7 import os 8 import sys 7 9 8 def main(iconDirectory): 10 #-------------------------------------------------------------------------------------- 11 12 class StdIOHandler(object): 13 """Handler for the standard I/O messages.""" 14 def __init__(self, gui): 15 """Construct the handler.""" 16 self._gui = gui 17 18 def write(self, text): 19 """Write the given text into the log.""" 20 self._gui.writeStdIO(text) 21 22 #-------------------------------------------------------------------------------------- 23 24 def main(): 9 25 """The main operation of the program.""" 10 gui = GUI()26 programDirectory = os.path.dirname(sys.argv[0]) 11 27 12 gui.build(iconDirectory) 28 config = Config() 29 gui = GUI(programDirectory, config) 30 31 sys.stdout = StdIOHandler(gui) 32 sys.stderr = StdIOHandler(gui) 33 34 gui.build(programDirectory) 13 35 14 36 gui.run() 15 37 38 #-------------------------------------------------------------------------------------- 39 16 40 if __name__ == "__main__": 17 main(os.path.dirname(__file__)) 18 19 41 main()
Note:
See TracChangeset
for help on using the changeset viewer.