Beispiel #1
0
    def loadTool(self, toolId):
        """ Load a tool by creating a dock widget containing the tool widget.
        """

        # A tool id should always be lower case
        toolId = toolId.lower()

        # Close old one
        if toolId in self._activeTools:
            old = self._activeTools[toolId].widget()
            self._activeTools[toolId].setWidget(QtGui.QWidget(iep.main))
            if old:
                old.close()
                old.deleteLater()

        # Get tool class (returns None on failure)
        toolClass = self.getToolClass(toolId)
        if toolClass is None:
            return

        # Already loaded? reload!
        if toolId in self._activeTools:
            self._activeTools[toolId].reload(toolClass)
            return

        # Obtain name from buffered list of names
        for toolDes in self._toolInfo:
            if toolDes.id == toolId:
                name = toolDes.name
                break
        else:
            name = toolId

        # Make sure there is a config entry for this tool
        if not hasattr(iep.config.tools, toolId):
            iep.config.tools[toolId] = ssdf.new()

        # Create dock widget and add in the main window
        dock = ToolDockWidget(iep.main, self)
        dock.setTool(toolId, name, toolClass)
        iep.main.addDockWidget(QtCore.Qt.RightDockWidgetArea, dock)

        # Add to list
        self._activeTools[toolId] = dock
        self.updateToolInstances()
Beispiel #2
0
    def setTabText(self, i, text):
        """ setTabText(i, text)
        
        Set the text for tab i.
        
        """
        self.tabBar().setTabText(i, text)

    def tabText(self, i):
        """ tabText(i)
        
        Get the title of the tab at index i.
        
        """
        return self.tabBar().tabText(i)


if __name__ == '__main__':

    w = CompactTabWidget()
    w.show()

    w.addTab(QtGui.QWidget(w), 'aapenootjedopje')
    w.addTab(QtGui.QWidget(w), 'aapenootjedropje')
    w.addTab(QtGui.QWidget(w), 'noot en mies')
    w.addTab(QtGui.QWidget(w), 'boom bijv een iep')
    w.addTab(QtGui.QWidget(w), 'roosemarijnus')
    w.addTab(QtGui.QWidget(w), 'vis')
    w.addTab(QtGui.QWidget(w), 'vuurvuurvuur')