本文整理汇总了Python中spyderlib.qt.QtGui.QPushButton.setEnabled方法的典型用法代码示例。如果您正苦于以下问题:Python QPushButton.setEnabled方法的具体用法?Python QPushButton.setEnabled怎么用?Python QPushButton.setEnabled使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类spyderlib.qt.QtGui.QPushButton
的用法示例。
在下文中一共展示了QPushButton.setEnabled方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from spyderlib.qt.QtGui import QPushButton [as 别名]
# 或者: from spyderlib.qt.QtGui.QPushButton import setEnabled [as 别名]
def __init__(self, parent, data, readonly=False,
xlabels=None, ylabels=None):
QWidget.__init__(self, parent)
self.data = data
self.old_data_shape = None
if len(self.data.shape) == 1:
self.old_data_shape = self.data.shape
self.data.shape = (self.data.shape[0], 1)
elif len(self.data.shape) == 0:
self.old_data_shape = self.data.shape
self.data.shape = (1, 1)
format = SUPPORTED_FORMATS.get(data.dtype.name, '%s')
self.model = ArrayModel(self.data, format=format, xlabels=xlabels,
ylabels=ylabels, readonly=readonly, parent=self)
self.view = ArrayView(self, self.model, data.dtype, data.shape)
btn_layout = QHBoxLayout()
btn_layout.setAlignment(Qt.AlignLeft)
btn = QPushButton(_( "Format"))
# disable format button for int type
btn.setEnabled(is_float(data.dtype))
btn_layout.addWidget(btn)
btn.clicked.connect(self.change_format)
btn = QPushButton(_( "Resize"))
btn_layout.addWidget(btn)
btn.clicked.connect(self.view.resize_to_contents)
bgcolor = QCheckBox(_( 'Background color'))
bgcolor.setChecked(self.model.bgcolor_enabled)
bgcolor.setEnabled(self.model.bgcolor_enabled)
bgcolor.stateChanged.connect(self.model.bgcolor)
btn_layout.addWidget(bgcolor)
layout = QVBoxLayout()
layout.addWidget(self.view)
layout.addLayout(btn_layout)
self.setLayout(layout)
示例2: ImportWizard
# 需要导入模块: from spyderlib.qt.QtGui import QPushButton [as 别名]
# 或者: from spyderlib.qt.QtGui.QPushButton import setEnabled [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"),
_(
#.........这里部分代码省略.........
示例3: ImportWizard
# 需要导入模块: from spyderlib.qt.QtGui import QPushButton [as 别名]
# 或者: from spyderlib.qt.QtGui.QPushButton import setEnabled [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)
#.........这里部分代码省略.........