本文整理汇总了Python中PySide.QtGui.QTabWidget.setCurrentIndex方法的典型用法代码示例。如果您正苦于以下问题:Python QTabWidget.setCurrentIndex方法的具体用法?Python QTabWidget.setCurrentIndex怎么用?Python QTabWidget.setCurrentIndex使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PySide.QtGui.QTabWidget
的用法示例。
在下文中一共展示了QTabWidget.setCurrentIndex方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TabDialog
# 需要导入模块: from PySide.QtGui import QTabWidget [as 别名]
# 或者: from PySide.QtGui.QTabWidget import setCurrentIndex [as 别名]
class TabDialog(QDialog):
"""This dialog contains tabs with options for everything related
to the module. Inheriting modules can add their own tabs
to this dialog by overriding buildTagDialog in ModuleFrame. They
should all super in order to keep the original tabs.
Example: a module might create a tab that determines what
the default aggregation method is for dropped data
"""
def __init__(self, parent, title=""):
"""Construct a TabDialog with the ModuleFrame parent and the
given title.
"""
super(TabDialog, self).__init__(parent)
self.setWindowTitle(title)
self.tabs = QTabWidget(self)
self.setModal(True)
# Need a layout to get resizing to work
layout = QGridLayout()
layout.addWidget(self.tabs, 0, 0)
self.setLayout(layout)
def addTab(self, tab, name, index=0):
"""Add the given tab to the TabDialog under the given name
at the given index. The index 0 means the tab will be
the active one when the TabDialog is raised.
"""
viewArea = QScrollArea()
viewArea.setWidget(tab)
viewArea.setWidgetResizable(True)
self.tabs.insertTab(index, viewArea, name)
self.tabs.setCurrentIndex(0)
示例2: TabView
# 需要导入模块: from PySide.QtGui import QTabWidget [as 别名]
# 或者: from PySide.QtGui.QTabWidget import setCurrentIndex [as 别名]
class TabView():
def __init__(self, targetLayoutContainer):
self.tabs = QTabWidget()
targetLayoutContainer.addWidget(self.tabs, 10)
def set_logger(self, logger):
self.logger = logger
def show_page(self, page):
print 'page is ' + page.item.name
widget = QWidget()
layout = QHBoxLayout()
widget.setLayout(layout)
pageWidget = pages.get_page_widget(page, layout, self)
self.tabs.insertTab(0, widget, page.label)
self.tabs.setCurrentIndex(0)
def save_page(self, page):
self.logger.info(__name__, 'save_page', page.description())
controller.save_page(page)
def clear(self):
self.tabs.clear()
print 'cleared'
示例3: MultiRenderPropWidget
# 需要导入模块: from PySide.QtGui import QTabWidget [as 别名]
# 或者: from PySide.QtGui.QTabWidget import setCurrentIndex [as 别名]
class MultiRenderPropWidget(QWidget):
"""
MultiRenderPropWidget is a widget that is displayed under the multi render
widget. It contains tabs with some controls for interaction and
visualization of the combined / multi-volume render widget.
"""
def __init__(self, multiRenderController, parent=None):
super(MultiRenderPropWidget, self).__init__(parent=parent)
# Two tabs: Visualization and Data info
self.mixParamWidget = RenderParameterWidget(multiRenderController)
self.transformParamWidget = TransformationParameterWidget()
self.registrationHistoryWidget = TransformationHistoryWidget()
self.slicesTabWidget = RenderSlicerParamWidget(multiRenderController)
# Create the tab widget
self.tabWidget = QTabWidget()
self.tabWidget.addTab(self.mixParamWidget, "Visualization")
self.tabWidget.addTab(self.registrationHistoryWidget, "History")
self.tabWidget.addTab(self.slicesTabWidget, "Slices")
self.currentTabIndex = 0
self.tabWidget.currentChanged.connect(self.tabIndexChanged)
layout = QVBoxLayout()
self.setLayout(layout)
layout.addWidget(self.tabWidget)
self.registrationHistoryWidget.setMultiRenderWidget(multiRenderController.multiRenderWidget)
def setTransformTool(self, transformTool):
if self.tabWidget.indexOf(self.transformParamWidget) < 0:
self.tabWidget.addTab(self.transformParamWidget, "Transformation")
self.tabWidget.setCurrentWidget(self.transformParamWidget)
self.transformParamWidget.setTransformationTool(transformTool)
def transformToolFinished(self):
index = self.tabWidget.indexOf(self.transformParamWidget)
if index >= 0:
# Restore the last tab index that wasn't the transform tab
self.tabWidget.setCurrentIndex(self.currentTabIndex)
self.tabWidget.removeTab(index)
@Slot(int)
def tabIndexChanged(self, index):
transformIndex = self.tabWidget.indexOf(self.transformParamWidget)
if index != transformIndex:
self.currentTabIndex = index
示例4: window
# 需要导入模块: from PySide.QtGui import QTabWidget [as 别名]
# 或者: from PySide.QtGui.QTabWidget import setCurrentIndex [as 别名]
#.........这里部分代码省略.........
complete_tab_layout.setSpacing(0)
complete_tab_layout.setContentsMargins(0, 0, 0, 0)
complete_tab_layout.addWidget(tasklist)
complete_tab_layout.addWidget(page_widget)
complete_tab_widget = QFrame()
complete_tab_widget.setLayout(complete_tab_layout)
#for page in tab['history']:
# new_tab.load(QUrl(page['url']))
#print tab['current_history']
#for item in new_tab.history().items():
# print item
#new_tab.history().goToItem(new_tab.history().itemAt(tab['current_history']))
new_tab.load(QUrl(tab['history'][tab['current_history']]['url']))
tab['current_history']
self.tabs.setUpdatesEnabled(False)
if self.new_tab_behavior == "insert":
self.tabs.insertTab(self.tabs.currentIndex()+1, complete_tab_widget,
unicode(new_tab.title()))
elif self.new_tab_behavior == "append":
self.tabs.appendTab(complete_tab_widget, unicode(new_tab.title()))
self.tabs.setUpdatesEnabled(True)
new_tab.titleChanged.connect(self.change_tab)
new_tab.urlChanged.connect(self.change_tab)
new_tab.loadStarted.connect(self.load_start)
new_tab.loadFinished.connect(self.load_finish)
new_tab.loadProgress.connect(self.pbar.setValue)
new_tab.page().linkHovered.connect(self.linkHover)
inspector.setPage(new_tab.page())
for index, tab in enumerate(saved_tabs['tabs']):
self.tabs.setTabText(index, tab['history'][tab['current_history']]['title'])
self.tabs.setCurrentIndex(saved_tabs['current_tab'])
else:
self.new_tab()
tabs_layout = QVBoxLayout()
tabs_layout.setSpacing(0)
tabs_layout.setContentsMargins(0, 0, 0, 0)
tabs_layout.addWidget(self.tabs)
self.tabs_widget = QFrame()
self.tabs_widget.setObjectName("TabLine")
self.tabs_widget.setStyleSheet(self.style_sheet)
self.tabs_widget.setLayout(tabs_layout)
self.tabs_widget.setVisible(True)
# Webkit settings
gsettings = self.tabs.currentWidget().findChild(QFrame, unicode('pageWidget')).findChild(QWebView, unicode('webView')).settings().globalSettings()
# Basic settings
gsettings.setAttribute(QWebSettings.AutoLoadImages, True)
gsettings.setAttribute(QWebSettings.JavascriptEnabled, True)
gsettings.setAttribute(QWebSettings.JavascriptCanOpenWindows, False)
gsettings.setAttribute(QWebSettings.JavascriptCanAccessClipboard, False)
gsettings.setAttribute(QWebSettings.PluginsEnabled, False) # Flash isn't stable at present
gsettings.setAttribute(QWebSettings.JavaEnabled, False) # Java applet's aren't supported by PySide
gsettings.setAttribute(QWebSettings.DeveloperExtrasEnabled, True)
gsettings.setAttribute(QWebSettings.AcceleratedCompositingEnabled,
True)
# Performace settings
gsettings.setAttribute(QWebSettings.DnsPrefetchEnabled, True)
gsettings.setAttribute(QWebSettings.AcceleratedCompositingEnabled, True)
gsettings.setAttribute(QWebSettings.DnsPrefetchEnabled, True)
# Other settings
gsettings.setAttribute(QWebSettings.PrivateBrowsingEnabled, False)
示例5: STMainWindow
# 需要导入模块: from PySide.QtGui import QTabWidget [as 别名]
# 或者: from PySide.QtGui.QTabWidget import setCurrentIndex [as 别名]
#.........这里部分代码省略.........
t = sweattrails.qt.imports.BackgroundThread.get_thread()
t.jobStarted.connect(self.status_message)
t.jobFinished.connect(self.status_message)
t.jobError.connect(self.status_message)
else:
self.close()
def switch_user(self):
pass
def select_user(self):
ret = False
if QCoreApplication.instance().user:
return True
elif QCoreApplication.instance().has_users():
dialog = SelectUser(self)
dialog.select()
ret = QCoreApplication.instance().is_authenticated()
if ret:
self.refresh()
else:
dialog = CreateUser(self)
dialog.exec_()
ret = QCoreApplication.instance().is_authenticated()
if ret:
self.refresh()
return ret
#
# FILE IMPORT
#
def file_import(self):
(fileNames, _) = QFileDialog.getOpenFileNames(self,
"Open Activity File",
"",
"Activity Files (*.tcx *.fit *.csv)")
if fileNames:
QCoreApplication.instance().import_files(*fileNames)
def file_import_started(self, filename):
self.switchUserAct.setEnabled(False)
def file_imported(self, filename):
self.switchUserAct.setEnabled(True)
self.refresh()
def file_import_error(self, filename, msg):
self.switchUserAct.setEnabled(True)
self.refresh()
#
# END FILE IMPORT
#
# =====================================================================
# S I G N A L H A N D L E R S
# =====================================================================
def refresh(self):
QCoreApplication.instance().refresh.emit()
self.status_message("")
def tabChanged(self, tabix):
w = self.tabs.currentWidget()
if hasattr(w, "activate"):
w.activate(0)
if hasattr(w, "setValues"):
w.setValues()
def setSession(self, session):
self.tabs.setCurrentIndex(0)
self.sessiontab.setSession(session)
def setTab(self, tab):
t = self.tabs.currentWidget()
if t and hasattr(t, "setTab"):
t.setTab(tab)
def userSet(self):
user = QCoreApplication.instance().user
if user.is_admin():
self.usertab.show()
def status_message(self, msg, *args):
self.statusmessage.setText(msg.format(*args))
def progress_init(self, msg, *args):
self.progressbar.setValue(0)
self.status_message(msg, *args)
def progress(self, percentage):
self.progressbar.setValue(percentage)
def progress_done(self):
self.progressbar.reset()
def about(self):
QMessageBox.about(self, "About SweatTrails",
"SweatTrails is a training log application")
示例6: RenderPropWidget
# 需要导入模块: from PySide.QtGui import QTabWidget [as 别名]
# 或者: from PySide.QtGui.QTabWidget import setCurrentIndex [as 别名]
class RenderPropWidget(QWidget):
"""
RenderPropWidget is a widget that is displayed under the render widgets. It
contains a tabwidget in which information of the data can be displayed and
in which visualization parameters can be shown. One of the tabs is a
RenderParameterWidget object.
"""
def __init__(self, renderController, parent=None):
super(RenderPropWidget, self).__init__(parent=parent)
# Three tabs: Visualization, data info and slices
self.visParamTabWidget = RenderParameterWidget(renderController)
self.dataInfoTabWidget = RenderInfoWidget()
self.slicesTabWidget = RenderSlicerParamWidget(renderController)
# Create the load dataset widget
self.loadDataWidget = QWidget()
self.loadDataButton = QPushButton()
self.loadDataButton.setText("Load a dataset")
layout = QVBoxLayout()
layout.setAlignment(Qt.AlignTop)
layout.addWidget(self.loadDataButton)
self.loadDataWidget.setLayout(layout)
# Create the tab widget
self.tabWidget = QTabWidget()
self.tabWidget.addTab(self.visParamTabWidget, "Visualization")
self.tabWidget.addTab(self.slicesTabWidget, "Slices")
self.tabWidget.addTab(self.dataInfoTabWidget, "Data info")
self.currentTabIndex = 0
self.extraTabWidget = None
self.tabWidget.currentChanged.connect(self.tabIndexChanged)
layout = QVBoxLayout()
layout.addWidget(self.loadDataWidget)
self.setLayout(layout)
def setFileChangedSignal(self, signal):
"""
:param signal: Signal that is connected to some file-loading slots.
:type signal: SIGNAL
"""
self.signal = signal
self.signal.connect(self.setFile)
self.signal.connect(self.dataInfoTabWidget.setFile)
def setLoadDataSlot(self, slot):
"""
The button is connected to the given slot. The slot action should load
a dataset from disk.
:type slot: Slot
"""
self.loadDataButton.clicked.connect(slot)
@Slot(basestring)
def setFile(self, fileName):
"""
When a file is loaded, the 'load data' button is removed from the widget
and the actual tabs with parameters are put on screen.
"""
layout = self.layout()
if fileName is None:
if layout.indexOf(self.tabWidget) != -1:
# Remove the parameter widgets
layout.removeWidget(self.tabWidget)
self.tabWidget.setParent(None)
# Show the load data button
layout.addWidget(self.loadDataWidget)
self.setLayout(layout)
else:
if layout.indexOf(self.loadDataWidget) != -1:
# Remove the load data button
layout.removeWidget(self.loadDataWidget)
self.loadDataWidget.setParent(None)
# Add the parameter widgets
layout.addWidget(self.tabWidget)
self.setLayout(layout)
@Slot(int)
def tabIndexChanged(self, index):
transformIndex = self.tabWidget.indexOf(self.extraTabWidget)
if index != transformIndex:
self.currentTabIndex = index
def addTabWidget(self, widget, name):
self.extraTabWidget = widget
self.tabWidget.addTab(widget, name)
self.tabWidget.setCurrentWidget(self.extraTabWidget)
def removeTabWidget(self):
if self.extraTabWidget is None:
return
index = self.tabWidget.indexOf(self.extraTabWidget)
if index >= 0:
# Restore the last tab index that wasn't the transform tab
self.tabWidget.setCurrentIndex(self.currentTabIndex)
#.........这里部分代码省略.........
示例7: FormWidget
# 需要导入模块: from PySide.QtGui import QTabWidget [as 别名]
# 或者: from PySide.QtGui.QTabWidget import setCurrentIndex [as 别名]
class FormWidget(FormPage):
instanceAssigned = Signal(str)
instanceDeleted = Signal(str)
instanceSaved = Signal(str)
exception = Signal(str)
def __init__(self, parent = None, buttons = FormButtons.EditButtons):
super(FormWidget, self).__init__(parent)
self.buildButtonBox(buttons)
self.tabs = None
self._tabs = {}
def buildButtonBox(self, buttons):
buttonWidget = QGroupBox()
self.buttonbox = QHBoxLayout(buttonWidget)
if buttons & FormButtons.DeleteButton:
self.deletebutton = QPushButton("Delete", self)
self.deletebutton.clicked.connect(self.deleteInstance)
self.buttonbox.addWidget(self.deletebutton)
self.buttonbox.addStretch(1)
if buttons & FormButtons.ResetButton:
self.resetbutton = QPushButton("Reset", self)
self.resetbutton.clicked.connect(self.setInstance)
self.buttonbox.addWidget(self.resetbutton)
if buttons & FormButtons.SaveButton:
self.savebutton = QPushButton("Save", self)
self.savebutton.clicked.connect(self.save)
self.buttonbox.addWidget(self.savebutton)
self.layout().addWidget(buttonWidget)
def addWidgetToButtonBox(self, widget, *args):
self.buttonbox.insertWidget(0, widget, *args)
def addTab(self, widget, title):
if self.tabs is None:
self.tabs = QTabWidget(self)
self.tabs.currentChanged[int].connect(self.tabChanged)
# Remove stretch at the bottom:
self._removeStretch()
self.vbox.addWidget(self.tabs, 1)
if isinstance(widget, FormPage):
self.form.addSubLayout(widget.form)
self.tabs.addTab(widget, title)
self._tabs[title] = widget
return widget
def count(self):
return self.tabs and self.tabs.count()
def setTab(self, tab):
if self.tabs and tab <= self.tabs.count():
self.tabs.setCurrentIndex(tab)
def tabChanged(self, ix):
w = self.tabs.currentWidget()
if hasattr(w, "selected"):
w.selected()
def save(self):
try:
self.form.retrieve(self.instance())
if hasattr(self, "retrieve") and callable(self.retrieve):
self.retrieve(self.instance())
self.instanceSaved.emit(str(self.instance.key()))
self.statusMessage.emit("Saved")
except:
self.exception.emit("Save failed...")
self.setInstance()
def instance(self):
return self._instance
def setInstance(self, instance = None):
if instance:
self._instance = instance
self.form.apply(self.instance())
if hasattr(self, "assign") and callable(self.assign):
self.assign(self.instance())
self.instanceAssigned.emit(str(self.instance().key()))
def confirmDelete(self):
return QMessageBox.warning(self, "Are you sure?",
"Are you sure you want to delete this?",
QMessageBox.Cancel | QMessageBox.Ok,
QMessageBox.Cancel) == QMessageBox.Ok
def onDelete(self):
try:
with gripe.db.Tx.begin():
key = str(self.instance().key())
if grumble.model.delete(self.instance()):
self.instanceDeleted.emit(key)
except:
traceback.print_exc()
self.exception.emit("Delete failed...")
def deleteInstance(self):
if self.instance() and self.confirmDelete():
self.onDelete()
示例8: Truss
# 需要导入模块: from PySide.QtGui import QTabWidget [as 别名]
# 或者: from PySide.QtGui.QTabWidget import setCurrentIndex [as 别名]
class Truss(QMainWindow):
def __init__(self, parent=None):
super(Truss, self).__init__(parent)
self.resize(800, 600)
self.filename = None
self.filetuple = None
self.dirty = False # Refers to Data Page only.
centralwidget = QWidget(self)
gridLayout = QGridLayout(centralwidget)
self.tabWidget = QTabWidget(centralwidget)
self.tab = QWidget()
font = QFont()
font.setFamily("Courier 10 Pitch")
font.setPointSize(12)
self.tab.setFont(font)
gridLayout_3 = QGridLayout(self.tab)
self.plainTextEdit = QPlainTextEdit(self.tab)
gridLayout_3.addWidget(self.plainTextEdit, 0, 0, 1, 1)
self.tabWidget.addTab(self.tab, "")
self.tab_2 = QWidget()
self.tab_2.setFont(font)
gridLayout_2 = QGridLayout(self.tab_2)
self.plainTextEdit_2 = QPlainTextEdit(self.tab_2)
gridLayout_2.addWidget(self.plainTextEdit_2, 0, 0, 1, 1)
self.tabWidget.addTab(self.tab_2, "")
gridLayout.addWidget(self.tabWidget, 0, 0, 1, 1)
self.setCentralWidget(centralwidget)
menubar = QMenuBar(self)
menubar.setGeometry(QRect(0, 0, 800, 29))
menu_File = QMenu(menubar)
self.menu_Solve = QMenu(menubar)
self.menu_Help = QMenu(menubar)
self.setMenuBar(menubar)
self.statusbar = QStatusBar(self)
self.setStatusBar(self.statusbar)
self.action_New = QAction(self)
self.actionSave_As = QAction(self)
self.action_Save = QAction(self)
self.action_Open = QAction(self)
self.action_Quit = QAction(self)
self.action_About = QAction(self)
self.actionShow_CCPL = QAction(self)
self.action_Solve = QAction(self)
self.action_CCPL = QAction(self)
self.action_Help = QAction(self)
menu_File.addAction(self.action_New)
menu_File.addAction(self.action_Open)
menu_File.addAction(self.actionSave_As)
menu_File.addAction(self.action_Save)
menu_File.addSeparator()
menu_File.addAction(self.action_Quit)
self.menu_Solve.addAction(self.action_Solve)
self.menu_Help.addAction(self.action_About)
self.menu_Help.addAction(self.action_CCPL)
self.menu_Help.addAction(self.action_Help)
menubar.addAction(menu_File.menuAction())
menubar.addAction(self.menu_Solve.menuAction())
menubar.addAction(self.menu_Help.menuAction())
self.setWindowTitle("Main Window")
self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab),\
"Data Page")
self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab_2),\
"Solution Page")
menu_File.setTitle("&File")
self.menu_Solve.setTitle("&Solve")
self.menu_Help.setTitle("&Help")
self.tabWidget.setCurrentIndex(0)
self.action_New.setText("&New")
self.action_Open.setText("&Open")
self.actionSave_As.setText("Save &As")
self.action_Save.setText("&Save")
self.action_Quit.setText("&Quit")
self.action_Solve.setText("&Solve")
self.action_About.setText("&About")
self.action_CCPL.setText("&CCPL")
self.action_Help.setText("&Help")
self.action_Quit.triggered.connect(self.close)
allToolBar = self.addToolBar("AllToolBar")
allToolBar.setObjectName("AllToolBar")
self.addActions(allToolBar, (self.action_Open, self.actionSave_As,\
self.action_Save, self.action_Solve,\
self.action_Quit ))
self.action_New.triggered.connect(self.fileNew)
self.action_Open.triggered.connect(self.fileOpen)
self.actionSave_As.triggered.connect(self.fileSaveAs)
self.action_Save.triggered.connect(self.fileSave)
self.action_Solve.triggered.connect(self.trussSolve)
self.action_About.triggered.connect(self.aboutBox)
self.action_CCPL.triggered.connect(self.displayCCPL)
self.action_Help.triggered.connect(self.help)
self.plainTextEdit.textChanged.connect(self.setDirty)
self.action_New = self.editAction(self.action_New, None,\
'ctrl+N', 'filenew', 'New File.')
self.action_Open = self.editAction(self.action_Open, None,
'ctrl+O', 'fileopen', 'Open File.')
self.actionSave_As = self.editAction(self.actionSave_As,\
None, 'ctrl+A', 'filesaveas',\
'Save and Name File.')
self.action_Save = self.editAction(self.action_Save, None,
'ctrl+S', 'filesave', 'Save File.')
#.........这里部分代码省略.........