本文整理汇总了Python中spyderlib.qt.QtGui.QLineEdit.text方法的典型用法代码示例。如果您正苦于以下问题:Python QLineEdit.text方法的具体用法?Python QLineEdit.text怎么用?Python QLineEdit.text使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类spyderlib.qt.QtGui.QLineEdit
的用法示例。
在下文中一共展示了QLineEdit.text方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ColorLayout
# 需要导入模块: from spyderlib.qt.QtGui import QLineEdit [as 别名]
# 或者: from spyderlib.qt.QtGui.QLineEdit import text [as 别名]
class ColorLayout(QHBoxLayout):
"""Color-specialized QLineEdit layout"""
def __init__(self, color, parent=None):
QHBoxLayout.__init__(self)
assert isinstance(color, QColor)
self.lineedit = QLineEdit(color.name(), parent)
self.connect(self.lineedit, SIGNAL("textChanged(QString)"),
self.update_color)
self.addWidget(self.lineedit)
self.colorbtn = ColorButton(parent)
self.colorbtn.color = color
self.connect(self.colorbtn, SIGNAL("colorChanged(QColor)"),
self.update_text)
self.addWidget(self.colorbtn)
def update_color(self, text):
color = text_to_qcolor(text)
if color.isValid():
self.colorbtn.color = color
def update_text(self, color):
self.lineedit.setText(color.name())
def text(self):
return self.lineedit.text()
示例2: RunConfigOptions
# 需要导入模块: from spyderlib.qt.QtGui import QLineEdit [as 别名]
# 或者: from spyderlib.qt.QtGui.QLineEdit import text [as 别名]
class RunConfigOptions(QWidget):
"""Run configuration options"""
def __init__(self, parent=None):
QWidget.__init__(self, parent)
self.current_radio = None
self.dedicated_radio = None
self.systerm_radio = None
self.runconf = RunConfiguration()
firstrun_o = CONF.get('run', ALWAYS_OPEN_FIRST_RUN_OPTION, False)
# --- General settings ----
common_group = QGroupBox(_("General settings"))
common_layout = QGridLayout()
common_group.setLayout(common_layout)
self.clo_cb = QCheckBox(_("Command line options:"))
common_layout.addWidget(self.clo_cb, 0, 0)
self.clo_edit = QLineEdit()
self.connect(self.clo_cb, SIGNAL("toggled(bool)"),
self.clo_edit.setEnabled)
self.clo_edit.setEnabled(False)
common_layout.addWidget(self.clo_edit, 0, 1)
self.wd_cb = QCheckBox(_("Working directory:"))
common_layout.addWidget(self.wd_cb, 1, 0)
wd_layout = QHBoxLayout()
self.wd_edit = QLineEdit()
self.connect(self.wd_cb, SIGNAL("toggled(bool)"),
self.wd_edit.setEnabled)
self.wd_edit.setEnabled(False)
wd_layout.addWidget(self.wd_edit)
browse_btn = QPushButton(get_std_icon('DirOpenIcon'), "", self)
browse_btn.setToolTip(_("Select directory"))
self.connect(browse_btn, SIGNAL("clicked()"), self.select_directory)
wd_layout.addWidget(browse_btn)
common_layout.addLayout(wd_layout, 1, 1)
# --- Interpreter ---
interpreter_group = QGroupBox(_("Console"))
interpreter_layout = QVBoxLayout()
interpreter_group.setLayout(interpreter_layout)
self.current_radio = QRadioButton(CURRENT_INTERPRETER)
interpreter_layout.addWidget(self.current_radio)
self.dedicated_radio = QRadioButton(DEDICATED_INTERPRETER)
interpreter_layout.addWidget(self.dedicated_radio)
self.systerm_radio = QRadioButton(SYSTERM_INTERPRETER)
interpreter_layout.addWidget(self.systerm_radio)
# --- Dedicated interpreter ---
new_group = QGroupBox(_("Dedicated Python console"))
self.connect(self.current_radio, SIGNAL("toggled(bool)"),
new_group.setDisabled)
new_layout = QGridLayout()
new_group.setLayout(new_layout)
self.interact_cb = QCheckBox(_("Interact with the Python "
"console after execution"))
new_layout.addWidget(self.interact_cb, 1, 0, 1, -1)
self.show_kill_warning_cb = QCheckBox(_("Show warning when killing"
" running process"))
new_layout.addWidget(self.show_kill_warning_cb, 2, 0, 1, -1)
self.pclo_cb = QCheckBox(_("Command line options:"))
new_layout.addWidget(self.pclo_cb, 3, 0)
self.pclo_edit = QLineEdit()
self.connect(self.pclo_cb, SIGNAL("toggled(bool)"),
self.pclo_edit.setEnabled)
self.pclo_edit.setEnabled(False)
self.pclo_edit.setToolTip(_("<b>-u</b> is added to the "
"other options you set here"))
new_layout.addWidget(self.pclo_edit, 3, 1)
#TODO: Add option for "Post-mortem debugging"
# Checkbox to preserve the old behavior, i.e. always open the dialog
# on first run
hline = QFrame()
hline.setFrameShape(QFrame.HLine)
hline.setFrameShadow(QFrame.Sunken)
self.firstrun_cb = QCheckBox(ALWAYS_OPEN_FIRST_RUN % _("this dialog"))
self.connect(self.firstrun_cb, SIGNAL("clicked(bool)"),
self.set_firstrun_o)
self.firstrun_cb.setChecked(firstrun_o)
layout = QVBoxLayout()
layout.addWidget(interpreter_group)
layout.addWidget(common_group)
layout.addWidget(new_group)
layout.addWidget(hline)
layout.addWidget(self.firstrun_cb)
self.setLayout(layout)
def select_directory(self):
"""Select directory"""
basedir = to_text_string(self.wd_edit.text())
if not osp.isdir(basedir):
basedir = getcwd()
directory = getexistingdirectory(self, _("Select directory"), basedir)
if directory:
self.wd_edit.setText(directory)
#.........这里部分代码省略.........
示例3: FileSwitcher
# 需要导入模块: from spyderlib.qt.QtGui import QLineEdit [as 别名]
# 或者: from spyderlib.qt.QtGui.QLineEdit import text [as 别名]
class FileSwitcher(QDialog):
"""A Sublime-like file switcher."""
sig_goto_file = Signal(int)
sig_close_file = Signal(int)
# Constants that define the mode in which the list widget is working
# FILE_MODE is for a list of files, SYMBOL_MODE if for a list of symbols
# in a given file when using the '@' symbol.
FILE_MODE, SYMBOL_MODE = [1, 2]
def __init__(self, parent, tabs, data):
QDialog.__init__(self, parent)
# Variables
self.tabs = tabs # Editor stack tabs
self.data = data # Editor data
self.mode = self.FILE_MODE # By default start in this mode
self.initial_cursors = None # {fullpath: QCursor}
self.initial_path = None # Fullpath of initial active editor
self.initial_editor = None # Initial active editor
self.line_number = None # Selected line number in filer
help_text = _("Press <b>Enter</b> to switch files or <b>Esc</b> to "
"cancel.<br><br>Type to filter filenames.<br><br>"
"Use <b>:number</b> to go to a line, e.g. "
"<b><code>main:42</code></b><br>"
"Use <b>@symbol_text</b> to go to a symbol, e.g. "
"<b><code>@init</code></b>"
"<br><br> Press <b>Ctrl+W</b> to close current tab.<br>")
# Either allow searching for a line number or a symbol but not both
regex = QRegExp("([A-Za-z0-9_]{0,100}@[A-Za-z0-9_]{0,100})|" +
"([A-Za-z]{0,100}:{0,1}[0-9]{0,100})")
# Widgets
self.edit = QLineEdit(self)
self.help = HelperToolButton()
self.list = QListWidget(self)
self.filter = KeyPressFilter()
regex_validator = QRegExpValidator(regex, self.edit)
# Widgets setup
self.setWindowFlags(Qt.Popup | Qt.FramelessWindowHint)
self.setWindowOpacity(0.95)
self.edit.installEventFilter(self.filter)
self.edit.setValidator(regex_validator)
self.help.setToolTip(help_text)
self.list.setItemDelegate(HTMLDelegate(self))
# Layout
edit_layout = QHBoxLayout()
edit_layout.addWidget(self.edit)
edit_layout.addWidget(self.help)
layout = QVBoxLayout()
layout.addLayout(edit_layout)
layout.addWidget(self.list)
self.setLayout(layout)
# Signals
self.rejected.connect(self.restore_initial_state)
self.filter.sig_up_key_pressed.connect(self.previous_row)
self.filter.sig_down_key_pressed.connect(self.next_row)
self.edit.returnPressed.connect(self.accept)
self.edit.textChanged.connect(self.setup)
self.list.itemSelectionChanged.connect(self.item_selection_changed)
self.list.clicked.connect(self.edit.setFocus)
# Setup
self.save_initial_state()
self.set_dialog_position()
self.setup()
# --- Properties
@property
def editors(self):
return [self.tabs.widget(index) for index in range(self.tabs.count())]
@property
def line_count(self):
return [editor.get_line_count() for editor in self.editors]
@property
def save_status(self):
return [getattr(td, 'newly_created', False) for td in self.data]
@property
def paths(self):
return [getattr(td, 'filename', None) for td in self.data]
@property
def filenames(self):
return [self.tabs.tabText(index) for index in range(self.tabs.count())]
@property
def current_path(self):
return self.paths_by_editor[self.get_editor()]
@property
def paths_by_editor(self):
return dict(zip(self.editors, self.paths))
#.........这里部分代码省略.........
示例4: ImportWizard
# 需要导入模块: from spyderlib.qt.QtGui import QLineEdit [as 别名]
# 或者: from spyderlib.qt.QtGui.QLineEdit import text [as 别名]
class ImportWizard(QDialog):
"""Text data import wizard"""
def __init__(self, parent, text, title=None, icon=None, contents_title=None, varname=None):
QDialog.__init__(self, parent)
# Destroying the C++ object right after closing the dialog box,
# otherwise it may be garbage-collected in another QThread
# (e.g. the editor's analysis thread in Spyder), thus leading to
# a segmentation fault on UNIX or an application crash on Windows
self.setAttribute(Qt.WA_DeleteOnClose)
if title is None:
title = _("Import wizard")
self.setWindowTitle(title)
if icon is None:
self.setWindowIcon(ima.icon("fileimport"))
if contents_title is None:
contents_title = _("Raw text")
if varname is None:
varname = _("variable_name")
self.var_name, self.clip_data = None, None
# Setting GUI
self.tab_widget = QTabWidget(self)
self.text_widget = ContentsWidget(self, text)
self.table_widget = PreviewWidget(self)
self.tab_widget.addTab(self.text_widget, _("text"))
self.tab_widget.setTabText(0, contents_title)
self.tab_widget.addTab(self.table_widget, _("table"))
self.tab_widget.setTabText(1, _("Preview"))
self.tab_widget.setTabEnabled(1, False)
name_layout = QHBoxLayout()
name_label = QLabel(_("Variable Name"))
name_layout.addWidget(name_label)
self.name_edt = QLineEdit()
self.name_edt.setText(varname)
name_layout.addWidget(self.name_edt)
btns_layout = QHBoxLayout()
cancel_btn = QPushButton(_("Cancel"))
btns_layout.addWidget(cancel_btn)
cancel_btn.clicked.connect(self.reject)
h_spacer = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum)
btns_layout.addItem(h_spacer)
self.back_btn = QPushButton(_("Previous"))
self.back_btn.setEnabled(False)
btns_layout.addWidget(self.back_btn)
self.back_btn.clicked.connect(ft_partial(self._set_step, step=-1))
self.fwd_btn = QPushButton(_("Next"))
btns_layout.addWidget(self.fwd_btn)
self.fwd_btn.clicked.connect(ft_partial(self._set_step, step=1))
self.done_btn = QPushButton(_("Done"))
self.done_btn.setEnabled(False)
btns_layout.addWidget(self.done_btn)
self.done_btn.clicked.connect(self.process)
self.text_widget.asDataChanged.connect(self.fwd_btn.setEnabled)
self.text_widget.asDataChanged.connect(self.done_btn.setDisabled)
layout = QVBoxLayout()
layout.addLayout(name_layout)
layout.addWidget(self.tab_widget)
layout.addLayout(btns_layout)
self.setLayout(layout)
def _focus_tab(self, tab_idx):
"""Change tab focus"""
for i in range(self.tab_widget.count()):
self.tab_widget.setTabEnabled(i, False)
self.tab_widget.setTabEnabled(tab_idx, True)
self.tab_widget.setCurrentIndex(tab_idx)
def _set_step(self, step):
"""Proceed to a given step"""
new_tab = self.tab_widget.currentIndex() + step
assert new_tab < self.tab_widget.count() and new_tab >= 0
if new_tab == self.tab_widget.count() - 1:
try:
self.table_widget.open_data(
self._get_plain_text(),
self.text_widget.get_col_sep(),
self.text_widget.get_row_sep(),
self.text_widget.trnsp_box.isChecked(),
self.text_widget.get_skiprows(),
self.text_widget.get_comments(),
)
self.done_btn.setEnabled(True)
self.done_btn.setDefault(True)
self.fwd_btn.setEnabled(False)
self.back_btn.setEnabled(True)
except (SyntaxError, AssertionError) as error:
QMessageBox.critical(
self,
_("Import wizard"),
_(
#.........这里部分代码省略.........
示例5: ContentsWidget
# 需要导入模块: from spyderlib.qt.QtGui import QLineEdit [as 别名]
# 或者: from spyderlib.qt.QtGui.QLineEdit import text [as 别名]
class ContentsWidget(QWidget):
"""Import wizard contents widget"""
asDataChanged = Signal(bool)
def __init__(self, parent, text):
QWidget.__init__(self, parent)
self.text_editor = QTextEdit(self)
self.text_editor.setText(text)
self.text_editor.setReadOnly(True)
# Type frame
type_layout = QHBoxLayout()
type_label = QLabel(_("Import as"))
type_layout.addWidget(type_label)
data_btn = QRadioButton(_("data"))
data_btn.setChecked(True)
self._as_data = True
type_layout.addWidget(data_btn)
code_btn = QRadioButton(_("code"))
self._as_code = False
type_layout.addWidget(code_btn)
txt_btn = QRadioButton(_("text"))
type_layout.addWidget(txt_btn)
h_spacer = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum)
type_layout.addItem(h_spacer)
type_frame = QFrame()
type_frame.setLayout(type_layout)
# Opts frame
grid_layout = QGridLayout()
grid_layout.setSpacing(0)
col_label = QLabel(_("Column separator:"))
grid_layout.addWidget(col_label, 0, 0)
col_w = QWidget()
col_btn_layout = QHBoxLayout()
self.tab_btn = QRadioButton(_("Tab"))
self.tab_btn.setChecked(False)
col_btn_layout.addWidget(self.tab_btn)
other_btn_col = QRadioButton(_("other"))
other_btn_col.setChecked(True)
col_btn_layout.addWidget(other_btn_col)
col_w.setLayout(col_btn_layout)
grid_layout.addWidget(col_w, 0, 1)
self.line_edt = QLineEdit(",")
self.line_edt.setMaximumWidth(30)
self.line_edt.setEnabled(True)
other_btn_col.toggled.connect(self.line_edt.setEnabled)
grid_layout.addWidget(self.line_edt, 0, 2)
row_label = QLabel(_("Row separator:"))
grid_layout.addWidget(row_label, 1, 0)
row_w = QWidget()
row_btn_layout = QHBoxLayout()
self.eol_btn = QRadioButton(_("EOL"))
self.eol_btn.setChecked(True)
row_btn_layout.addWidget(self.eol_btn)
other_btn_row = QRadioButton(_("other"))
row_btn_layout.addWidget(other_btn_row)
row_w.setLayout(row_btn_layout)
grid_layout.addWidget(row_w, 1, 1)
self.line_edt_row = QLineEdit(";")
self.line_edt_row.setMaximumWidth(30)
self.line_edt_row.setEnabled(False)
other_btn_row.toggled.connect(self.line_edt_row.setEnabled)
grid_layout.addWidget(self.line_edt_row, 1, 2)
grid_layout.setRowMinimumHeight(2, 15)
other_group = QGroupBox(_("Additional options"))
other_layout = QGridLayout()
other_group.setLayout(other_layout)
skiprows_label = QLabel(_("Skip rows:"))
other_layout.addWidget(skiprows_label, 0, 0)
self.skiprows_edt = QLineEdit("0")
self.skiprows_edt.setMaximumWidth(30)
intvalid = QIntValidator(0, len(to_text_string(text).splitlines()), self.skiprows_edt)
self.skiprows_edt.setValidator(intvalid)
other_layout.addWidget(self.skiprows_edt, 0, 1)
other_layout.setColumnMinimumWidth(2, 5)
comments_label = QLabel(_("Comments:"))
other_layout.addWidget(comments_label, 0, 3)
self.comments_edt = QLineEdit("#")
self.comments_edt.setMaximumWidth(30)
other_layout.addWidget(self.comments_edt, 0, 4)
self.trnsp_box = QCheckBox(_("Transpose"))
# self.trnsp_box.setEnabled(False)
other_layout.addWidget(self.trnsp_box, 1, 0, 2, 0)
grid_layout.addWidget(other_group, 3, 0, 2, 0)
opts_frame = QFrame()
opts_frame.setLayout(grid_layout)
#.........这里部分代码省略.........
示例6: RunConfigOptions
# 需要导入模块: from spyderlib.qt.QtGui import QLineEdit [as 别名]
# 或者: from spyderlib.qt.QtGui.QLineEdit import text [as 别名]
class RunConfigOptions(QWidget):
"""Run configuration options"""
def __init__(self, parent=None):
QWidget.__init__(self, parent)
self.runconf = RunConfiguration()
common_group = QGroupBox(_("General settings"))
common_layout = QGridLayout()
common_group.setLayout(common_layout)
self.clo_cb = QCheckBox(_("Command line options:"))
common_layout.addWidget(self.clo_cb, 0, 0)
self.clo_edit = QLineEdit()
self.connect(self.clo_cb, SIGNAL("toggled(bool)"), self.clo_edit.setEnabled)
self.clo_edit.setEnabled(False)
common_layout.addWidget(self.clo_edit, 0, 1)
self.wd_cb = QCheckBox(_("Working directory:"))
common_layout.addWidget(self.wd_cb, 1, 0)
wd_layout = QHBoxLayout()
self.wd_edit = QLineEdit()
self.connect(self.wd_cb, SIGNAL("toggled(bool)"), self.wd_edit.setEnabled)
self.wd_edit.setEnabled(False)
wd_layout.addWidget(self.wd_edit)
browse_btn = QPushButton(get_std_icon("DirOpenIcon"), "", self)
browse_btn.setToolTip(_("Select directory"))
self.connect(browse_btn, SIGNAL("clicked()"), self.select_directory)
wd_layout.addWidget(browse_btn)
common_layout.addLayout(wd_layout, 1, 1)
radio_group = QGroupBox(_("Interpreter"))
radio_layout = QVBoxLayout()
radio_group.setLayout(radio_layout)
self.current_radio = QRadioButton(_("Execute in current Python " "or IPython interpreter"))
radio_layout.addWidget(self.current_radio)
self.new_radio = QRadioButton(_("Execute in a new dedicated " "Python interpreter"))
radio_layout.addWidget(self.new_radio)
self.systerm_radio = QRadioButton(_("Execute in an external " "system terminal"))
radio_layout.addWidget(self.systerm_radio)
new_group = QGroupBox(_("Dedicated Python interpreter"))
self.connect(self.current_radio, SIGNAL("toggled(bool)"), new_group.setDisabled)
new_layout = QGridLayout()
new_group.setLayout(new_layout)
self.interact_cb = QCheckBox(_("Interact with the Python " "interpreter after execution"))
new_layout.addWidget(self.interact_cb, 1, 0, 1, -1)
self.pclo_cb = QCheckBox(_("Command line options:"))
new_layout.addWidget(self.pclo_cb, 2, 0)
self.pclo_edit = QLineEdit()
self.connect(self.pclo_cb, SIGNAL("toggled(bool)"), self.pclo_edit.setEnabled)
self.pclo_edit.setEnabled(False)
new_layout.addWidget(self.pclo_edit, 2, 1)
pclo_label = QLabel(_("The <b>-u</b> option is " "added to these commands"))
pclo_label.setWordWrap(True)
new_layout.addWidget(pclo_label, 3, 1)
# TODO: Add option for "Post-mortem debugging"
layout = QVBoxLayout()
layout.addWidget(common_group)
layout.addWidget(radio_group)
layout.addWidget(new_group)
self.setLayout(layout)
def select_directory(self):
"""Select directory"""
basedir = unicode(self.wd_edit.text())
if not osp.isdir(basedir):
basedir = os.getcwdu()
directory = getexistingdirectory(self, _("Select directory"), basedir)
if directory:
self.wd_edit.setText(directory)
self.wd_cb.setChecked(True)
def set(self, options):
self.runconf.set(options)
self.clo_cb.setChecked(self.runconf.args_enabled)
self.clo_edit.setText(self.runconf.args)
self.wd_cb.setChecked(self.runconf.wdir_enabled)
self.wd_edit.setText(self.runconf.wdir)
if self.runconf.current:
self.current_radio.setChecked(True)
elif self.runconf.systerm:
self.systerm_radio.setChecked(True)
else:
self.new_radio.setChecked(True)
self.interact_cb.setChecked(self.runconf.interact)
self.pclo_cb.setChecked(self.runconf.python_args_enabled)
self.pclo_edit.setText(self.runconf.python_args)
def get(self):
self.runconf.args_enabled = self.clo_cb.isChecked()
self.runconf.args = unicode(self.clo_edit.text())
self.runconf.wdir_enabled = self.wd_cb.isChecked()
self.runconf.wdir = unicode(self.wd_edit.text())
self.runconf.current = self.current_radio.isChecked()
self.runconf.systerm = self.systerm_radio.isChecked()
self.runconf.interact = self.interact_cb.isChecked()
self.runconf.python_args_enabled = self.pclo_cb.isChecked()
self.runconf.python_args = unicode(self.pclo_edit.text())
return self.runconf.get()
#.........这里部分代码省略.........