本文整理汇总了Python中spyderlib.qt.QtGui.QLineEdit.setMaximumWidth方法的典型用法代码示例。如果您正苦于以下问题:Python QLineEdit.setMaximumWidth方法的具体用法?Python QLineEdit.setMaximumWidth怎么用?Python QLineEdit.setMaximumWidth使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类spyderlib.qt.QtGui.QLineEdit
的用法示例。
在下文中一共展示了QLineEdit.setMaximumWidth方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ContentsWidget
# 需要导入模块: from spyderlib.qt.QtGui import QLineEdit [as 别名]
# 或者: from spyderlib.qt.QtGui.QLineEdit import setMaximumWidth [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)
#.........这里部分代码省略.........
示例2: ImportWizard
# 需要导入模块: from spyderlib.qt.QtGui import QLineEdit [as 别名]
# 或者: from spyderlib.qt.QtGui.QLineEdit import setMaximumWidth [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(get_icon("fileimport.png"))
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_h_spacer = QSpacerItem(40, 20,
QSizePolicy.Expanding, QSizePolicy.Minimum)
name_layout.addItem(name_h_spacer)
name_label = QLabel(_("Name"))
name_layout.addWidget(name_label)
self.name_edt = QLineEdit()
self.name_edt.setMaximumWidth(100)
self.name_edt.setText(varname)
name_layout.addWidget(self.name_edt)
btns_layout = QHBoxLayout()
cancel_btn = QPushButton(_("Cancel"))
btns_layout.addWidget(cancel_btn)
self.connect(cancel_btn, SIGNAL("clicked()"), self, SLOT("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.connect(self.back_btn, SIGNAL("clicked()"),
ft_partial(self._set_step, step=-1))
self.fwd_btn = QPushButton(_("Next"))
btns_layout.addWidget(self.fwd_btn)
self.connect(self.fwd_btn, SIGNAL("clicked()"),
ft_partial(self._set_step, step=1))
self.done_btn = QPushButton(_("Done"))
self.done_btn.setEnabled(False)
btns_layout.addWidget(self.done_btn)
self.connect(self.done_btn, SIGNAL("clicked()"),
self, SLOT("process()"))
self.connect(self.text_widget, SIGNAL("asDataChanged(bool)"),
self.fwd_btn, SLOT("setEnabled(bool)"))
self.connect(self.text_widget, SIGNAL("asDataChanged(bool)"),
self.done_btn, SLOT("setDisabled(bool)"))
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)
#.........这里部分代码省略.........