本文整理汇总了Python中qtpy.QtWidgets.QTabWidget.setTabEnabled方法的典型用法代码示例。如果您正苦于以下问题:Python QTabWidget.setTabEnabled方法的具体用法?Python QTabWidget.setTabEnabled怎么用?Python QTabWidget.setTabEnabled使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类qtpy.QtWidgets.QTabWidget
的用法示例。
在下文中一共展示了QTabWidget.setTabEnabled方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ImportWizard
# 需要导入模块: from qtpy.QtWidgets import QTabWidget [as 别名]
# 或者: from qtpy.QtWidgets.QTabWidget import setTabEnabled [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"),
_("<b>Unable to proceed to next step</b>"
"<br><br>Please check your entries."
"<br><br>Error message:<br>%s") % str(error))
return
#.........这里部分代码省略.........
示例2: PyChopGui
# 需要导入模块: from qtpy.QtWidgets import QTabWidget [as 别名]
# 或者: from qtpy.QtWidgets.QTabWidget import setTabEnabled [as 别名]
class PyChopGui(QMainWindow):
"""
GUI Class using PyQT for PyChop to help users plan inelastic neutron experiments
at spallation sources by calculating the resolution and flux at a given neutron energies.
"""
instruments = {}
choppers = {}
minE = {}
maxE = {}
def __init__(self):
super(PyChopGui, self).__init__()
self.folder = os.path.dirname(sys.modules[self.__module__].__file__)
for fname in os.listdir(self.folder):
if fname.endswith('.yaml'):
instobj = Instrument(os.path.join(self.folder, fname))
self.instruments[instobj.name] = instobj
self.choppers[instobj.name] = instobj.getChopperNames()
self.minE[instobj.name] = max([instobj.emin, 0.01])
self.maxE[instobj.name] = instobj.emax
self.drawLayout()
self.setInstrument(list(self.instruments.keys())[0])
self.resaxes_xlim = 0
self.qeaxes_xlim = 0
self.isFramePlotted = 0
def setInstrument(self, instname):
"""
Defines the instrument parameters by the name of the instrument.
"""
self.engine = self.instruments[str(instname)]
self.tabs.setTabEnabled(self.tdtabID, False)
self.widgets['ChopperCombo']['Combo'].clear()
self.widgets['FrequencyCombo']['Combo'].clear()
self.widgets['FrequencyCombo']['Label'].setText('Frequency')
self.widgets['PulseRemoverCombo']['Combo'].clear()
for item in self.choppers[str(instname)]:
self.widgets['ChopperCombo']['Combo'].addItem(item)
rep = self.engine.moderator.source_rep
maxfreq = self.engine.chopper_system.max_frequencies
# At the moment, the GUI only supports up to two independent frequencies
if not hasattr(maxfreq, '__len__') or len(maxfreq) == 1:
self.widgets['PulseRemoverCombo']['Combo'].hide()
self.widgets['PulseRemoverCombo']['Label'].hide()
for fq in range(rep, (maxfreq[0] if hasattr(maxfreq, '__len__') else maxfreq) + 1, rep):
self.widgets['FrequencyCombo']['Combo'].addItem(str(fq))
if hasattr(self.engine.chopper_system, 'frequency_names'):
self.widgets['FrequencyCombo']['Label'].setText(self.engine.chopper_system.frequency_names[0])
else:
self.widgets['PulseRemoverCombo']['Combo'].show()
self.widgets['PulseRemoverCombo']['Label'].show()
if hasattr(self.engine.chopper_system, 'frequency_names'):
for idx, chp in enumerate([self.widgets['FrequencyCombo']['Label'], self.widgets['PulseRemoverCombo']['Label']]):
chp.setText(self.engine.chopper_system.frequency_names[idx])
for fq in range(rep, maxfreq[0] + 1, rep):
self.widgets['FrequencyCombo']['Combo'].addItem(str(fq))
for fq in range(rep, maxfreq[1] + 1, rep):
self.widgets['PulseRemoverCombo']['Combo'].addItem(str(fq))
if len(self.engine.chopper_system.choppers) > 1:
self.widgets['MultiRepCheck'].setEnabled(True)
self.tabs.setTabEnabled(self.tdtabID, True)
else:
self.widgets['MultiRepCheck'].setEnabled(False)
self.widgets['MultiRepCheck'].setChecked(False)
self.widgets['Chopper2Phase']['Edit'].hide()
self.widgets['Chopper2Phase']['Label'].hide()
if self.engine.chopper_system.isPhaseIndependent:
self.widgets['Chopper2Phase']['Edit'].show()
self.widgets['Chopper2Phase']['Label'].show()
self.widgets['Chopper2Phase']['Edit'].setText(str(self.engine.chopper_system.defaultPhase[0]))
self.widgets['Chopper2Phase']['Label'].setText(self.engine.chopper_system.phaseNames[0])
# Special case for MERLIN - hide phase control from normal users
if 'MERLIN' in str(instname) and not self.instSciAct.isChecked():
self.widgets['Chopper2Phase']['Edit'].hide()
self.widgets['Chopper2Phase']['Label'].hide()
self.engine.setChopper(str(self.widgets['ChopperCombo']['Combo'].currentText()))
self.engine.setFrequency(float(self.widgets['FrequencyCombo']['Combo'].currentText()))
val = self.flxslder.val * self.maxE[self.engine.instname] / 100
self.flxedt.setText('%3.2f' % (val))
nframe = self.engine.moderator.n_frame if hasattr(self.engine.moderator, 'n_frame') else 1
self.repfig_nframe_edit.setText(str(nframe))
self.repfig_nframe_rep1only.setChecked(False)
if hasattr(self.engine.chopper_system, 'default_frequencies'):
cb = [self.widgets['FrequencyCombo']['Combo'], self.widgets['PulseRemoverCombo']['Combo']]
for idx, freq in enumerate(self.engine.chopper_system.default_frequencies):
cb[idx].setCurrentIndex([i for i in range(cb[idx].count()) if str(freq) in cb[idx].itemText(i)][0])
if idx > 1:
break
self.tabs.setTabEnabled(self.qetabID, False)
if self.engine.has_detector and hasattr(self.engine.detector, 'tthlims'):
self.tabs.setTabEnabled(self.qetabID, True)
def setChopper(self, choppername):
"""
Defines the Fermi chopper slit package type by name, or the disk chopper arrangement variant.
"""
self.engine.setChopper(str(choppername))
self.engine.setFrequency(float(self.widgets['FrequencyCombo']['Combo'].currentText()))
# Special case for MERLIN - only enable multirep for 'G' chopper
#.........这里部分代码省略.........