本文整理汇总了Python中PyQt5.Qt.QTabWidget.indexOf方法的典型用法代码示例。如果您正苦于以下问题:Python QTabWidget.indexOf方法的具体用法?Python QTabWidget.indexOf怎么用?Python QTabWidget.indexOf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.Qt.QTabWidget
的用法示例。
在下文中一共展示了QTabWidget.indexOf方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: MainWin
# 需要导入模块: from PyQt5.Qt import QTabWidget [as 别名]
# 或者: from PyQt5.Qt.QTabWidget import indexOf [as 别名]
#.........这里部分代码省略.........
Reads the content of the PRIMARY clipboard and navigates to it
on a new tab.
"""
url = clipboard()
if url is not None:
self.add_tab(url)
# aux. action (en register_actions)
def inc_tab(self, incby=1):
""" Takes the current tab index, modifies wrapping around,
and sets as current.
Afterwards the active tab has focus on its webkit area.
"""
if self.tab_widget.count() < 2:
return
idx = self.tab_widget.currentIndex()
idx += incby
if idx < 0:
idx = self.tab_widget.count()-1
elif idx >= self.tab_widget.count():
idx = 0
self.tab_widget.setCurrentIndex(idx)
self.tab_widget.currentWidget().webkit.setFocus()
def finalize(self):
""" Just doing self.close() doesn't clean up; for example, closing
when the address bar popup is visible doesn't close the popup, and
leaves the window hidden and unclosable (except e.g. for KILL 15)
Makes a hard app close through os._exit to prevent garbage collection;
cleanup has typically done more harm than good. Any state that we may
want to preserve we should do ourselves (e.g. cookies through the NAMs)
"""
idx = self.tab_widget.currentIndex()
self.tab_widget.widget(idx).deleteLater()
self.tab_widget.removeTab(idx)
close_managers() # also does an os._exit
# action y connect en llamada en constructor
def del_tab(self, idx=None):
""" Closes a tab. If 'idx' is set, it was called by a
tabCloseRequested signal (maybe mid click). If not,
it was called by a keyboard action and closes the
currently active tab.
Afterwards the active tab has focus on its webkit area.
It closes the window when deleting the last active tab.
"""
if idx is None:
idx = self.tab_widget.currentIndex()
self.tab_widget.widget(idx).webkit.stop()
self.last_closed = self.tab_widget.widget(idx).webkit.url()
self.tab_widget.widget(idx).deleteLater()
self.tab_widget.removeTab(idx)
if len(self.tab_widget) == 0:
close_managers() # also does an os.__exit
else:
self.tab_widget.currentWidget().webkit.setFocus()
# action (en register_actions)
# only way to create a new tab
# called externally in eilat.py to create the first tab
def add_tab(self, url=None, scripting=False):
""" Creates a new tab, either empty or navegating to the url.
Sets itself as the active tab.
If navegating to an url it gives focus to the webkit area. Otherwise,
the address bar is focused.
"""
tab = WebTab(parent=self.tab_widget)
self.tab_widget.addTab(tab, tab.current['title'])
self.tab_widget.setCurrentWidget(tab)
tab_idx = self.tab_widget.indexOf(tab)
self.tab_widget.tabBar().tabButton(tab_idx, 1).hide() # 1: right align
if scripting:
tab.toggle_script()
if url is not None:
qurl = fix_url(url)
tab.webkit.navigate(qurl)
else:
tab.address_bar.setFocus()
示例2: PanelQWidget
# 需要导入模块: from PyQt5.Qt import QTabWidget [as 别名]
# 或者: from PyQt5.Qt.QTabWidget import indexOf [as 别名]
class PanelQWidget(QWidget):
"""
Class who manage Panel with Host and Services QWidgets
"""
def __init__(self, parent=None):
super(PanelQWidget, self).__init__(parent)
self.setAcceptDrops(True)
# Fields
self.tab_widget = QTabWidget()
self.layout = QVBoxLayout()
self.dashboard_widget = DashboardQWidget()
self.synthesis_widget = SynthesisQWidget()
self.problems_widget = ProblemsQWidget()
self.spy_widget = SpyQWidget()
self.hostnames_list = []
def initialize(self):
"""
Create the QWidget with its items and layout.
"""
logger.info('Create Panel View...')
self.setLayout(self.layout)
# Dashboard widget
self.dashboard_widget.initialize()
self.layout.addWidget(self.dashboard_widget)
self.tab_widget.setMovable(True)
self.layout.addWidget(self.tab_widget)
tab_order = self.get_tab_order()
# Set hostnames
self.hostnames_list = data_manager.get_all_hostnames()
# Synthesis
self.synthesis_widget.initialize_synthesis()
self.synthesis_widget.host_widget.spy_btn.clicked.connect(self.spy_host)
self.synthesis_widget.line_search.returnPressed.connect(self.display_host)
self.synthesis_widget.line_search.cursorPositionChanged.connect(self.display_host)
self.synthesis_widget.create_line_search(self.hostnames_list)
self.tab_widget.insertTab(tab_order.index('h'), self.synthesis_widget, _('Host Synthesis'))
self.tab_widget.setTabToolTip(
self.tab_widget.indexOf(self.synthesis_widget), _('See a synthesis view of a host')
)
# Problems
self.problems_widget.initialize(self.spy_widget)
self.problems_widget.host_btn.clicked.connect(self.display_host)
self.problems_widget.problems_table.doubleClicked.connect(self.set_host_from_problems)
self.tab_widget.insertTab(
tab_order.index('p'),
self.problems_widget,
_('Problems (%d)') % len(data_manager.get_problems()['problems'])
)
self.tab_widget.setTabToolTip(
self.tab_widget.indexOf(self.problems_widget), _('See the problems found in backend')
)
# Spied hosts
self.spy_widget.initialize()
self.tab_widget.insertTab(tab_order.index('s'), self.spy_widget, _('Spy Hosts'))
self.tab_widget.setTabToolTip(
self.tab_widget.indexOf(self.spy_widget), _('See spy hosts by Alignak-app')
)
# Hide widget for first display
self.dashboard_widget.show()
self.synthesis_widget.host_widget.hide()
self.synthesis_widget.services_widget.hide()
@staticmethod
def get_tab_order():
"""
Return tab order defined by user, else default order
:return: tab order of App
:rtype: list
"""
default_order = ['p', 'h', 's']
tab_order = settings.get_config('Alignak-app', 'tab_order').split(',')
try:
assert len(tab_order) == len(default_order)
for nb in default_order:
assert nb in tab_order
except AssertionError:
logger.error('Wrong "tab_order" value in config file %s', tab_order)
tab_order = default_order
return tab_order
def spy_host(self):
"""
Spy host who is available in line_search QLineEdit
"""
#.........这里部分代码省略.........