当前位置: 首页>>代码示例>>Python>>正文


Python QTabWidget.addTab方法代码示例

本文整理汇总了Python中PySide.QtGui.QTabWidget.addTab方法的典型用法代码示例。如果您正苦于以下问题:Python QTabWidget.addTab方法的具体用法?Python QTabWidget.addTab怎么用?Python QTabWidget.addTab使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PySide.QtGui.QTabWidget的用法示例。


在下文中一共展示了QTabWidget.addTab方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from PySide.QtGui import QTabWidget [as 别名]
# 或者: from PySide.QtGui.QTabWidget import addTab [as 别名]
 def __init__(self, parent=None):
     '''
     Constructor
     '''
     QDialog.__init__(self, parent)
     self._ui = Ui_CreditsDialog()
     self._ui.setupUi(self)
     
     creditsTab = QTabWidget()
     creditSections = info.CREDITS.keys()
     for creditSection in creditSections:
         creditTab = QWidget()
         creditsTab.addTab(creditTab, creditSection)
         vbox = QVBoxLayout(creditTab)
         creditList = ""
         for person in info.CREDITS[creditSection]:
             creditList += ("\n%s [%s]" % (person['name'], person['email']))
         creditLabel = QLabel()
         creditLabel.setStyleSheet("QLabel { background-color : white}")
         creditLabel.setText(creditList)
         creditLabel.setAlignment(Qt.AlignTop | Qt.AlignLeft)
         vbox.addWidget(creditLabel)
     
     vbox = QVBoxLayout()
     vbox.setContentsMargins(0, 0, 0, 0)
     vbox.addWidget(creditsTab)
     self._ui.frame_CreditsTab.setLayout(vbox)
开发者ID:MusculoskeletalAtlasProject,项目名称:mapclient-src,代码行数:29,代码来源:creditsdialog.py

示例2: setup_ui

# 需要导入模块: from PySide.QtGui import QTabWidget [as 别名]
# 或者: from PySide.QtGui.QTabWidget import addTab [as 别名]
    def setup_ui(self):
        """ Construct the UI for the dialog.

        """
        tab_widget = QTabWidget()

        general_widget = QWidget()
        general_layout = QVBoxLayout()

        general_layout.addWidget(self.setup_general_server_group())
        general_widget.setLayout(general_layout)
        tab_widget.addTab(general_widget, 'General')

        advanced_widget = QWidget()
        advanced_layout = QVBoxLayout()

        warning_label = QLabel('Caution: Changing these settings can potentially break the application.')
        warning_label.setStyleSheet('QLabel { color: red; }')
        advanced_layout.addWidget(warning_label)

        advanced_layout.addWidget(self.setup_advanced_server_group())
        advanced_layout.addWidget(self.setup_advanced_storage_group())
        advanced_widget.setLayout(advanced_layout)
        tab_widget.addTab(advanced_widget, 'Advanced')

        layout = QVBoxLayout()
        layout.addWidget(tab_widget)
        self.setLayout(layout)
开发者ID:brett-patterson,项目名称:d-clock,代码行数:30,代码来源:preferences_dialog.py

示例3: addTab

# 需要导入模块: from PySide.QtGui import QTabWidget [as 别名]
# 或者: from PySide.QtGui.QTabWidget import addTab [as 别名]
 def addTab(self, name ):
     
     newWidget = QWidget()
     layout = QVBoxLayout( newWidget )
     labelEmpty = QLabel(); labelEmpty.setMinimumHeight(5)
     buttonDelete = QPushButton( "Delete Tab" )
     layout.addWidget( labelEmpty )
     layout.addWidget( buttonDelete )
     QTabWidget.addTab( self, newWidget, name )
     
     QtCore.QObject.connect( buttonDelete, QtCore.SIGNAL( 'clicked()' ), self.deleteTab )
开发者ID:jonntd,项目名称:mayadev-1,代码行数:13,代码来源:createRenderLayer.py

示例4: MainWindow

# 需要导入模块: from PySide.QtGui import QTabWidget [as 别名]
# 或者: from PySide.QtGui.QTabWidget import addTab [as 别名]
class MainWindow(QMainWindow):
    def __init__(self):
        QMainWindow.__init__(self)
        self.setupUi()

    def setupUi(self):
        self.setWindowTitle('Tab Test')
        self.tabs = QTabWidget(self)
        self.setCentralWidget(self.tabs)
        # QMainWindow inherits QWidget, thus it can simply be added as child
        # widget
        tab = ToolbarTabWidget()
        self.tabs.addTab(tab, 'spam')
开发者ID:MiguelCarrilhoGT,项目名称:snippets,代码行数:15,代码来源:toolbar_in_tabs.py

示例5: Console

# 需要导入模块: from PySide.QtGui import QTabWidget [as 别名]
# 或者: from PySide.QtGui.QTabWidget import addTab [as 别名]
class Console():
    def __init__(self, targetLayoutContainer):
        self.textarea = QTextEdit()
        self.commits = QListWidget()
        
        self.commits.addAction(QAction('Rollback to this revision', self.commits, triggered=self.rollback))
        self.commits.setContextMenuPolicy(Qt.ActionsContextMenu)
        
        self.widget = QTabWidget()
        self.widget.addTab(self.textarea, 'Log')
        self.widget.addTab(self.commits, 'Commits')
        
        targetLayoutContainer.addWidget(self.widget)
        
    def color(self, module, function, color,  *args):
        print module, function, args
        
        prettyString = '<font color="' + color + '"><b>', module, '</b><i>::', function, '</i> --> ', ''.join(args), '</font>'
        self.textarea.append(''.join(prettyString))    
        
    def info(self, module, function, *args):
        print module, function, args
        
        prettyString = '<font color="black"><b>', module, '</b><i>::', function, '</i> --> ', ''.join(args), '</font>'
        self.textarea.append(''.join(prettyString))
        
    def error(self, module, function, *args):
        print module, function, args
        
        prettyString = '<font color="red"><b>', module, '</b><i>::', function, '</i> --> ', ''.join(args), '</font>'
        self.textarea.append(''.join(prettyString))
        
    def warn(self, module, function, *args):
        print module, function, args
        
        prettyString = '<font color="#BE9900"><b>', module, '</b><i>::', function, '</i> --> ', ''.join(args), '</font>'
        self.textarea.append(''.join(prettyString))
        
    def set_commits(self, commits):
        self.commits.clear()
        
        for commit in commits:
            self.commits.addItem(commit)
            
    def clear(self):
        self.textarea.clear()
        
    def rollback(self):
        targetCommit = self.commits.currentItem().text().split(' ')[0]
        if QMessageBox.warning(None, 'Rollback to commit?', 'All commits after ' + targetCommit + ' will be lost, proceed?', QMessageBox.Yes, QMessageBox.No) == QMessageBox.Yes:
            rollback(targetCommit)
开发者ID:cefolger,项目名称:favorites,代码行数:53,代码来源:console.py

示例6: MultiRenderPropWidget

# 需要导入模块: from PySide.QtGui import QTabWidget [as 别名]
# 或者: from PySide.QtGui.QTabWidget import addTab [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, "Mix")
		self.tabWidget.addTab(self.transformParamWidget, "Transformation")
		self.tabWidget.addTab(self.registrationHistoryWidget, "History")
		self.tabWidget.addTab(self.slicesTabWidget, "Slices")

		layout = QVBoxLayout()
		self.setLayout(layout)
		layout.addWidget(self.tabWidget)

		self.registrationHistoryWidget.setMultiRenderWidget(multiRenderController.multiRenderWidget)
开发者ID:rcockbur,项目名称:3DMedicalVisualizationTool,代码行数:29,代码来源:MultiRenderPropWidget.py

示例7: ManagerWindow

# 需要导入模块: from PySide.QtGui import QTabWidget [as 别名]
# 或者: from PySide.QtGui.QTabWidget import addTab [as 别名]
class ManagerWindow(QMainWindow):
    """
    This is the Add-on Manager's custom window. Not much else to say, really.
    """

    def __init__(self, parent=None):
        super(ManagerWindow, self).__init__(parent)

        # Set the window title and size.
        self.setWindowTitle(self.tr("Add-on Manager"))
        self.setMinimumSize(400, 300)

        # Build the main widget.
        self.tabs = QTabWidget(self)
        self.setCentralWidget(self.tabs)

        # Load up all our tabs.
        for addon_type in sorted(addons.manager._types.keys()):
            tab = AddonTypeTab(addon_type)
            self.tabs.addTab(tab, tab.windowIcon(), tab.windowTitle())

        # Let plugins get in on this.
        plugins.run_signal('opened_addon_manager', self)

        # Icons and Style!
        #style.enable_aero(self)
        self.reload_icons()
        style.style_reloaded.connect(self.reload_icons)
        

    def reload_icons(self):
        """ Reload all of our icons. Which is... one icon. """
        self.setWindowIcon(style.icon('addon-manager'))

    def showRaise(self):
        """ Show and raise the window. """
        self.show()
        self.raise_()
        self.setFocus()

    ##### The Close Event #####################################################

    def closeEvent(self, event):
        """ Disconnect any signals and remove our reference. """
        global _manager_window
        if _manager_window is self:
            _manager_window = None

        style.style_reloaded.disconnect(self.reload_icons)
        plugins.run_signal('closed_addon_manager', self)
开发者ID:gitter-badger,项目名称:a2,代码行数:52,代码来源:ui.py

示例8: SessionDetails

# 需要导入模块: from PySide.QtGui import QTabWidget [as 别名]
# 或者: from PySide.QtGui.QTabWidget import addTab [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))
开发者ID:JanDeVisser,项目名称:Grumble,代码行数:20,代码来源:sessiontab.py

示例9: MultiRenderPropWidget

# 需要导入模块: from PySide.QtGui import QTabWidget [as 别名]
# 或者: from PySide.QtGui.QTabWidget import addTab [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
开发者ID:berendkleinhaneveld,项目名称:Registrationshop,代码行数:51,代码来源:MultiRenderPropWidget.py

示例10: __init__

# 需要导入模块: from PySide.QtGui import QTabWidget [as 别名]
# 或者: from PySide.QtGui.QTabWidget import addTab [as 别名]
    def __init__(self, parent, settings):
        QDialog.__init__( self, parent )

        self.settings = settings

        tabWidget = QTabWidget()

        #Representations
        self.repWidget = RepresentationPane(self.settings.get_rep_settings())

        tabWidget.addTab(self.repWidget,'Representations')


        #Network Tab

        self.networkWidget = NetworkPane(self.settings.get_network_settings())
        tabWidget.addTab(self.networkWidget, 'Network')


        self.specWidget = SpecgramPane(self.settings.get_specgram_settings())
        tabWidget.addTab(self.specWidget,'Spectrogram')


        layout = QVBoxLayout()
        layout.addWidget(tabWidget)

        #Accept cancel
        self.acceptButton = QPushButton('Ok')
        self.cancelButton = QPushButton('Cancel')

        self.acceptButton.clicked.connect(self.accept)
        self.cancelButton.clicked.connect(self.reject)

        hbox = QHBoxLayout()
        hbox.addWidget(self.acceptButton)
        hbox.addWidget(self.cancelButton)
        ac = QWidget()
        ac.setLayout(hbox)
        layout.addWidget(ac)

        self.setLayout(layout)

        self.network_changed = False
        self.rep_changed = False
        self.specgram_changed = False
开发者ID:mmcauliffe,项目名称:exemplar-network-explorer,代码行数:47,代码来源:config.py

示例11: __init__

# 需要导入模块: from PySide.QtGui import QTabWidget [as 别名]
# 或者: from PySide.QtGui.QTabWidget import addTab [as 别名]
    def __init__(self):
        super(Caerus, self).__init__()

        self.exit_cb = None

        self.status_bar = self.statusBar()

        self.exit_app = QAction(self.tr("Exit"), self)

        self.file_menu = self.menuBar().addMenu("&File")
        self.file_menu.addAction(self.exit_app)

        self.employers = Employers(self,
                                   [self.tr("ID"),
                                    self.tr("Name"),
                                    self.tr("Street Address"),
                                    self.tr("City"),
                                    self.tr("State"),
                                    self.tr("Zip Code"),
                                    self.tr("Phone Number"),
                                    self.tr("E-mail Address"),
                                    self.tr("Contact Person")])

        self.employees = Employees(self,
                                   [self.tr("ID"),
                                    self.tr("First Name"),
                                    self.tr("Last Name"),
                                    self.tr("E-mail Address"),
                                    self.tr("Phone Number"),
                                    self.tr("Cell Number"),
                                    self.tr("Street Address"),
                                    self.tr("City"),
                                    self.tr("State"),
                                    self.tr("Zip Code")])

        self.reports = Reports(self)

        context = QTabWidget(self)

        context.addTab(self.employers, self.tr("Workplaces"))
        context.addTab(self.employees, self.tr("Employees"))
        context.addTab(self.reports,   self.tr("Reports"))

        self.setCentralWidget(context)
开发者ID:xiphffff,项目名称:Caerus,代码行数:46,代码来源:caerus.py

示例12: __init__

# 需要导入模块: from PySide.QtGui import QTabWidget [as 别名]
# 或者: from PySide.QtGui.QTabWidget import addTab [as 别名]
    def __init__(self, client, method):
        super(Tab, self).__init__(None)

        self.client = client
        self.method = method

        horiz = QHBoxLayout(self)
        
        left = QWidget()
        
        horiz.addWidget(left)
        
        layout = QFormLayout(left)
        
        self.fields = []
        for param in method[1]:
            field = QLineEdit()
            self.fields.append(field)
            layout.addRow(param[0], field)

        button = QPushButton("Execute Web Service")
        button.clicked.connect(self.execute)
        layout.addWidget(button)
        
        display = QTabWidget()
        
        self.result = QTextBrowser()
        display.addTab(self.result, "Result")
        
        self.request = QTextBrowser()
        display.addTab(self.request, "Request", )
        
        self.response = QTextBrowser()
        display.addTab(self.response, "Response")
        
        horiz.addWidget(display)
开发者ID:michaelballantyne,项目名称:py-ws-client,代码行数:38,代码来源:pywscclient.py

示例13: uiManager

# 需要导入模块: from PySide.QtGui import QTabWidget [as 别名]
# 或者: from PySide.QtGui.QTabWidget import addTab [as 别名]
class uiManager(QMainWindow):
	def __init__(self):
		super(uiManager, self).__init__()

		self.setMinimumSize(900,500)
		self.setWindowTitle("Manage")

		self.aFileModel = FileModel() # Add files
		self.sFileModel = FileModel() # Queried files
		self.eFileModel = FileModel() # Editing files

		self.tabWidget = QTabWidget()
		self.setCentralWidget(self.tabWidget)

		self.defActions()

		self.addTab()
		self.searchTab()
		self.editTab()
		self.testtab()

		self.statusBar().showMessage("Hi.")


	def defActions(self):
		self.findAct = QAction("+", self, triggered=self.findFilesDlg)
		self.dropAddTabAct = QAction("-", self, shortcut="Delete",
			triggered=self.dropAddTabRows)
		self.dropEditTabAct = QAction("-", self, shortcut="Delete",
			triggered=self.dropEditTabRows)


	def dropEditTabRows(self):
		self.dropFiles(self.eFileTable, self.eFileModel)


	def dropAddTabRows(self):
		self.dropFiles(self.aFileTable, self.aFileModel)


	def testtab(self):
		self.test = QWidget()
		self.tabWidget.addTab(self.test, "WORDS")
		self.tabWidget.setCornerWidget(self.test)


	def addTab(self):

		self.aFileTable = QTableView()
		self.aFileTable.setModel(self.aFileModel)
		self.aFileTable.setSelectionBehavior(QAbstractItemView.SelectRows)

		self.setColumnsWidths(self.aFileTable)

		self.addWidget = QWidget()

		vLayout = QVBoxLayout()
		vLayout.addWidget(self.aFileTable)

		addBtn = QToolButton()
		addBtn.setDefaultAction(self.findAct)
		# addBtn.clicked.connect(self.findFilesDlg)

		dropBtn = QToolButton()
		dropBtn.setDefaultAction(self.dropAddTabAct)
		# rmvBtn.clicked.connect(self.rmvFiles)

		insBtn = QPushButton("Track")
		insBtn.clicked.connect(self.insert)

		hLayout = QHBoxLayout()

		hLayout.addWidget(addBtn)
		hLayout.addWidget(dropBtn)
		hLayout.addStretch(1)		
		hLayout.addWidget(insBtn)

		vLayout.addLayout(hLayout)

		self.addWidget.setLayout(vLayout)

		self.tabWidget.addTab(self.addWidget, u"Add")


	def searchTab(self):

		# sFileModel + view tab
		self.sFileTable = QTableView()
		self.sFileTable.setModel(self.sFileModel)
		self.sFileTable.setEditTriggers(QAbstractItemView.NoEditTriggers)
		self.sFileTable.setSelectionBehavior(QAbstractItemView.SelectRows)

		self.setColumnsWidths(self.sFileTable)

		self.searchWidget = QWidget()

		# Horizontal layout
		# Button, Line Edit, Button
		hLayout = QHBoxLayout()
		self.searchBox = QLineEdit()
#.........这里部分代码省略.........
开发者ID:jogden88,项目名称:TagFileManager,代码行数:103,代码来源:managerui.py

示例14: FormWidget

# 需要导入模块: from PySide.QtGui import QTabWidget [as 别名]
# 或者: from PySide.QtGui.QTabWidget import addTab [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()
开发者ID:JanDeVisser,项目名称:Grumble,代码行数:102,代码来源:bridge.py

示例15: STMainWindow

# 需要导入模块: from PySide.QtGui import QTabWidget [as 别名]
# 或者: from PySide.QtGui.QTabWidget import addTab [as 别名]
class STMainWindow(QMainWindow):
    def __init__(self):
        super(STMainWindow, self).__init__()
        self.createActions()
        self.createMenus()
        layout = QVBoxLayout()
        self.tabs = QTabWidget()
        self.tabs.setTabPosition(QTabWidget.West)
        self.tabs.currentChanged[int].connect(self.tabChanged)
        self.sessiontab = sweattrails.qt.sessiontab.SessionTab(self)
        self.tabs.addTab(self.sessiontab, "Sessions")
        self.tabs.addTab(sweattrails.qt.fitnesstab.FitnessTab(self),
                         "Fitness")
        self.tabs.addTab(sweattrails.qt.profiletab.ProfileTab(self),
                         "Profile")
        self.usertab = sweattrails.qt.usertab.UserTab(self)
        self.tabs.addTab(self.usertab, "Users")
        self.usertab.hide()
        layout.addWidget(self.tabs)
        w = QWidget(self)
        w.setLayout(layout)
        self.setCentralWidget(w)
        self.statusmessage = QLabel()
        self.statusmessage.setMinimumWidth(200)
        self.statusBar().addPermanentWidget(self.statusmessage)
        self.progressbar = QProgressBar()
        self.progressbar.setMinimumWidth(100)
        self.progressbar.setMinimum(0)
        self.progressbar.setMaximum(100)
        self.statusBar().addPermanentWidget(self.progressbar)
        self.setWindowTitle("SweatTrails")
        self.setWindowIconText("SweatTrails")
        icon = QPixmap("image/sweatdrops.png")
        self.setWindowIcon(QIcon(icon))
        QCoreApplication.instance().refresh.connect(self.userSet)


    def createActions(self):
        self.switchUserAct = QAction("&Switch User", self, shortcut = "Ctrl+U", statusTip = "Switch User", triggered = self.switch_user)
        self.importFileAct = QAction("&Import", self, shortcut = "Ctrl+I", statusTip = "Import Session", triggered = self.file_import)
        self.downloadAct = QAction("&Download", self, shortcut = "Ctrl+D",
                                   statusTip = "Download activities from device",
                                   triggered = QCoreApplication.instance().download)
        self.downloadAct = QAction("&Withings", self,
                                   statusTip = "Download Withings data",
                                   triggered = QCoreApplication.instance().withings)
        self.exitAct = QAction("E&xit", self, shortcut = "Ctrl+Q", statusTip = "Exit SweatTrails", triggered = self.close)

        self.aboutAct = QAction("&About", self, triggered = self.about)
        self.aboutQtAct = QAction("About &Qt", self, triggered = QApplication.aboutQt)


    def createMenus(self):
        self.fileMenu = self.menuBar().addMenu(self.tr("&File"))
        self.fileMenu.addAction(self.switchUserAct)
        self.fileMenu.addSeparator()
        self.fileMenu.addAction(self.importFileAct)
        self.fileMenu.addAction(self.downloadAct)
        self.fileMenu.addSeparator()
        self.fileMenu.addAction(self.exitAct)

        self.menuBar().addSeparator()

        self.helpMenu = self.menuBar().addMenu("&Help")
        self.helpMenu.addAction(self.aboutAct)
        self.helpMenu.addAction(self.aboutQtAct)


    def show(self):
        super(QMainWindow, self).show()
        if self.select_user():
            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

    #
#.........这里部分代码省略.........
开发者ID:JanDeVisser,项目名称:Grumble,代码行数:103,代码来源:mainwindow.py


注:本文中的PySide.QtGui.QTabWidget.addTab方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。