Exemplo n.º 1
0
 def editItem(self, item):
     """
     Edit the widget item.
     @see: self.insertItems for a comment 
     @see: self.renameItemValue()
     @self.editItem() (This is a QListWidget method
     """
     #explicitely set the flag to False for safety. 
     self._suppress_itemChanged_signal = False
     PM_ListWidget.editItem(self, item)
 def editItem(self, item):
     """
     Edit the widget item.
     @see: self.insertItems for a comment 
     @see: self.renameItemValue()
     @self.editItem() (This is a QListWidget method
     """
     #explicitely set the flag to False for safety. 
     self._supress_itemChanged_signal = False
     PM_ListWidget.editItem(self, item)
Exemplo n.º 3
0
    def clear(self):
        """
        Clear everything inside this list widget including the 
        contents of self._itemDictionary and tags if any. 

        Overrides QListWidget.clear()
        """
        self.clearTags()

        #Clear the previous contents of the self._itemDictionary 
        self._itemDictionary.clear()

        #Clear the contents of this list widget, using QListWidget.clear()
        #See U{<http://doc.trolltech.com/4.2/qlistwidget.html>} for details
        PM_ListWidget.clear(self)
    def clear(self):
        """
        Clear everything inside this list widget including the 
        contents of self._itemDictionary and tags if any. 

        Overrides QListWidget.clear()
        """
        self.clearTags()

        #Clear the previous contents of the self._itemDictionary 
        self._itemDictionary.clear()

        #Clear the contents of this list widget, using QListWidget.clear()
        #See U{<http://doc.trolltech.com/4.2/qlistwidget.html>} for details
        PM_ListWidget.clear(self)
Exemplo n.º 5
0
 def _loadPM_ListWidget(self, inPmGroupBox):
     """
     PM_ListWidget.
     """
     
     items = ["Item 1", "Item 2", "Item 3", "Item 4", "Item 5", "Item 6"]
     
     self.listWidget1 = \
         PM_ListWidget( inPmGroupBox, 
                      label        = "Items to select (label on top):",
                      items        = items, 
                      defaultRow   = 0, 
                      setAsDefault = False,
                      heightByRows = 4, 
                      spanWidth    = True )
     
     self.listWidget2 = \
         PM_ListWidget( inPmGroupBox, 
                      label        = "Items:",
                      items        = items, 
                      defaultRow   = 0, 
                      setAsDefault = False,
                      heightByRows = 4, 
                      spanWidth    = False )
Exemplo n.º 6
0
    def __init__(self, 
                 parentWidget, 
                 win,
                 label = '',
                 color = None,
                 heightByRows = 6, 
                 spanWidth    = False):
        """
        Appends a QListWidget (Qt) widget to the I{parentWidget}, 
        a Property Manager group box. This is a selection list widget, that 
        means if you select the items in this list widget, the corresponding
        item in the GLPane will be tagged or picked or both depending on the 
        'tag instructions' 

        @param parentWidget: The parent group box containing this widget.
        @type  parentWidget: PM_GroupBox

        @param win: Mainwindow object
        @type win: MWSemantics

        @param label: The label that appears to the left or right of the 
                      checkbox. 

                      If spanWidth is True, the label will be displayed on
                      its own row directly above the list widget.

                      To suppress the label, set I{label} to an 
                      empty string.
        @type  label: str

        @param color: color of the ListWidget
        @type : Array

        @param heightByRows: The height of the list widget.
        @type  heightByRows: int

        @param spanWidth: If True, the widget and its label will span the width
                          of the group box. Its label will appear directly above
                          the widget (unless the label is empty) and is left 
                          justified.
        @type  spanWidth: bool

        @see: U{B{QListWidget}<http://doc.trolltech.com/4/qlistwidget.html>}

        """ 

        self.win = win
        self.glpane = self.win.glpane

        #Note: self._tagInstruction and  self._itemDictionary  are instance 
        #variables and not class constants as we 
        #have many PM_SelectionListWidget objects (e.g. in Build Dna mode, we 
        # have Srand and Segment list widgets. Defining self._itemDictionary
        #as a class constant will make class objects share it and create bugs.
        self._tagInstruction = 'TAG_ITEM_IN_GLPANE'
        self._itemDictionary = {}

        #The following flag suppresses the itemSelectionChanged signal
        #see self.updateSelection for more comments. 
        self._suppress_itemSelectionChanged_signal = False

        #The following flag suppresses the itemChanged signal
        #ItemChanged signal is emitted too frequently. We use this to know that
        #the data of an item has changed...example : to know that the renaming
        #operation of the widget is completed. When a widgetItem is renamed, 
        #we want to rename the corresponding object in the glpane (which is 
        #stored as a value in self._itemDictionary) As of 2008-04-16 this signal
        #is the most convienent way to do it (in Qt4.2.3). If this flag 
        #is set to False, it simply returns from the method that gets called 
        #when itemItemChanged signal is sent. The flag is set to True
        #while updating items in self.isertItems. When itemDoubleClicked signal
        #is sent, the flag is explicitely set to False -- Ninad 2008-04-16
        #@see: self.renameItemValue(), 
        #@self.editItem() (This is a QListWidget method)
        self._suppress_itemChanged_signal = False

        PM_ListWidget.__init__(self, 
                               parentWidget, 
                               label = '',
                               heightByRows = heightByRows,
                               spanWidth = spanWidth)

        self.setSelectionMode(QAbstractItemView.ExtendedSelection)

        #Assigning color to the widget -- to be revised. (The color should 
        #change only when the focus is inside this widget -- the color change
        #will also suggest object(s) selected in glpane will be added as 
        #items in this widget (could be a  selective addition depending on 
        # the use) -- Niand 2007-11-12
        if color:
            self.setAutoFillBackground(True)
            self.setPalette(getPalette( None, 
                                        QPalette.Base,
                                        color))
    def __init__(self, 
                 parentWidget, 
                 win,
                 label = '',
                 color = None,
                 heightByRows = 6, 
                 spanWidth    = False):
        """
        Appends a QListWidget (Qt) widget to the I{parentWidget}, 
        a Property Manager group box. This is a selection list widget, that 
        means if you select the items in this list widget, the corresponding
        item in the GLPane will be tagged or picked or both depending on the 
        'tag instructions' 

        @param parentWidget: The parent group box containing this widget.
        @type  parentWidget: PM_GroupBox

        @param win: Mainwindow object
        @type win: MWSemantics

        @param label: The label that appears to the left or right of the 
                      checkbox. 

                      If spanWidth is True, the label will be displayed on
                      its own row directly above the list widget.

                      To suppress the label, set I{label} to an 
                      empty string.
        @type  label: str

        @param color: color of the ListWidget
        @type : Array

        @param heightByRows: The height of the list widget.
        @type  heightByRows: int

        @param spanWidth: If True, the widget and its label will span the width
                          of the group box. Its label will appear directly above
                          the widget (unless the label is empty) and is left 
                          justified.
        @type  spanWidth: bool

        @see: U{B{QListWidget}<http://doc.trolltech.com/4/qlistwidget.html>}

        """ 

        self.win = win
        self.glpane = self.win.glpane

        #Note: self._tagInstruction and  self._itemDictionary  are instance 
        #variables and not class constants as we 
        #have many PM_SelectionListWidget objects (e.g. in Build Dna mode, we 
        # have Srand and Segment list widgets. Defining self._itemDictionary
        #as a class constant will make class objects share it and create bugs.
        self._tagInstruction = 'TAG_ITEM_IN_GLPANE'
        self._itemDictionary = {}

        #The following flag supresses the itemSelectionChanged signal
        #see self.updateSelection for more comments. 
        self._supress_itemSelectionChanged_signal = False

        #The following flag supresses the itemChanged signal
        #ItemChanged signal is emitted too frequently. We use this to know that
        #the data of an item has changed...example : to know that the renaming
        #operation of the widget is completed. When a widgetItem is renamed, 
        #we want to rename the corresponding object in the glpane (which is 
        #stored as a value in self._itemDictionary) As of 2008-04-16 this signal
        #is the most convienent way to do it (in Qt4.2.3). If this flag 
        #is set to False, it simply returns from the method that gets called 
        #when itemItemChanged signal is sent. The flag is set to True
        #while updating items in self.isertItems. When itemDoubleClicked signal
        #is sent, the flag is explicitely set to False -- Ninad 2008-04-16
        #@see: self.renameItemValue(), 
        #@self.editItem() (This is a QListWidget method)
        self._supress_itemChanged_signal = False

        PM_ListWidget.__init__(self, 
                               parentWidget, 
                               label = '',
                               heightByRows = heightByRows,
                               spanWidth = spanWidth)

        self.setSelectionMode(QAbstractItemView.ExtendedSelection)

        #Assigning color to the widget -- to be revised. (The color should 
        #change only when the focus is inside this widget -- the color change
        #will also suggest object(s) selected in glpane will be added as 
        #items in this widget (could be a  selective addition depending on 
        # the use) -- Niand 2007-11-12
        if color:
            self.setAutoFillBackground(True)
            self.setPalette(getPalette( None, 
                                        QPalette.Base,
                                        color))