本文整理汇总了Python中PySide.QtGui.QTabWidget.currentWidget方法的典型用法代码示例。如果您正苦于以下问题:Python QTabWidget.currentWidget方法的具体用法?Python QTabWidget.currentWidget怎么用?Python QTabWidget.currentWidget使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PySide.QtGui.QTabWidget
的用法示例。
在下文中一共展示了QTabWidget.currentWidget方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: SessionDetails
# 需要导入模块: from PySide.QtGui import QTabWidget [as 别名]
# 或者: from PySide.QtGui.QTabWidget import currentWidget [as 别名]
class SessionDetails(QWidget):
def __init__(self, parent = None):
super(SessionDetails, self).__init__(parent)
self.tabs = QTabWidget(self)
layout = QVBoxLayout(self)
layout.addWidget(self.tabs)
self.setMinimumSize(600, 600)
def setSession(self, session):
self.tabs.clear()
self.tabs.addTab(IntervalPage(session, self), str(session.start_time))
def setTab(self, tab):
t = self.tabs.currentWidget()
t.setTab(tab)
def addInterval(self, interval):
self.tabs.addTab(IntervalPage(interval, self), str(interval.timestamp))
示例2: window
# 需要导入模块: from PySide.QtGui import QTabWidget [as 别名]
# 或者: from PySide.QtGui.QTabWidget import currentWidget [as 别名]
#.........这里部分代码省略.........
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)
# Create a vertical layout and add widgets
vlayout = QVBoxLayout()
vlayout.setSpacing(0)
vlayout.setContentsMargins(0, 0, 0, 0)
# toolbar.addWidget(self.input_widget)
vlayout.addWidget(self.input_widget)
vlayout.addWidget(self.bookmarks_widget)
vlayout.addWidget(self.tabs_widget)
# create a widget to hold the vertical layout
wrapper_widget = QWidget()
wrapper_widget.setLayout(vlayout)
self.setCentralWidget(wrapper_widget)
self.bbutton.clicked.connect(self.tabs.currentWidget().findChild(QFrame, unicode('pageWidget')).findChild(QWebView, unicode('webView')).back)
示例3: STMainWindow
# 需要导入模块: from PySide.QtGui import QTabWidget [as 别名]
# 或者: from PySide.QtGui.QTabWidget import currentWidget [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")
示例4: Cherry
# 需要导入模块: from PySide.QtGui import QTabWidget [as 别名]
# 或者: from PySide.QtGui.QTabWidget import currentWidget [as 别名]
#.........这里部分代码省略.........
def createSamples(self):
'''Creates a given number of samples with no names or plant names.'''
samples,ok = CreateSamplesDialog.create(self)
if ok:
columns = ['Origin plate','Origin well','Plant','Sample','From plate','From well',
'Plate','Well','Experiment','Exp well','Result','Continues',]
newSamplesDF = DataFrame(samples,columns=columns)
self.markers[0].table = self.markers[0].table.append(newSamplesDF,ignore_index=True)
self.__updateView()
def createSamplesFromExcelKea(self):
'''Opens a Kea Sample Batch spreadsheet and imports the samples.'''
title = 'Locate Kea sample batch spreadsheet...'
fileName,f = QFileDialog.getOpenFileName(self,title,self.path)
excelFile = ExcelFile(fileName)
imported = excelFile.parse('Data')
imported = imported[['PlantID','Sample ID','Plate No','Position on Plate(s)']]
imported.columns = ['Plant','Sample','Origin plate','Origin well']
imported = imported.dropna(how='all',subset=['Origin plate','Origin well'])
imported['From plate'] = imported['Origin plate']
imported['From well'] = imported['Origin well']
imported['Plate'] = imported['Origin plate']
imported['Well'] = imported['Origin well']
self.markers[0].table = self.markers[0].table.append(imported,ignore_index=True)
self.__updateView()
########################################################################
## Marker Menu Actions
def addMarker(self):
'''Prompts for marker name and samples, and adds a new tab containing
the marker's information table.'''
newMarker,includeAll,controls,ok = NewMarkerDialog.run()
if ok:
marker = self.tabs.currentWidget()
samples = marker.getContinues(getAll=includeAll)
samples.columns = ['Origin plate','Origin well','From plate','From well','Plant','Sample','Continues']
newTable = Table(newMarker,samples=samples)
newTable.addPlateAndWell(controls,getAll=includeAll)
self.markers.append(newTable)
self.tabs.addTab(self.markers[-1],self.markers[-1].name)
self.__updateView()
def createPlateSheets(self):
'''Generates platesheets for current marker.'''
marker = self.tabs.currentWidget().table
if marker.loc[0,'From plate'] == marker.loc[0,'Plate']:
text = 'The source and destination plates are the same.'
QMessageBox.information(self,'Unnecessary',text,QMessageBox.Ok)
else:
title = 'Excel filename...'
exportFileName,f = QFileDialog.getSaveFileName(self,title,self.path)
workBook = PlateSheets()
workBook.addPlateSheets(marker,'Destination','Plate','Well','From plate','From well')
workBook.addPlateSheets(marker,'Source','From plate','From well','Plate','Well')
workBook.save(exportFileName+'.xls')
def importLightcyclerFile(self):
'''Imports Lightcycler .txt files and adds the results, locating
samples by plate name (taken from filename) and well.'''
title = 'Import LC file(s)...'
filter_mask = 'Lightcycler text files (*.txt)'
lightFileNames,f = QFileDialog.getOpenFileNames(self,title,self.path,filter_mask)
marker = self.tabs.currentWidget()
fileDataLists,ok = LCDialog.importLC(lightFileNames)
if ok:
marker.addLCFiles(fileDataLists)
示例5: FormWidget
# 需要导入模块: from PySide.QtGui import QTabWidget [as 别名]
# 或者: from PySide.QtGui.QTabWidget import currentWidget [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()