Beispiel #1
0
    def __init__(self, *args):
        """
        Descript. :
        """
        BlissWidget.__init__(self, *args)

        # Hardware objects ----------------------------------------------------

        # Internal values -----------------------------------------------------
        self.max_log_lines = -1

        # Properties ----------------------------------------------------------
        self.addProperty('maxLogLines', 'integer', -1)

        # Signals -------------------------------------------------------------

        # Slots ---------------------------------------------------------------

        # Graphic elements ----------------------------------------------------
        self._status_bar_widget = LogBarWidget(self)

        # Layout --------------------------------------------------------------
        _main_hlayout = QHBoxLayout(self)
        _main_hlayout.addWidget(self._status_bar_widget)
        _main_hlayout.setSpacing(0)
        _main_hlayout.setContentsMargins(2, 2, 2, 2)

        # SizePolicies --------------------------------------------------------
        self.setSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.Fixed)

        # Qt signal/slot connections ------------------------------------------

        # Other ---------------------------------------------------------------
        Qt4_GUILogHandler.GUILogHandler().register(self)
Beispiel #2
0
class Qt4_LogBarBrick(BlissWidget):
    """
    Descript. :
    """
    COLORS = {logging.NOTSET: 'lightgrey', logging.DEBUG: 'darkgreen', 
              logging.INFO: 'darkblue', logging.WARNING: 'orange', 
              logging.ERROR: 'red', logging.CRITICAL: 'black' }

    def __init__(self, *args):
        """
        Descript. :
        """
        BlissWidget.__init__(self, *args)

        #self.setObjectName("log_bar_brick") 

        # Layout
        self._status_bar_widget = LogBarWidget(self)
        _main_hlayout = QtGui.QHBoxLayout(self)
        _main_hlayout.addWidget(self._status_bar_widget)
        _main_hlayout.setSpacing(0)
        _main_hlayout.setContentsMargins(0, 0, 0, 0)
        self.setLayout(_main_hlayout)

        self.setSizePolicy(QtGui.QSizePolicy.MinimumExpanding, 
                           QtGui.QSizePolicy.Fixed)

        Qt4_GUILogHandler.GUILogHandler().register(self)
        #logger = logging.getLogger("user_level_log")
        #logger.info('Ready')

    def customEvent(self, event):
        """
        Descript. :
        """
        if self.isRunning():
            self.append_log_record(event.record)

    def append_log_record(self, record):
        """
        Descript. :
        """
        if record.name == 'user_level_log':
            msg = record.getMessage()#.replace('\n',' ').strip()
            level = record.getLevel()
            color = Qt4_LogBarBrick.COLORS[level]
            date_time = "%s %s" % (record.getDate(), record.getTime())

            self._status_bar_widget.text_edit.\
                append("<font color=%s>[%s]" % (color, date_time) + \
                           " "*5 + "<b>%s</b></font>" % msg)

            if level == logging.WARNING or level == logging.ERROR:
                self._status_bar_widget.toggle_background_color()

    appendLogRecord = append_log_record
Beispiel #3
0
class Qt4_LogBarBrick(BlissWidget):
    """
    Descript. :
    """
    COLORS = {logging.NOTSET: 'lightgrey', logging.DEBUG: 'darkgreen', 
              logging.INFO: 'darkblue', logging.WARNING: 'orange', 
              logging.ERROR: 'red', logging.CRITICAL: 'black' }

    def __init__(self, *args):
        """
        Descript. :
        """
        BlissWidget.__init__(self, *args)

        self._status_bar_widget = LogBarWidget(self)
        _main_hlayout = QtGui.QHBoxLayout(self)
        _main_hlayout.addWidget(self._status_bar_widget)
        _main_hlayout.setSpacing(0)
        _main_hlayout.setContentsMargins(2, 2, 2, 2)
        self.setLayout(_main_hlayout)

        # LNLS
        #self.setSizePolicy(QtGui.QSizePolicy.MinimumExpanding, 
        #                   QtGui.QSizePolicy.Fixed)
        self.setSizePolicy(QtGui.QSizePolicy.Expanding, 
                           QtGui.QSizePolicy.Expanding)

        Qt4_GUILogHandler.GUILogHandler().register(self)

    def customEvent(self, event):
        """
        Descript. :
        """
        if self.isRunning():
            self.append_log_record(event.record)

    def append_log_record(self, record):
        """
        Descript. :
        """
        if record.name == 'user_level_log':
            msg = record.getMessage()#.replace('\n',' ').strip()
            level = record.getLevel()
            color = Qt4_LogBarBrick.COLORS[level]
            date_time = "%s %s" % (record.getDate(), record.getTime())

            self._status_bar_widget.text_edit.\
                append("<font color=%s>[%s]" % (color, date_time) + \
                           " "*5 + "<b>%s</b></font>" % msg)

            if level == logging.WARNING or level == logging.ERROR:
                self._status_bar_widget.toggle_background_color()

    appendLogRecord = append_log_record
Beispiel #4
0
    def __init__(self, *args):
        """
        Descript. :
        """
        BlissWidget.__init__(self, *args)

        # Hardware objects ----------------------------------------------------

        # Internal values -----------------------------------------------------
        self.max_log_lines = -1

        # Properties ----------------------------------------------------------
        self.addProperty('maxLogLines', 'integer', -1)

        # Signals -------------------------------------------------------------

        # Slots ---------------------------------------------------------------

        # Graphic elements ----------------------------------------------------
        self._status_bar_widget = LogBarWidget(self)

        # Layout --------------------------------------------------------------
        _main_hlayout = QHBoxLayout(self)
        _main_hlayout.addWidget(self._status_bar_widget)
        _main_hlayout.setSpacing(0)
        _main_hlayout.setContentsMargins(2, 2, 2, 2)

        # SizePolicies --------------------------------------------------------

        # Qt signal/slot connections ------------------------------------------

        # Other ---------------------------------------------------------------
        Qt4_GUILogHandler.GUILogHandler().register(self)
Beispiel #5
0
    def __init__(self, *args):
        """
        Descript. :
        """
        BlissWidget.__init__(self, *args)

        self._status_bar_widget = LogBarWidget(self)
        _main_hlayout = QtGui.QHBoxLayout(self)
        _main_hlayout.addWidget(self._status_bar_widget)
        _main_hlayout.setSpacing(0)
        _main_hlayout.setContentsMargins(2, 2, 2, 2)
        self.setLayout(_main_hlayout)

        # LNLS
        #self.setSizePolicy(QtGui.QSizePolicy.MinimumExpanding, 
        #                   QtGui.QSizePolicy.Fixed)
        self.setSizePolicy(QtGui.QSizePolicy.Expanding, 
                           QtGui.QSizePolicy.Expanding)

        Qt4_GUILogHandler.GUILogHandler().register(self)
Beispiel #6
0
    def __init__(self, *args):
        """
        Descript. :
        """
        BlissWidget.__init__(self, *args)

        #self.setObjectName("log_bar_brick")

        # Layout
        self._status_bar_widget = LogBarWidget(self)
        _main_hlayout = QtGui.QHBoxLayout(self)
        _main_hlayout.addWidget(self._status_bar_widget)
        _main_hlayout.setSpacing(0)
        _main_hlayout.setContentsMargins(0, 0, 0, 0)
        self.setLayout(_main_hlayout)

        self.setSizePolicy(QtGui.QSizePolicy.MinimumExpanding,
                           QtGui.QSizePolicy.Fixed)

        Qt4_GUILogHandler.GUILogHandler().register(self)
Beispiel #7
0
    def __init__(self, *args):
        """
        Descript. :
        """
        BlissWidget.__init__(self, *args)

        self._status_bar_widget = LogBarWidget(self)
        _main_hlayout = QtGui.QHBoxLayout(self)
        _main_hlayout.addWidget(self._status_bar_widget)
        _main_hlayout.setSpacing(0)
        _main_hlayout.setContentsMargins(2, 2, 2, 2)
        self.setLayout(_main_hlayout)

        self.setSizePolicy(QtGui.QSizePolicy.MinimumExpanding, 
                           QtGui.QSizePolicy.Fixed)

        Qt4_GUILogHandler.GUILogHandler().register(self)
Beispiel #8
0
    def __init__(self, *args):
        """
        Descript. :
        """
        BlissWidget.__init__(self, *args)

        # Layout
        self._status_bar_widget = LogBarWidget(self)
        _main_hlayout = QtGui.QHBoxLayout(self)
        _main_hlayout.addWidget(self._status_bar_widget)
        _main_hlayout.setSpacing(0)
        _main_hlayout.setContentsMargins(0, 0, 0, 0)
        self.setLayout(_main_hlayout)

        self.setSizePolicy(QtGui.QSizePolicy.MinimumExpanding, 
                           QtGui.QSizePolicy.Fixed)

        Qt4_GUILogHandler.GUILogHandler().register(self)
        logger = logging.getLogger("user_level_log")
        logger.info('Ready')
Beispiel #9
0
class Qt4_LogBarBrick(BlissWidget):
    """
    Descript. :
    """
    COLORS = {logging.NOTSET: Qt.lightGray,
              logging.DEBUG: Qt.darkGreen, 
              logging.INFO: Qt.darkBlue,
              logging.WARNING: QColor(255, 185, 56), 
              logging.ERROR: Qt.red,
              logging.CRITICAL: Qt.red}

    def __init__(self, *args):
        """
        Descript. :
        """
        BlissWidget.__init__(self, *args)

        # Hardware objects ----------------------------------------------------

        # Internal values -----------------------------------------------------
        self.max_log_lines = -1

        # Properties ----------------------------------------------------------
        self.addProperty('maxLogLines', 'integer', -1)

        # Signals -------------------------------------------------------------

        # Slots ---------------------------------------------------------------

        # Graphic elements ----------------------------------------------------
        self._status_bar_widget = LogBarWidget(self)

        # Layout --------------------------------------------------------------
        _main_hlayout = QHBoxLayout(self)
        _main_hlayout.addWidget(self._status_bar_widget)
        _main_hlayout.setSpacing(0)
        _main_hlayout.setContentsMargins(2, 2, 2, 2)

        # SizePolicies --------------------------------------------------------

        # Qt signal/slot connections ------------------------------------------

        # Other ---------------------------------------------------------------
        Qt4_GUILogHandler.GUILogHandler().register(self)

    def propertyChanged(self, property_name, old_value, new_value):
        if property_name == 'maxLogLines':
            self.max_log_lines = new_value
        else:
            BlissWidget.propertyChanged(self, property_name, old_value, new_value)

    def customEvent(self, event):
        """Event to add a new log record"""
        self.append_log_record(event.record)

    def append_log_record(self, record):
        """Appends a new log line to the text edit
        """
        if self.isRunning() and record.name in ('user_level_log', 'GUI'):
            msg = record.getMessage()
            level = record.getLevel()
            self._status_bar_widget.text_edit.setTextColor(Qt4_LogBarBrick.COLORS[level])
            self._status_bar_widget.text_edit.append(\
                "[%s %s]  %s" % (record.getDate(), record.getTime(), msg))

            #if level == logging.WARNING or level == logging.ERROR:
            #    self._status_bar_widget.toggle_background_color()
            text_document = self._status_bar_widget.text_edit.document()
            if self.max_log_lines > -1 and \
               text_document.blockCount() > self.max_log_lines:
                cursor = QTextCursor(text_document.firstBlock())
                cursor.select(QTextCursor.BlockUnderCursor)
                cursor.removeSelectedText()
                cursor.deleteChar()

            if level == logging.ERROR:
                self._status_bar_widget.toggle_background_color()
Beispiel #10
0
class Qt4_LogBarBrick(BlissWidget):
    """
    Descript. :
    """
    COLORS = {
        logging.NOTSET: 'lightgrey',
        logging.DEBUG: 'darkgreen',
        logging.INFO: 'darkblue',
        logging.WARNING: 'orange',
        logging.ERROR: 'red',
        logging.CRITICAL: 'black'
    }

    def __init__(self, *args):
        """
        Descript. :
        """
        BlissWidget.__init__(self, *args)

        # Hardware objects ----------------------------------------------------

        # Internal values -----------------------------------------------------
        self.max_log_lines = -1

        # Properties ----------------------------------------------------------
        self.addProperty('maxLogLines', 'integer', -1)

        # Signals -------------------------------------------------------------

        # Slots ---------------------------------------------------------------

        # Graphic elements ----------------------------------------------------
        self._status_bar_widget = LogBarWidget(self)

        # Layout --------------------------------------------------------------
        _main_hlayout = QHBoxLayout(self)
        _main_hlayout.addWidget(self._status_bar_widget)
        _main_hlayout.setSpacing(0)
        _main_hlayout.setContentsMargins(2, 2, 2, 2)

        # SizePolicies --------------------------------------------------------
        self.setSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.Fixed)

        # Qt signal/slot connections ------------------------------------------

        # Other ---------------------------------------------------------------
        Qt4_GUILogHandler.GUILogHandler().register(self)

    def propertyChanged(self, property_name, old_value, new_value):
        if property_name == 'maxLogLines':
            self.max_log_lines = new_value
        else:
            BlissWidget.propertyChanged(self, property_name, old_value,
                                        new_value)

    def customEvent(self, event):
        """Event to add a new log record"""
        self.append_log_record(event.record)

    def append_log_record(self, record):
        """Appends a new log line to the text edit
        """
        if self.isRunning() and record.name in ('user_level_log', 'GUI'):
            msg = record.getMessage()  #.replace('\n',' ').strip()
            level = record.getLevel()
            color = Qt4_LogBarBrick.COLORS[level]
            date_time = "%s %s" % (record.getDate(), record.getTime())

            self._status_bar_widget.text_edit.\
                append("<font color=%s>[%s]" % (color, date_time) + \
                           " "*5 + "<b>%s</b></font>" % msg)

            if level == logging.WARNING or level == logging.ERROR:
                self._status_bar_widget.toggle_background_color()
            text_document = self._status_bar_widget.text_edit.document()
            if self.max_log_lines > -1 and \
               text_document.blockCount() > self.max_log_lines:
                cursor = QTextCursor(text_document.firstBlock())
                cursor.select(QTextCursor.BlockUnderCursor)
                cursor.removeSelectedText()
                cursor.deleteChar()
Beispiel #11
0
class Qt4_LogBarBrick(BlissWidget):
    """
    Descript. :
    """
    COLORS = {
        logging.NOTSET: Qt.lightGray,
        logging.DEBUG: Qt.darkGreen,
        logging.INFO: Qt.darkBlue,
        logging.WARNING: QColor(255, 185, 56),
        logging.ERROR: Qt.red,
        logging.CRITICAL: Qt.red
    }

    def __init__(self, *args):
        """
        Descript. :
        """
        BlissWidget.__init__(self, *args)

        # Hardware objects ----------------------------------------------------

        # Internal values -----------------------------------------------------
        self.max_log_lines = -1

        # Properties ----------------------------------------------------------
        self.addProperty('maxLogLines', 'integer', -1)

        # Signals -------------------------------------------------------------

        # Slots ---------------------------------------------------------------

        # Graphic elements ----------------------------------------------------
        self._status_bar_widget = LogBarWidget(self)

        # Layout --------------------------------------------------------------
        _main_hlayout = QHBoxLayout(self)
        _main_hlayout.addWidget(self._status_bar_widget)
        _main_hlayout.setSpacing(0)
        _main_hlayout.setContentsMargins(2, 2, 2, 2)

        # SizePolicies --------------------------------------------------------

        # Qt signal/slot connections ------------------------------------------

        # Other ---------------------------------------------------------------
        Qt4_GUILogHandler.GUILogHandler().register(self)

    def propertyChanged(self, property_name, old_value, new_value):
        if property_name == 'maxLogLines':
            self.max_log_lines = new_value
        else:
            BlissWidget.propertyChanged(self, property_name, old_value,
                                        new_value)

    def customEvent(self, event):
        """Event to add a new log record"""
        self.append_log_record(event.record)

    def append_log_record(self, record):
        """Appends a new log line to the text edit
        """
        if self.isRunning() and record.name in ('user_level_log', 'GUI'):
            msg = record.getMessage()
            level = record.getLevel()
            self._status_bar_widget.text_edit.setTextColor(
                Qt4_LogBarBrick.COLORS[level])
            self._status_bar_widget.text_edit.append(\
                "[%s %s]  %s" % (record.getDate(), record.getTime(), msg))

            #if level == logging.WARNING or level == logging.ERROR:
            #    self._status_bar_widget.toggle_background_color()
            text_document = self._status_bar_widget.text_edit.document()
            if self.max_log_lines > -1 and \
               text_document.blockCount() > self.max_log_lines:
                cursor = QTextCursor(text_document.firstBlock())
                cursor.select(QTextCursor.BlockUnderCursor)
                cursor.removeSelectedText()
                cursor.deleteChar()

            if level == logging.ERROR:
                self._status_bar_widget.toggle_background_color()
Beispiel #12
0
class Qt4_LogBarBrick(BlissWidget):
    """
    Descript. :
    """
    COLORS = {logging.NOTSET: 'lightgrey',
              logging.DEBUG: 'darkgreen', 
              logging.INFO: 'darkblue',
              logging.WARNING: 'orange', 
              logging.ERROR: 'red',
              logging.CRITICAL: 'black'}

    def __init__(self, *args):
        """
        Descript. :
        """
        BlissWidget.__init__(self, *args)

        # Hardware objects ----------------------------------------------------

        # Internal values -----------------------------------------------------
        self.max_log_lines = -1

        # Properties ----------------------------------------------------------
        self.addProperty('maxLogLines', 'integer', -1)

        # Signals -------------------------------------------------------------

        # Slots ---------------------------------------------------------------

        # Graphic elements ----------------------------------------------------
        self._status_bar_widget = LogBarWidget(self)

        # Layout --------------------------------------------------------------
        _main_hlayout = QHBoxLayout(self)
        _main_hlayout.addWidget(self._status_bar_widget)
        _main_hlayout.setSpacing(0)
        _main_hlayout.setContentsMargins(2, 2, 2, 2)

        # SizePolicies --------------------------------------------------------
        #self.setSizePolicy(QSizePolicy.MinimumExpanding, 
        #                   QSizePolicy.Fixed)

        # Qt signal/slot connections ------------------------------------------

        # Other ---------------------------------------------------------------
        Qt4_GUILogHandler.GUILogHandler().register(self)

    def propertyChanged(self, property_name, old_value, new_value):
        if property_name == 'maxLogLines':
            self.max_log_lines = new_value
        else:
            BlissWidget.propertyChanged(self, property_name, old_value, new_value)

    def customEvent(self, event):
        """Event to add a new log record"""
        self.append_log_record(event.record)

    def append_log_record(self, record):
        """Appends a new log line to the text edit
        """
        if self.isRunning() and record.name in ('user_level_log', 'GUI'):
            msg = record.getMessage()#.replace('\n',' ').strip()
            level = record.getLevel()
            color = Qt4_LogBarBrick.COLORS[level]
            date_time = "%s %s" % (record.getDate(), record.getTime())

            self._status_bar_widget.text_edit.\
                append("<font color=%s>[%s]" % (color, date_time) + \
                           " "*5 + "<b>%s</b></font>" % msg)

            if level == logging.WARNING or level == logging.ERROR:
                self._status_bar_widget.toggle_background_color()
            text_document = self._status_bar_widget.text_edit.document()
            if self.max_log_lines > -1 and \
               text_document.blockCount() > self.max_log_lines:
                cursor = QTextCursor(text_document.firstBlock())
                cursor.select(QTextCursor.BlockUnderCursor)
                cursor.removeSelectedText()
                cursor.deleteChar()