本文整理汇总了Python中spyderlib.widgets.comboboxes.PatternComboBox.lineEdit方法的典型用法代码示例。如果您正苦于以下问题:Python PatternComboBox.lineEdit方法的具体用法?Python PatternComboBox.lineEdit怎么用?Python PatternComboBox.lineEdit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类spyderlib.widgets.comboboxes.PatternComboBox
的用法示例。
在下文中一共展示了PatternComboBox.lineEdit方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: FindReplace
# 需要导入模块: from spyderlib.widgets.comboboxes import PatternComboBox [as 别名]
# 或者: from spyderlib.widgets.comboboxes.PatternComboBox import lineEdit [as 别名]
class FindReplace(QWidget):
"""Find widget"""
STYLE = {False: "background-color:rgb(255, 175, 90);",
True: ""}
visibility_changed = Signal(bool)
def __init__(self, parent, enable_replace=False):
QWidget.__init__(self, parent)
self.enable_replace = enable_replace
self.editor = None
self.is_code_editor = None
glayout = QGridLayout()
glayout.setContentsMargins(0, 0, 0, 0)
self.setLayout(glayout)
self.close_button = create_toolbutton(self, triggered=self.hide,
icon=ima.icon('DialogCloseButton'))
glayout.addWidget(self.close_button, 0, 0)
# Find layout
self.search_text = PatternComboBox(self, tip=_("Search string"),
adjust_to_minimum=False)
self.search_text.valid.connect(
lambda state:
self.find(changed=False, forward=True, rehighlight=False))
self.search_text.lineEdit().textEdited.connect(
self.text_has_been_edited)
self.previous_button = create_toolbutton(self,
triggered=self.find_previous,
icon=ima.icon('ArrowUp'))
self.next_button = create_toolbutton(self,
triggered=self.find_next,
icon=ima.icon('ArrowDown'))
self.next_button.clicked.connect(self.update_search_combo)
self.previous_button.clicked.connect(self.update_search_combo)
self.re_button = create_toolbutton(self, icon=ima.icon('advanced'),
tip=_("Regular expression"))
self.re_button.setCheckable(True)
self.re_button.toggled.connect(lambda state: self.find())
self.case_button = create_toolbutton(self,
icon=get_icon("upper_lower.png"),
tip=_("Case Sensitive"))
self.case_button.setCheckable(True)
self.case_button.toggled.connect(lambda state: self.find())
self.words_button = create_toolbutton(self,
icon=get_icon("whole_words.png"),
tip=_("Whole words"))
self.words_button.setCheckable(True)
self.words_button.toggled.connect(lambda state: self.find())
self.highlight_button = create_toolbutton(self,
icon=get_icon("highlight.png"),
tip=_("Highlight matches"))
self.highlight_button.setCheckable(True)
self.highlight_button.toggled.connect(self.toggle_highlighting)
hlayout = QHBoxLayout()
self.widgets = [self.close_button, self.search_text,
self.previous_button, self.next_button,
self.re_button, self.case_button, self.words_button,
self.highlight_button]
for widget in self.widgets[1:]:
hlayout.addWidget(widget)
glayout.addLayout(hlayout, 0, 1)
# Replace layout
replace_with = QLabel(_("Replace with:"))
self.replace_text = PatternComboBox(self, adjust_to_minimum=False,
tip=_('Replace string'))
self.replace_button = create_toolbutton(self,
text=_('Replace/find'),
icon=ima.icon('DialogApplyButton'),
triggered=self.replace_find,
text_beside_icon=True)
self.replace_button.clicked.connect(self.update_replace_combo)
self.replace_button.clicked.connect(self.update_search_combo)
self.all_check = QCheckBox(_("Replace all"))
self.replace_layout = QHBoxLayout()
widgets = [replace_with, self.replace_text, self.replace_button,
self.all_check]
for widget in widgets:
self.replace_layout.addWidget(widget)
glayout.addLayout(self.replace_layout, 1, 1)
self.widgets.extend(widgets)
self.replace_widgets = widgets
self.hide_replace()
self.search_text.setTabOrder(self.search_text, self.replace_text)
self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
self.shortcuts = self.create_shortcuts(parent)
#.........这里部分代码省略.........
示例2: FindOptions
# 需要导入模块: from spyderlib.widgets.comboboxes import PatternComboBox [as 别名]
# 或者: from spyderlib.widgets.comboboxes.PatternComboBox import lineEdit [as 别名]
#.........这里部分代码省略.........
self.search_text.valid.connect(lambda valid: self.find.emit())
self.include_pattern.valid.connect(lambda valid: self.find.emit())
self.exclude_pattern.valid.connect(lambda valid: self.find.emit())
self.dir_combo.valid.connect(lambda valid: self.find.emit())
vlayout = QVBoxLayout()
vlayout.setContentsMargins(0, 0, 0, 0)
vlayout.addLayout(hlayout1)
vlayout.addLayout(hlayout2)
vlayout.addLayout(hlayout3)
self.more_widgets = (hlayout2, hlayout3)
self.toggle_more_options(more_options)
self.setLayout(vlayout)
self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Minimum)
@Slot(bool)
def toggle_more_options(self, state):
for layout in self.more_widgets:
for index in range(layout.count()):
if state and self.isVisible() or not state:
layout.itemAt(index).widget().setVisible(state)
if state:
icon = ima.icon('options_less')
tip = _('Hide advanced options')
else:
icon = ima.icon('options_more')
tip = _('Show advanced options')
self.more_options.setIcon(icon)
self.more_options.setToolTip(tip)
def update_combos(self):
self.search_text.lineEdit().returnPressed.emit()
self.include_pattern.lineEdit().returnPressed.emit()
self.exclude_pattern.lineEdit().returnPressed.emit()
def detect_hg_repository(self, path=None):
if path is None:
path = getcwd()
hg_repository = is_hg_installed() and get_vcs_root(path) is not None
self.hg_manifest.setEnabled(hg_repository)
if not hg_repository and self.hg_manifest.isChecked():
self.custom_dir.setChecked(True)
def set_search_text(self, text):
if text:
self.search_text.add_text(text)
self.search_text.lineEdit().selectAll()
self.search_text.setFocus()
def get_options(self, all=False):
# Getting options
utext = to_text_string(self.search_text.currentText())
if not utext:
return
try:
texts = [(utext.encode('ascii'), 'ascii')]
except UnicodeEncodeError:
texts = []
for enc in self.supported_encodings:
try:
texts.append((utext.encode(enc), enc))
except UnicodeDecodeError:
pass
text_re = self.edit_regexp.isChecked()
示例3: FindReplace
# 需要导入模块: from spyderlib.widgets.comboboxes import PatternComboBox [as 别名]
# 或者: from spyderlib.widgets.comboboxes.PatternComboBox import lineEdit [as 别名]
class FindReplace(QWidget):
"""
Find widget
Signals:
visibility_changed(bool)
"""
STYLE = {False: "background-color:rgb(255, 175, 90);", True: ""}
def __init__(self, parent, enable_replace=False):
QWidget.__init__(self, parent)
self.enable_replace = enable_replace
self.editor = None
self.is_code_editor = None
glayout = QGridLayout()
glayout.setContentsMargins(0, 0, 0, 0)
self.setLayout(glayout)
self.close_button = create_toolbutton(self, triggered=self.hide, icon=get_std_icon("DialogCloseButton"))
glayout.addWidget(self.close_button, 0, 0)
# Find layout
self.search_text = PatternComboBox(self, tip=_("Search string"), adjust_to_minimum=False)
self.connect(self.search_text.lineEdit(), SIGNAL("textEdited(QString)"), self.text_has_been_edited)
self.previous_button = create_toolbutton(self, triggered=self.find_previous, icon=get_std_icon("ArrowBack"))
self.next_button = create_toolbutton(self, triggered=self.find_next, icon=get_std_icon("ArrowForward"))
self.connect(self.next_button, SIGNAL("clicked()"), self.update_search_combo)
self.connect(self.previous_button, SIGNAL("clicked()"), self.update_search_combo)
self.re_button = create_toolbutton(self, icon=get_icon("advanced.png"), tip=_("Regular expression"))
self.re_button.setCheckable(True)
self.connect(self.re_button, SIGNAL("toggled(bool)"), lambda state: self.find())
self.case_button = create_toolbutton(self, icon=get_icon("upper_lower.png"), tip=_("Case Sensitive"))
self.case_button.setCheckable(True)
self.connect(self.case_button, SIGNAL("toggled(bool)"), lambda state: self.find())
self.words_button = create_toolbutton(self, icon=get_icon("whole_words.png"), tip=_("Whole words"))
self.words_button.setCheckable(True)
self.connect(self.words_button, SIGNAL("toggled(bool)"), lambda state: self.find())
self.highlight_button = create_toolbutton(self, icon=get_icon("highlight.png"), tip=_("Highlight matches"))
self.highlight_button.setCheckable(True)
self.connect(self.highlight_button, SIGNAL("toggled(bool)"), self.toggle_highlighting)
hlayout = QHBoxLayout()
self.widgets = [
self.close_button,
self.search_text,
self.previous_button,
self.next_button,
self.re_button,
self.case_button,
self.words_button,
self.highlight_button,
]
for widget in self.widgets[1:]:
hlayout.addWidget(widget)
glayout.addLayout(hlayout, 0, 1)
# Replace layout
replace_with = QLabel(_("Replace with:"))
self.replace_text = PatternComboBox(self, adjust_to_minimum=False, tip=_("Replace string"))
self.replace_button = create_toolbutton(
self,
text=_("Replace/find"),
icon=get_std_icon("DialogApplyButton"),
triggered=self.replace_find,
text_beside_icon=True,
)
self.connect(self.replace_button, SIGNAL("clicked()"), self.update_replace_combo)
self.connect(self.replace_button, SIGNAL("clicked()"), self.update_search_combo)
self.all_check = QCheckBox(_("Replace all"))
self.replace_layout = QHBoxLayout()
widgets = [replace_with, self.replace_text, self.replace_button, self.all_check]
for widget in widgets:
self.replace_layout.addWidget(widget)
glayout.addLayout(self.replace_layout, 1, 1)
self.widgets.extend(widgets)
self.replace_widgets = widgets
self.hide_replace()
self.search_text.setTabOrder(self.search_text, self.replace_text)
self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
self.findnext_sc = QShortcut(QKeySequence("F3"), parent, self.find_next)
self.findnext_sc.setContext(Qt.WidgetWithChildrenShortcut)
self.findprev_sc = QShortcut(QKeySequence("Shift+F3"), parent, self.find_previous)
self.findprev_sc.setContext(Qt.WidgetWithChildrenShortcut)
self.togglefind_sc = QShortcut(QKeySequence("Ctrl+F"), parent, self.show)
self.togglefind_sc.setContext(Qt.WidgetWithChildrenShortcut)
self.togglereplace_sc = QShortcut(QKeySequence("Ctrl+H"), parent, self.toggle_replace_widgets)
self.togglereplace_sc.setContext(Qt.WidgetWithChildrenShortcut)
#.........这里部分代码省略.........
示例4: FindOptions
# 需要导入模块: from spyderlib.widgets.comboboxes import PatternComboBox [as 别名]
# 或者: from spyderlib.widgets.comboboxes.PatternComboBox import lineEdit [as 别名]
#.........这里部分代码省略.........
self.hg_manifest.setToolTip(translate('FindInFiles',
"Search in current directory hg repository"))
searchin_label.setBuddy(self.hg_manifest)
self.custom_dir = QRadioButton(translate('FindInFiles',
"Directory:"), self)
self.custom_dir.setChecked(True)
self.dir_combo = PathComboBox(self)
self.dir_combo.addItems(search_path)
self.dir_combo.setToolTip(translate('FindInFiles',
"Search recursively in this directory"))
self.connect(self.dir_combo, SIGNAL("open_dir(QString)"),
self.set_directory)
self.connect(self.python_path, SIGNAL('toggled(bool)'),
self.dir_combo.setDisabled)
self.connect(self.hg_manifest, SIGNAL('toggled(bool)'),
self.dir_combo.setDisabled)
browse = create_toolbutton(self, get_std_icon('DirOpenIcon'),
tip=translate('FindInFiles',
'Browse a search directory'),
triggered=self.select_directory)
for widget in [searchin_label, self.python_path, self.hg_manifest,
self.custom_dir, self.dir_combo, browse]:
hlayout3.addWidget(widget)
vlayout = QVBoxLayout()
vlayout.addLayout(hlayout1)
vlayout.addLayout(hlayout2)
vlayout.addLayout(hlayout3)
self.setLayout(vlayout)
self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Minimum)
def update_combos(self):
self.search_text.lineEdit().emit(SIGNAL('returnPressed()'))
self.include_pattern.lineEdit().emit(SIGNAL('returnPressed()'))
self.exclude_pattern.lineEdit().emit(SIGNAL('returnPressed()'))
def detect_hg_repository(self, path=None):
if path is None:
path = os.getcwdu()
hg_repository = is_hg_installed() and get_hg_root(path) is not None
self.hg_manifest.setEnabled(hg_repository)
if not hg_repository and self.hg_manifest.isChecked():
self.custom_dir.setChecked(True)
def set_search_text(self, text):
self.search_text.setEditText(text)
self.search_text.lineEdit().selectAll()
self.search_text.setFocus()
def get_options(self, all=False):
# Getting options
utext = unicode(self.search_text.currentText())
if not utext:
return
try:
texts = [str(utext)]
except UnicodeDecodeError:
texts = []
for encoding in self.supported_encodings:
try:
texts.append( utext.encode(encoding) )
except UnicodeDecodeError:
pass
text_re = self.edit_regexp.isChecked()
include = unicode(self.include_pattern.currentText())
示例5: FindReplace
# 需要导入模块: from spyderlib.widgets.comboboxes import PatternComboBox [as 别名]
# 或者: from spyderlib.widgets.comboboxes.PatternComboBox import lineEdit [as 别名]
class FindReplace(QWidget):
"""
Find widget
"""
STYLE = {False: "background-color:rgb(255, 175, 90);",
True: ""}
def __init__(self, parent, enable_replace=False):
QWidget.__init__(self, parent)
self.enable_replace = enable_replace
self.editor = None
glayout = QGridLayout()
glayout.setContentsMargins(0, 0, 0, 0)
self.setLayout(glayout)
self.close_button = create_toolbutton(self, triggered=self.hide,
icon=get_std_icon("DialogCloseButton"))
glayout.addWidget(self.close_button, 0, 0)
# Find layout
self.search_text = PatternComboBox(self, tip=self.tr("Search string"),
adjust_to_minimum=False)
self.connect(self.search_text, SIGNAL("editTextChanged(QString)"),
self.text_has_changed)
self.previous_button = create_toolbutton(self,
text=self.tr("Previous"),
triggered=self.find_previous,
icon=get_std_icon("ArrowBack"))
self.next_button = create_toolbutton(self,
text=self.tr("Next"),
triggered=self.find_next,
icon=get_std_icon("ArrowForward"))
self.connect(self.next_button, SIGNAL('clicked()'),
self.update_search_combo)
self.connect(self.previous_button, SIGNAL('clicked()'),
self.update_search_combo)
self.case_check = QCheckBox(self.tr("Case Sensitive"))
self.connect(self.case_check, SIGNAL("stateChanged(int)"), self.find)
self.words_check = QCheckBox(self.tr("Whole words"))
self.connect(self.words_check, SIGNAL("stateChanged(int)"), self.find)
hlayout = QHBoxLayout()
self.widgets = [self.close_button, self.search_text, self.previous_button,
self.next_button, self.case_check, self.words_check]
for widget in self.widgets[1:]:
hlayout.addWidget(widget)
glayout.addLayout(hlayout, 0, 1)
# Replace layout
replace_with1 = QLabel(self.tr("Replace"))
replace_with2 = QLabel()
font = replace_with2.font()
font.setBold(True)
replace_with2.setFont(font)
replace_with3 = QLabel(self.tr("with:"))
self.replace_text = PatternComboBox(self, adjust_to_minimum=False,
tip=self.tr("Replace string"))
self.replace_button = create_toolbutton(self,
text=self.tr("Replace/find"),
triggered=self.replace_find,
icon=get_std_icon("DialogApplyButton"))
self.connect(self.replace_button, SIGNAL('clicked()'),
self.update_replace_combo)
self.connect(self.replace_button, SIGNAL('clicked()'),
self.update_search_combo)
self.all_check = QCheckBox(self.tr("Replace all"))
self.replace_layout = QHBoxLayout()
widgets = [replace_with1, replace_with2, replace_with3,
self.replace_text, self.replace_button, self.all_check]
for widget in widgets:
self.replace_layout.addWidget(widget)
self.connect(self.search_text, SIGNAL("editTextChanged(QString)"),
replace_with2, SLOT("setText(QString)"))
glayout.addLayout(self.replace_layout, 1, 1)
self.widgets.extend(widgets)
self.replace_widgets = widgets
self.hide_replace()
self.search_text.setTabOrder(self.search_text, self.replace_text)
self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
def update_search_combo(self):
self.search_text.lineEdit().emit(SIGNAL('returnPressed()'))
def update_replace_combo(self):
self.replace_text.lineEdit().emit(SIGNAL('returnPressed()'))
def keyPressEvent(self, event):
"""Reimplemented to handle key events"""
ctrl = event.modifiers() & Qt.ControlModifier
if event.key() == Qt.Key_Escape:
self.hide()
event.accept()
return
#.........这里部分代码省略.........