Example #1
0
    def __init__(self, *args, padding=(4, 4, 6, 6), preventEqualTexts=True):
        QtGui.QTabBar.__init__(self, *args)

        # Put tab widget in document mode
        self.setDocumentMode(True)

        # Widget needs to draw its background (otherwise Mac has a dark bg)
        self.setDrawBase(False)
        if sys.platform == 'darwin':
            self.setAutoFillBackground(True)

        # Set whether we want to prevent eliding for names that start the same.
        self._preventEqualTexts = preventEqualTexts

        # Allow moving tabs around
        self.setMovable(True)

        # Get padding
        if isinstance(padding, (int, float)):
            padding = padding, padding, padding, padding
        elif isinstance(padding, (tuple, list)):
            pass
        else:
            raise ValueError('Invalid value for padding.')

        # Set style sheet
        stylesheet = STYLESHEET
        stylesheet = stylesheet.replace('PADDING_TOP', str(padding[0]))
        stylesheet = stylesheet.replace('PADDING_BOTTOM', str(padding[1]))
        stylesheet = stylesheet.replace('PADDING_LEFT', str(padding[2]))
        stylesheet = stylesheet.replace('PADDING_RIGHT', str(padding[3]))
        self.setStyleSheet(stylesheet)

        # We do our own eliding
        self.setElideMode(QtCore.Qt.ElideNone)

        # Make tabs wider if there's plenty space?
        self.setExpanding(False)

        # If there's not enough space, use scroll buttons
        self.setUsesScrollButtons(True)

        # When a tab is removed, select previous
        self.setSelectionBehaviorOnRemove(self.SelectPreviousTab)

        # Init alignment parameters
        self._alignWidth = MIN_NAME_WIDTH  # Width in characters
        self._alignWidthIsReducing = False  # Whether in process of reducing

        # Create timer for aligning
        self._alignTimer = QtCore.QTimer(self)
        self._alignTimer.setInterval(10)
        self._alignTimer.setSingleShot(True)
        self._alignTimer.timeout.connect(self._alignRecursive)
Example #2
0
    def __init__(self, objectWithIcon):

        self._objectWithIcon = objectWithIcon

        # Motion properties
        self._index = 0
        self._level = 0
        self._count = 0  #  to count number of iters in level 1

        # Prepare blob pixmap
        self._blob = self._createBlobPixmap()
        self._legs = self._createLegsPixmap()

        # Create timer
        self._timer = QtCore.QTimer(None)
        self._timer.setInterval(150)
        self._timer.setSingleShot(False)
        self._timer.timeout.connect(self.onTimer)
Example #3
0
 def __init__(self, *args, **kwds):
     super().__init__(*args, **kwds)
     
     # Set font and zooming
     self.setFont(pyzo.config.view.fontname)
     self.setZoom(pyzo.config.view.zoom)
     
     # Create timer for autocompletion delay
     self._delayTimer = QtCore.QTimer(self)
     self._delayTimer.setSingleShot(True)
     self._delayTimer.timeout.connect(self._introspectNow)
     
     # For buffering autocompletion and calltip info
     self._callTipBuffer_name = ''
     self._callTipBuffer_time = 0
     self._callTipBuffer_result = ''
     self._autoCompBuffer_name = ''
     self._autoCompBuffer_time = 0
     self._autoCompBuffer_result = []
     
     # The string with names given to SCI_AUTOCSHOW
     self._autoCompNameString = ''
     
     # Set autocomp accept key to default if necessary.
     # We force it to be string (see issue 134)
     if not isinstance(pyzo.config.settings.autoComplete_acceptKeys, str):
         pyzo.config.settings.autoComplete_acceptKeys = 'Tab'
     
     # Set autocomp accept keys
     qtKeys = []
     for key in pyzo.config.settings.autoComplete_acceptKeys.split(' '):
         if len(key) > 1:
             key = 'Key_' + key[0].upper() + key[1:].lower()
             qtkey = getattr(QtCore.Qt, key, None)
         else:
             qtkey = ord(key)
         if qtkey:
             qtKeys.append(qtkey)
     self.setAutoCompletionAcceptKeys(*qtKeys)
     
     self.completer().highlighted.connect(self.updateHelp)
     self.setIndentUsingSpaces(pyzo.config.settings.defaultIndentUsingSpaces)
     self.setIndentWidth(pyzo.config.settings.defaultIndentWidth) 
     self.setAutocompletPopupSize(*pyzo.config.view.autoComplete_popupSize) 
Example #4
0
File: editor.py Project: j5s/pyzo
    def __init__(self, parent, **kwds):
        super().__init__(parent, showLineNumbers=True, **kwds)

        # Init filename and name
        self._filename = ''
        self._name = '<TMP>'

        # View settings
        self.setShowWhitespace(pyzo.config.view.showWhitespace)
        #TODO: self.setViewWrapSymbols(view.showWrapSymbols)
        self.setShowLineEndings(pyzo.config.view.showLineEndings)
        self.setShowIndentationGuides(pyzo.config.view.showIndentationGuides)
        #
        self.setWrap(bool(pyzo.config.view.wrap))
        self.setHighlightCurrentLine(pyzo.config.view.highlightCurrentLine)
        self.setLongLineIndicatorPosition(pyzo.config.view.edgeColumn)
        self.setHighlightMatchingBracket(
            pyzo.config.view.highlightMatchingBracket)
        #TODO: self.setFolding( int(view.codeFolding)*5 )
        # bracematch is set in baseTextCtrl, since it also applies to shells
        # dito for zoom and tabWidth

        # Set line endings to default
        self.lineEndings = pyzo.config.settings.defaultLineEndings

        # Set encoding to default
        self.encoding = 'UTF-8'

        # Modification time to test file change
        self._modifyTime = 0

        self.modificationChanged.connect(self._onModificationChanged)

        # To see whether the doc has changed to update the parser.
        self.textChanged.connect(self._onModified)

        # This timer is used to hide the marker that shows which code is executed
        self._showRunCursorTimer = QtCore.QTimer()

        # Add context menu (the offset is to prevent accidental auto-clicking)
        self._menu = EditorContextMenu(self)
        self.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
        self.customContextMenuRequested.connect(lambda p: self._menu.popup(
            self.mapToGlobal(p) + QtCore.QPoint(0, 3)))
Example #5
0
    def __init__(self, parent, shellStack):
        QtGui.QToolButton.__init__(self, parent)

        # Store reference of shell stack
        self._shellStack = shellStack

        # Keep reference of actions corresponding to shells
        self._shellActions = []

        # Set text and tooltip
        self.setText('Warming up ...')
        self.setToolTip("Click to select shell.")
        self.setToolButtonStyle(QtCore.Qt.ToolButtonTextBesideIcon)
        self.setPopupMode(self.InstantPopup)

        # Set icon
        self._iconMaker = ShellIconMaker(self)
        self._iconMaker.updateIcon('busy')  # Busy initializing

        # Create timer
        self._elapsedTimesTimer = QtCore.QTimer(self)
        self._elapsedTimesTimer.setInterval(200)
        self._elapsedTimesTimer.setSingleShot(False)
        self._elapsedTimesTimer.timeout.connect(self.onElapsedTimesTimer)