示例#1
0
    def __init__(self, editor):
        super(XNumberArea, self).__init__(editor)

        self._codeEditor = editor

        # set default properties
        font = QtGui.QFont()
        font.setPointSize(8)
        font.setFamily('Courier New')
        self.setFont(font)
示例#2
0
    def __init__(self, parent=None):
        super(XLogRecordWidget, self).__init__(parent)

        # load the user interface
        projexui.loadUi(__file__, self)

        # define custom properties
        self._handler = XLogRecordHandler(self)
        self._destroyed = False
        self._loggers = set()
        self._activeLevels = []
        self._queue = []
        self._timer = QtCore.QTimer()
        self._timer.setInterval(500)  # only load records every 500 msecs

        # update the feedback
        id = threading.currentThread().ident
        self.uiFeedbackLBL.setText('Main thread: {0}'.format(id))

        # update the interface
        font = QtGui.QFont('Courier New')
        font.setPointSize(9)
        self.uiRecordTREE.setFont(font)
        self.uiRecordTREE.setVisibleColumns(['Level', 'Name', 'Message'])
        self.uiRecordTREE.setFilteredColumns(
            list(range(self.uiRecordTREE.columnCount())))
        self.updateUi()

        # setup the configurations
        popup = self.uiSettingsBTN.popupWidget()
        popup.setShowTitleBar(False)
        popup.setResizable(False)

        bbox = popup.buttonBox()
        bbox.clear()
        bbox.addButton(QtGui.QDialogButtonBox.Ok)

        # create the logger tree widget
        controls = XLogRecordControls(self)
        self.uiSettingsBTN.setCentralWidget(controls)
        self.uiSettingsBTN.setDefaultAnchor(popup.Anchor.TopRight)

        self._timer.start()

        # create connections
        self._timer.timeout.connect(self.loadQueue)
        self._handler.dispatch().recordLogged.connect(self.addRecord)

        self.uiRecordBTN.toggled.connect(self.updateUi)
        self.uiRecordTREE.customContextMenuRequested.connect(self.showMenu)
        self.destroyed.connect(self.markDestroyed)
示例#3
0
 def __init__(self, parent=None):
     super(XCodeEdit, self).__init__(parent)
     
     # define custom properties
     self._filename = ''
     self._numberArea = XNumberArea(self)
     self._highlighter = None
     
     # set default properties
     font = QtGui.QFont()
     font.setPointSize(10)
     font.setFamily('Courier New')
     self.setFont(font)
     self.setWordWrapMode(QtGui.QTextOption.NoWrap)
     
     # create connections
     self.blockCountChanged.connect(self.updateNumberAreaWidth)
     self.updateRequest.connect(self.updateNumberArea)
     self.cursorPositionChanged.connect(self.highlightCurrentLine)
     
     self.updateNumberAreaWidth(0)
     self.highlightCurrentLine()
示例#4
0
    def __init__(self, parent):
        super(XLoggerWidget, self).__init__(parent)

        # set standard properties
        self.setReadOnly(True)
        self.setLineWrapMode(XLoggerWidget.NoWrap)

        # define custom properties
        self._clearOnClose = True
        self._handler = XLoggerWidgetHandler(self)
        self._currentMode = 'standard'
        self._blankCache = ''
        self._mutex = QtCore.QMutex()
        self._loggers = set()
        self._configurable = True
        self._destroyed = False

        # define the popup button for congfiguration
        self._configButton = XPopupButton(self)
        self._configButton.setIcon(
            QtGui.QIcon(resources.find('img/config.png')))
        self._configButton.setShadowed(True)

        popup = self._configButton.popupWidget()
        popup.setShowTitleBar(False)
        popup.setResizable(False)

        bbox = popup.buttonBox()
        bbox.clear()
        bbox.addButton(QtGui.QDialogButtonBox.Ok)

        # set to a monospace font
        font = QtGui.QFont('Courier New')
        font.setPointSize(9)
        self.setFont(font)
        metrics = QtGui.QFontMetrics(font)
        self.setTabStopWidth(4 * metrics.width(' '))
        self.setAcceptRichText(False)

        # determine whether or not to use the light or dark configuration
        palette = self.palette()
        base = palette.color(palette.Base)
        avg = (base.red() + base.green() + base.blue()) / 3.0

        if avg < 160:
            colorSet = XLoggerColorSet.darkScheme()
        else:
            colorSet = XLoggerColorSet.lightScheme()

        self._colorSet = colorSet
        palette.setColor(palette.Text, colorSet.color('Standard'))
        palette.setColor(palette.Base, colorSet.color('Background'))
        self.setPalette(palette)

        # create the logger tree widget
        controls = XLoggerControls(self)
        self._configButton.setCentralWidget(controls)
        self._configButton.setDefaultAnchor(popup.Anchor.TopRight)

        # create connections
        self._handler.dispatch().messageLogged.connect(self.log)
        self.destroyed.connect(self.markDestroyed)