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


Python CodeEditor.get_line_count方法代码示例

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


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

示例1: FilterDialog

# 需要导入模块: from spyderlib.widgets.sourcecode.codeeditor import CodeEditor [as 别名]
# 或者: from spyderlib.widgets.sourcecode.codeeditor.CodeEditor import get_line_count [as 别名]
class FilterDialog(QDialog):
    """ A dialog for editing filters
    """

    def __init__(self, groups, type=None, group=None, name=None, code=None, on_exception=False, parent=None):
        QDialog.__init__(self, parent)
        self.setupUi()
        self.groups = groups

        if type:
            index = self.filterTypeComboBox.findText(type)
            if index >= 0:
                self.filterTypeComboBox.setCurrentIndex(index)

        self.populate_groups()
        if group:
            index = self.filterGroupComboBox.findText(group)
            if index >= 0:
                self.filterGroupComboBox.setCurrentIndex(index)

        if name:
            self.nameLineEdit.setText(name)
        if code:
            self.editor.set_text('\n'.join(code))
        if name and code and type:
            self.filterTypeComboBox.setEnabled(False)

        self.onExceptionCheckBox.setChecked(on_exception)

    def populate_groups(self):
        self.filterGroupComboBox.clear()
        self.filterGroupComboBox.addItem('')
        for g in sorted(self.groups[self.filterTypeComboBox.currentText()]):
            self.filterGroupComboBox.addItem(g)

    def setupUi(self):
        self.setWindowTitle('Edit filter')
        #self.resize(400, 300)

        self.signatureLabel = QLabel(self)
        self.signatureLabel.setText('def filter(block):')

        font = QFont('Some font that does not exist')
        font.setStyleHint(font.TypeWriter, font.PreferDefault)
        self.editor = CodeEditor()
        self.editor.setup_editor(linenumbers=False, language='py',
            scrollflagarea=False, codecompletion_enter=True, font=font,
            highlight_current_line=False, occurence_highlighting=False)
        self.editor.set_text('return True')
        self.editor.setCursor(Qt.IBeamCursor)

        self.onExceptionCheckBox = QCheckBox(self)
        self.onExceptionCheckBox.setText('True on exception')
        self.onExceptionCheckBox.setToolTip('Determines if the filter will be admit items if there is an exception during its execution')

        self.filterTypeComboBox = QComboBox(self)
        self.filterTypeComboBox.addItem('Block')
        self.filterTypeComboBox.addItem('Segment')
        self.filterTypeComboBox.addItem('Recording Channel Group')
        self.filterTypeComboBox.addItem('Recording Channel')
        self.filterTypeComboBox.addItem('Unit')

        self.filterGroupComboBox = QComboBox(self)

        self.nameLineEdit = QLineEdit()

        self.dialogButtonBox = QDialogButtonBox(self)
        self.dialogButtonBox.setAutoFillBackground(False)
        self.dialogButtonBox.setOrientation(Qt.Horizontal)
        self.dialogButtonBox.setStandardButtons(QDialogButtonBox.Cancel|QDialogButtonBox.Ok)
        self.dialogButtonBox.setCenterButtons(True)

        gridLayout = QGridLayout(self)
        gridLayout.addWidget(self.signatureLabel, 0, 0, 1, 2)
        gridLayout.addWidget(self.editor, 1, 0, 1, 2)
        gridLayout.addWidget(self.onExceptionCheckBox, 2,0, 1, 2)
        gridLayout.addWidget(QLabel('Type:', self), 3, 0)
        gridLayout.addWidget(self.filterTypeComboBox, 3, 1)
        gridLayout.addWidget(QLabel('Group:', self), 4, 0)
        gridLayout.addWidget(self.filterGroupComboBox, 4, 1)
        gridLayout.addWidget(QLabel('Name:', self), 5, 0)
        gridLayout.addWidget(self.nameLineEdit, 5, 1)
        gridLayout.addWidget(self.dialogButtonBox, 6, 0, 1, 2)

        self.connect(self.dialogButtonBox, SIGNAL('accepted()'), self.accept)
        self.connect(self.dialogButtonBox, SIGNAL('rejected()'), self.reject)
        self.connect(self.filterTypeComboBox, SIGNAL('currentIndexChanged(int)'), self.on_filterTypeComboBox_currentIndexChanged)

    def name(self):
        return self.nameLineEdit.text()

    def code(self):
        return [self.editor.get_text_line(l) for l in xrange(self.editor.get_line_count())]

    def type(self):
        return self.filterTypeComboBox.currentText()

    def group(self):
        if self.filterGroupComboBox.currentText() == '':
            return None
#.........这里部分代码省略.........
开发者ID:neurodebian,项目名称:spykeviewer,代码行数:103,代码来源:filter_dialog.py


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