Beispiel #1
0
 def removeTab(self, which):
     """ removeTab(which)
     
     Removes the specified tab. which can be an integer, an item,
     or an editor.
     
     """
     
     # Init
     items = self.items()
     theIndex = -1
     
     # Find index
     if isinstance(which, int) and which>=0 and which<len(items):
         theIndex = which
     
     elif isinstance(which, FileItem):
         for i in range(self.count()):
             if items[i] is which:
                 theIndex = i
                 break
     
     elif isinstance(which, str):
         for i in range(self.count()):
             if items[i].filename == which:
                 theIndex = i
                 break
     
     elif hasattr(which, '_filename'):
         for i in range(self.count()):
             if items[i].filename == which._filename:
                 theIndex = i
                 break
     
     else:
         raise ValueError('removeTab accepts a FileItem, integer, file name, or editor.')
     
     
     if theIndex >= 0:
         
         # Close tab
         CompactTabWidget.removeTab(self, theIndex)
         
         # Delete editor
         items[theIndex].editor.destroy()
         gc.collect()
Beispiel #2
0
 def removeTab(self, which):
     """ removeTab(which)
     
     Removes the specified tab. which can be an integer, an item,
     or an editor.
     
     """
     
     # Init
     items = self.items()
     theIndex = -1
     
     # Find index
     if isinstance(which, int) and which>=0 and which<len(items):
         theIndex = which
     
     elif isinstance(which, FileItem):
         for i in range(self.count()):
             if items[i] is which:
                 theIndex = i
                 break
     
     elif isinstance(which, str):
         for i in range(self.count()):
             if items[i].filename == which:
                 theIndex = i
                 break
     
     elif hasattr(which, '_filename'):
         for i in range(self.count()):
             if items[i].filename == which._filename:
                 theIndex = i
                 break
     
     else:
         raise ValueError('removeTab accepts a FileItem, integer, file name, or editor.')
     
     
     if theIndex >= 0:
         
         # Close tab
         CompactTabWidget.removeTab(self, theIndex)
         
         # Delete editor
         items[theIndex].editor.destroy()
         gc.collect()
Beispiel #3
0
    def __init__(self, parent):
        CompactTabWidget.__init__(self, parent, padding=(2,1,0,4))
        
        # Init main file
        self._mainFile = ''
        
        # Init item history
        self._itemHistory = []
        
#         # Create a corner widget
#         but = QtGui.QToolButton()
#         but.setIcon( iep.icons.cross )
#         but.setIconSize(QtCore.QSize(16,16))
#         but.clicked.connect(self.onClose)
#         self.setCornerWidget(but)
                
        # Bind signal to update items and keep track of history
        self.currentChanged.connect(self.updateItems)
        self.currentChanged.connect(self.trackHistory)
        self.currentChanged.connect(self.setTitleInMainWindowWhenTabChanged)
        self.setTitleInMainWindowWhenTabChanged(-1)
Beispiel #4
0
    def __init__(self, parent):
        CompactTabWidget.__init__(self, parent, padding=(2,1,0,4))
        
        # Init main file
        self._mainFile = ''
        
        # Init item history
        self._itemHistory = []
        
#         # Create a corner widget
#         but = QtGui.QToolButton()
#         but.setIcon( iep.icons.cross )
#         but.setIconSize(QtCore.QSize(16,16))
#         but.clicked.connect(self.onClose)
#         self.setCornerWidget(but)
                
        # Bind signal to update items and keep track of history
        self.currentChanged.connect(self.updateItems)
        self.currentChanged.connect(self.trackHistory)
        self.currentChanged.connect(self.setTitleInMainWindowWhenTabChanged)
        self.setTitleInMainWindowWhenTabChanged(-1)