本文整理汇总了Python中spyderlib.widgets.sourcecode.codeeditor.CodeEditor.setCursor方法的典型用法代码示例。如果您正苦于以下问题:Python CodeEditor.setCursor方法的具体用法?Python CodeEditor.setCursor怎么用?Python CodeEditor.setCursor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类spyderlib.widgets.sourcecode.codeeditor.CodeEditor
的用法示例。
在下文中一共展示了CodeEditor.setCursor方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: add_file
# 需要导入模块: from spyderlib.widgets.sourcecode.codeeditor import CodeEditor [as 别名]
# 或者: from spyderlib.widgets.sourcecode.codeeditor.CodeEditor import setCursor [as 别名]
def add_file(self, file_name):
font = QFont('Some font that does not exist')
font.setStyleHint(font.TypeWriter, font.PreferDefault)
editor = CodeEditor()
editor.setup_editor(linenumbers=True, language='py',
scrollflagarea=False, codecompletion_enter=True,
tab_mode=False, edge_line=False, font=font,
codecompletion_auto=True, go_to_definition=True,
codecompletion_single=True)
editor.setCursor(Qt.IBeamCursor)
editor.horizontalScrollBar().setCursor(Qt.ArrowCursor)
editor.verticalScrollBar().setCursor(Qt.ArrowCursor)
editor.file_name = file_name
if file_name.endswith('py'):
editor.set_text_from_file(file_name)
tab_name = os.path.split(file_name)[1]
else:
editor.set_text(self.template_code)
tab_name = 'New Analysis'
editor.file_was_changed = False
editor.textChanged.connect(lambda: self.file_changed(editor))
self.tabs.addTab(editor, tab_name)
self.tabs.setCurrentWidget(editor)
self.setVisible(True)
self.raise_()
示例2: FilterDialog
# 需要导入模块: from spyderlib.widgets.sourcecode.codeeditor import CodeEditor [as 别名]
# 或者: from spyderlib.widgets.sourcecode.codeeditor.CodeEditor import setCursor [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
#.........这里部分代码省略.........