Ignore:
Timestamp:
04/21/12 11:13:29 (12 years ago)
Author:
István Váradi <ivaradi@…>
Branch:
default
Phase:
public
Message:

The contents of log lines can be modified after they are written, and we are using it for Vref

File:
1 edited

Legend:

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

    r93 r96  
    2424class GUI(fs.ConnectionListener):
    2525    """The main GUI class."""
     26    @staticmethod
     27    def _formatFlightLogLine(timeStr, line):
     28        """Format the given line for flight logging."""
     29        if timeStr is not None:
     30            line = timeStr + ": " + line
     31        return line + "\n"
     32       
    2633    def __init__(self, programDirectory, config):
    2734        """Construct the GUI."""
     
    3340        self._reconnecting = False
    3441        self._connected = False
    35         self._logger = logger.Logger(output = self)
     42        self._logger = logger.Logger(self)
    3643        self._flight = None
    3744        self._simulator = None
     
    272279        self._statusbar.updateConnection(False, False)
    273280           
    274     def write(self, msg):
    275         """Write the given message to the log."""
    276         gobject.idle_add(self._writeLog, msg, self._logView)
    277        
     281    def addFlightLogLine(self, timeStr, line):
     282        """Write the given message line to the log."""
     283        gobject.idle_add(self._writeLog,
     284                         GUI._formatFlightLogLine(timeStr, line),
     285                         self._logView)
     286
     287    def updateFlightLogLine(self, index, timeStr, line):
     288        """Update the line with the given index."""
     289        gobject.idle_add(self._updateFlightLogLine, index,
     290                         GUI._formatFlightLogLine(timeStr, line))
     291
     292    def _updateFlightLogLine(self, index, line):
     293        """Replace the contents of the given line in the log."""
     294        buffer = self._logView.get_buffer()
     295        startIter = buffer.get_iter_at_line(index)
     296        endIter = buffer.get_iter_at_line(index + 1)
     297        buffer.delete(startIter, endIter)
     298        buffer.insert(startIter, line)
     299        self._logView.scroll_mark_onscreen(buffer.get_insert())
     300
    278301    def check(self, flight, aircraft, logger, oldState, state):
    279302        """Update the data."""
     
    428451           
    429452        for line in lines:
    430             print >> sys.__stdout__, line
     453            #print >> sys.__stdout__, line
    431454            self._writeLog(line + "\n", self._debugLogView)
    432455
    433456        if text:
    434             print >> sys.__stdout__, line,
     457            #print >> sys.__stdout__, text,
    435458            self._writeLog(text, self._debugLogView)
    436459
Note: See TracChangeset for help on using the changeset viewer.