当前位置: 首页>>代码示例>>Python>>正文


Python Qutepart.setStyleSheet方法代码示例

本文整理汇总了Python中qutepart.Qutepart.setStyleSheet方法的典型用法代码示例。如果您正苦于以下问题:Python Qutepart.setStyleSheet方法的具体用法?Python Qutepart.setStyleSheet怎么用?Python Qutepart.setStyleSheet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在qutepart.Qutepart的用法示例。


在下文中一共展示了Qutepart.setStyleSheet方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: Document

# 需要导入模块: from qutepart import Qutepart [as 别名]
# 或者: from qutepart.Qutepart import setStyleSheet [as 别名]
class Document(QWidget):
    """
    Base class for documents on workspace, such as opened source file, Qt Designer and Qt Assistant, ...
    Inherit this class, if you want to create new document type

    This class may requre redesign, if we need to add support for non-textual or non-unicode editor.
    DO redesign instead of doing dirty hacks
    """

    documentDataChanged = pyqtSignal()
    """
    documentDataChanged()

    **Signal** emitted, when document icon or toolTip has changed
    (i.e. document has been modified externally)
    """

    _EOL_CONVERTOR = {r'\r\n': '\r\n',
                      r'\n': '\n',
                      r'\r': '\r'}

    def __init__( self, parentObject, filePath, createNew=False):
        """Create editor and open file.
        If file is None or createNew is True, empty not saved file is created
        IO Exceptions are not catched, therefore, must be catched on upper level
        """
        QWidget.__init__( self, parentObject)
        self._neverSaved = filePath is None or createNew
        self._filePath = filePath
        self._externallyRemoved = False
        self._externallyModified = False
        # File opening should be implemented in the document classes

        self._fileWatcher = _FileWatcher(filePath)
        self._fileWatcher.modified.connect(self._onWatcherFileModified)
        self._fileWatcher.removed.connect(self._onWatcherFileRemoved)

        if filePath and self._neverSaved:
            core.mainWindow().appendMessage('New file "%s" is going to be created' % filePath, 5000)

        self.qutepart = Qutepart(self)

        self.qutepart.setStyleSheet('QPlainTextEdit {border: 0}')

        self.qutepart.userWarning.connect(lambda text: core.mainWindow().statusBar().showMessage(text, 5000))

        self._applyQpartSettings()
        core.uiSettingsManager().dialogAccepted.connect(self._applyQpartSettings)

        layout = QVBoxLayout(self)
        layout.setMargin(0)
        layout.addWidget(self.qutepart)
        self.setFocusProxy(self.qutepart)

        if not self._neverSaved:
            originalText = self._readFile(filePath)
            self.qutepart.text = originalText
        else:
            originalText = ''

        #autodetect eol, if need
        self._configureEolMode(originalText)

        self._tryDetectSyntax()

    def _tryDetectSyntax(self):
        if len(self.qutepart.lines) > (100 * 1000) and \
           self.qutepart.language() is None:
            """Qutepart uses too lot of memory when highlighting really big files
            It may crash the editor, so, do not highlight really big files.
            But, do not disable highlighting for files, which already was highlighted
            """
            return

        self.qutepart.detectSyntax(sourceFilePath=self.filePath(),
                                   firstLine=self.qutepart.lines[0])

    def del_(self):
        """Explicytly called destructor
        """
        self._fileWatcher.disable()

        # avoid emit on text change, document shall behave like it is already dead
        self.qutepart.document().modificationChanged.disconnect()
        self.qutepart.text = ''  # stop background highlighting, free memory

    def _onWatcherFileModified(self, modified):
        """File has been modified
        """
        self._externallyModified = modified
        self.documentDataChanged.emit()

    def _onWatcherFileRemoved(self, isRemoved):
        """File has been removed
        """
        self._externallyRemoved = isRemoved
        self.documentDataChanged.emit()

    def _readFile(self, filePath):
        """Read the file contents.
#.........这里部分代码省略.........
开发者ID:vi,项目名称:enki,代码行数:103,代码来源:document.py

示例2: Document

# 需要导入模块: from qutepart import Qutepart [as 别名]
# 或者: from qutepart.Qutepart import setStyleSheet [as 别名]
class Document(QWidget):
    """
    Document is a opened file representation.

    It contains file management methods and uses `Qutepart <http://qutepart.rtfd.org/>`_ as an editor widget.
    Qutepart is available as ``qutepart`` attribute.
    """

    documentDataChanged = pyqtSignal()
    """
    documentDataChanged()

    **Signal** emitted, when document icon or toolTip has changed
    (i.e. document has been modified externally)
    """

    _EOL_CONVERTOR = {r'\r\n': '\r\n',
                      r'\n': '\n',
                      r'\r': '\r'}

    def __init__(self, parentObject, filePath, createNew=False):
        """Create editor and open file.
        If file is None or createNew is True, empty not saved file is created
        IO Exceptions are not catched, therefore, must be catched on upper level
        """
        QWidget.__init__(self, parentObject)
        self._neverSaved = filePath is None or createNew
        self._filePath = filePath
        self._externallyRemoved = False
        self._externallyModified = False
        # File opening should be implemented in the document classes

        self._fileWatcher = _FileWatcher(filePath)
        self._fileWatcher.modified.connect(self._onWatcherFileModified)
        self._fileWatcher.removed.connect(self._onWatcherFileRemoved)

        self.qutepart = Qutepart(self)

        self.qutepart.setStyleSheet('QPlainTextEdit {border: 0}')

        self.qutepart.userWarning.connect(lambda text: core.mainWindow().statusBar().showMessage(text, 5000))

        self._applyQpartSettings()
        core.uiSettingsManager().dialogAccepted.connect(self._applyQpartSettings)

        layout = QVBoxLayout(self)
        layout.setContentsMargins(0, 0, 0, 0)
        layout.addWidget(self.qutepart)
        self.setFocusProxy(self.qutepart)

        if not self._neverSaved:
            originalText = self._readFile(filePath)
            self.qutepart.text = originalText
        else:
            originalText = ''

        # autodetect eol, if need
        self._configureEolMode(originalText)

        self._tryDetectSyntax()

    def _tryDetectSyntax(self):
        if len(self.qutepart.lines) > (100 * 1000) and \
           self.qutepart.language() is None:
            """Qutepart uses too lot of memory when highlighting really big files
            It may crash the editor, so, do not highlight really big files.
            But, do not disable highlighting for files, which already was highlighted
            """
            return

        self.qutepart.detectSyntax(sourceFilePath=self.filePath(),
                                   firstLine=self.qutepart.lines[0])

    def terminate(self):
        """Explicytly called destructor
        """
        self._fileWatcher.term()

        # avoid emitting signals, document shall behave like it is already dead
        self.qutepart.document().modificationChanged.disconnect()
        self.qutepart.cursorPositionChanged.disconnect()  #
        self.qutepart.textChanged.disconnect()

        self.qutepart.terminate()  # stop background highlighting, free memory

    @pyqtSlot(bool)
    def _onWatcherFileModified(self, modified):
        """File has been modified
        """
        self._externallyModified = modified
        self.documentDataChanged.emit()

    @pyqtSlot(bool)
    def _onWatcherFileRemoved(self, isRemoved):
        """File has been removed
        """
        self._externallyRemoved = isRemoved
        self.documentDataChanged.emit()

    def _readFile(self, filePath):
#.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:103,代码来源:


注:本文中的qutepart.Qutepart.setStyleSheet方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。