Example #1
0
 def getCmdMgrCtrlAreaPalette(self):
     """ Return a palette for Command Manager control area
     (Palette for Tool Buttons in command toolbar control area)
     """
     #See comment at the top for details about this flag
     if DEFINE_CONTROL_AREA_AS_A_QWIDGET:
         return getPalette(None, QPalette.Window, cmdTbarCntrlAreaBtnColor)
     else:
         return getPalette(None, QPalette.Button, cmdTbarCntrlAreaBtnColor)
    def _loadTextEditWidget(self):
        """
        Load the SequenceTexteditWidgets.
        """
        self.aaRulerTextEdit = \
            PM_TextEdit( self,
                         label = "",
                         spanWidth = False,
                         permit_enter_keystroke = False)

        palette = getPalette(None,
                             QPalette.Base,
                             pmGrpBoxColor)
        self.aaRulerTextEdit.setPalette(palette)
        self.aaRulerTextEdit.setWordWrapMode( QTextOption.WrapAnywhere )
        self.aaRulerTextEdit.setFixedHeight(20)
        self.aaRulerTextEdit.setReadOnly(True)

        self.sequenceTextEdit = \
            PM_TextEdit( self,
                         label = " Sequence: ",
                         spanWidth = False,
                         permit_enter_keystroke = False)
        #self.sequenceTextEdit.setReadOnly(True) #@@@

        self.sequenceTextEdit.setCursorWidth(2)
        self.sequenceTextEdit.setWordWrapMode( QTextOption.WrapAnywhere )
        self.sequenceTextEdit.setFixedHeight(20)

        self.secStrucTextEdit = \
            PM_TextEdit( self,
                         label = " Secondary structure: ",
                         spanWidth = False,
                         permit_enter_keystroke = False)

        palette = getPalette(None,
                             QPalette.Base,
                             sequenceEditStrandMateBaseColor)
        self.secStrucTextEdit.setPalette(palette)
        self.secStrucTextEdit.setWordWrapMode( QTextOption.WrapAnywhere )
        self.secStrucTextEdit.setFixedHeight(20)
        self.secStrucTextEdit.setReadOnly(True)

        #Important to make sure that the horizontal and vertical scrollbars
        #for these text edits are never displayed.

        self.sequenceTextEdit.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        self.sequenceTextEdit.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        self.secStrucTextEdit.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        self.secStrucTextEdit.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        self.aaRulerTextEdit.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        self.aaRulerTextEdit.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        return
Example #3
0
    def _loadTextEditWidget(self):
        """
        Load the SequenceTexteditWidgets.
        """
        self.aaRulerTextEdit = \
            PM_TextEdit( self,
                         label = "",
                         spanWidth = False,
                         permit_enter_keystroke = False)

        palette = getPalette(None, QPalette.Base, pmGrpBoxColor)
        self.aaRulerTextEdit.setPalette(palette)
        self.aaRulerTextEdit.setWordWrapMode(QTextOption.WrapAnywhere)
        self.aaRulerTextEdit.setFixedHeight(20)
        self.aaRulerTextEdit.setReadOnly(True)

        self.sequenceTextEdit = \
            PM_TextEdit( self,
                         label = " Sequence: ",
                         spanWidth = False,
                         permit_enter_keystroke = False)
        #self.sequenceTextEdit.setReadOnly(True) #@@@

        self.sequenceTextEdit.setCursorWidth(2)
        self.sequenceTextEdit.setWordWrapMode(QTextOption.WrapAnywhere)
        self.sequenceTextEdit.setFixedHeight(20)

        self.secStrucTextEdit = \
            PM_TextEdit( self,
                         label = " Secondary structure: ",
                         spanWidth = False,
                         permit_enter_keystroke = False)

        palette = getPalette(None, QPalette.Base,
                             sequenceEditStrandMateBaseColor)
        self.secStrucTextEdit.setPalette(palette)
        self.secStrucTextEdit.setWordWrapMode(QTextOption.WrapAnywhere)
        self.secStrucTextEdit.setFixedHeight(20)
        self.secStrucTextEdit.setReadOnly(True)

        #Important to make sure that the horizontal and vertical scrollbars
        #for these text edits are never displayed.

        self.sequenceTextEdit.setHorizontalScrollBarPolicy(
            Qt.ScrollBarAlwaysOff)
        self.sequenceTextEdit.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        self.secStrucTextEdit.setHorizontalScrollBarPolicy(
            Qt.ScrollBarAlwaysOff)
        self.secStrucTextEdit.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        self.aaRulerTextEdit.setHorizontalScrollBarPolicy(
            Qt.ScrollBarAlwaysOff)
        self.aaRulerTextEdit.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        return
Example #4
0
 def getCmdMgrCtrlAreaPalette(self): 
     """ Return a palette for Command Manager control area 
     (Palette for Tool Buttons in command toolbar control area)
     """
     #See comment at the top for details about this flag
     if DEFINE_CONTROL_AREA_AS_A_QWIDGET:
         return getPalette(None,
                           QPalette.Window,
                           cmdTbarCntrlAreaBtnColor
                           )
     else:
         return getPalette(None,
                           QPalette.Button,
                           cmdTbarCntrlAreaBtnColor
                           )
 def resetColor(self):
     """
     Reset the paletter color of the widget (and set it to white)
     """
     self.setAutoFillBackground(True)
     color = RGBf_to_QColor(white)
     self.setPalette(getPalette(None, QPalette.Base, color))
    def _loadTextEditWidget(self):
        """
        Load the SequenceTexteditWidgets.         
        """        
        self.sequenceTextEdit = \
            PM_TextEdit( self, 
                         label = " Sequence: ", 
                         spanWidth = False,
                         permit_enter_keystroke = False)        
        self.sequenceTextEdit.setCursorWidth(2)
        self.sequenceTextEdit.setWordWrapMode( QTextOption.WrapAnywhere )
        self.sequenceTextEdit.setFixedHeight(20)

        #The StrandSequence 'Mate' it is a read only etxtedit that shows
        #the complementary strand sequence.         
        self.sequenceTextEdit_mate = \
            PM_TextEdit(self, 
                        label = "", 
                        spanWidth = False,
                        permit_enter_keystroke = False
                        )        
        palette = getPalette(None, 
                             QPalette.Base, 
                             sequenceEditStrandMateBaseColor)
        self.sequenceTextEdit_mate.setPalette(palette)        
        self.sequenceTextEdit_mate.setFixedHeight(20)
        self.sequenceTextEdit_mate.setReadOnly(True)
        self.sequenceTextEdit_mate.setWordWrapMode(QTextOption.WrapAnywhere)

        #Important to make sure that the horizontal and vertical scrollbars 
        #for these text edits are never displayed. 
        for textEdit in (self.sequenceTextEdit, self.sequenceTextEdit_mate):
            textEdit.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
            textEdit.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
    def _loadTextEditWidget(self):
        """
        Load the SequenceTexteditWidgets.         
        """
        self.sequenceTextEdit = \
            PM_TextEdit( self,
                         label = " Sequence: ",
                         spanWidth = False,
                         permit_enter_keystroke = False)
        self.sequenceTextEdit.setCursorWidth(2)
        self.sequenceTextEdit.setWordWrapMode(QTextOption.WrapAnywhere)
        self.sequenceTextEdit.setFixedHeight(20)

        #The StrandSequence 'Mate' it is a read only etxtedit that shows
        #the complementary strand sequence.
        self.sequenceTextEdit_mate = \
            PM_TextEdit(self,
                        label = "",
                        spanWidth = False,
                        permit_enter_keystroke = False
                        )
        palette = getPalette(None, QPalette.Base,
                             sequenceEditStrandMateBaseColor)
        self.sequenceTextEdit_mate.setPalette(palette)
        self.sequenceTextEdit_mate.setFixedHeight(20)
        self.sequenceTextEdit_mate.setReadOnly(True)
        self.sequenceTextEdit_mate.setWordWrapMode(QTextOption.WrapAnywhere)

        #Important to make sure that the horizontal and vertical scrollbars
        #for these text edits are never displayed.
        for textEdit in (self.sequenceTextEdit, self.sequenceTextEdit_mate):
            textEdit.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
            textEdit.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        return
Example #8
0
    def getCmdMgrSubCtrlAreaPalette(self):
        """ Return a palette for Command Manager sub control area
        (Palette for Tool Buttons in command toolbar sub control area)
        """
        #Define the color role. Make sure to apply color to QPalette.Button
        #instead of QPalette.Window as it is a QToolBar. - ninad 20070619

        return getPalette(None, QPalette.Button, cmdTbarSubCntrlAreaBtnColor)
 def setColor(self, color):
     """
     Set the color of the widget to the one given by param color
     @param color: new palette color of self.
     """
     self.setAutoFillBackground(True)
     color = RGBf_to_QColor(color)
     self.setPalette(getPalette(None, QPalette.Base, color))
 def resetColor(self):
     """
     Reset the paletter color of the widget (and set it to white)
     """
     self.setAutoFillBackground(True)
     color = RGBf_to_QColor(white)
     self.setPalette(getPalette( None, 
                                 QPalette.Base,
                                 color))
Example #11
0
 def getPalette(self):        
     """ 
     Return a palette for Command Manager 'Commands area'(flyout toolbar)
     (Palette for Tool Buttons in command toolbar command area)
     """
     return getPalette(None,
                       QPalette.Button,
                       cmdTbarCmdAreaBtnColor
                       )
 def setColor(self, color):    
     """
     Set the color of the widget to the one given by param color
     @param color: new palette color of self.
     """
     self.setAutoFillBackground(True)
     color = RGBf_to_QColor(color)
     self.setPalette(getPalette( None, 
                                 QPalette.Base,
                                 color))
Example #13
0
 def getCmdMgrSubCtrlAreaPalette(self):
     """ Return a palette for Command Manager sub control area 
     (Palette for Tool Buttons in command toolbar sub control area)
     """
     #Define the color role. Make sure to apply color to QPalette.Button 
     #instead of QPalette.Window as it is a QToolBar. - ninad 20070619
     
     return getPalette(None,
                       QPalette.Button,
                       cmdTbarSubCntrlAreaBtnColor
                       )
Example #14
0
    def _updateSequenceBgColor(self):
        """
        Updates the sequence field background color
        (pink = changed, white = unchanged).
        """
        if self._sequence_changed:
            bgColor = sequenceEditorChangedColor
        else:
            bgColor = sequenceEditorNormalColor

        palette = getPalette(None, QPalette.Base, bgColor)
        self.sequenceTextEdit.setPalette(palette)
        return
Example #15
0
 def _updateSequenceBgColor(self):
     """
     Updates the sequence field background color 
     (pink = changed, white = unchanged).
     """
     if self._sequence_changed:
         bgColor = sequenceEditorChangedColor
     else:
         bgColor = sequenceEditorNormalColor
         
     palette = getPalette(None, 
                          QPalette.Base, 
                          bgColor)
     self.sequenceTextEdit.setPalette(palette)
     return
Example #16
0
    def __init__(self, parentWidget, title="Message"):
        """
        PM_MessageGroupBox constructor.

        @param parentWidget: the PM_Dialog containing this message groupbox.
        @type  parentWidget: PM_Dialog

        @param title: The title on the collapse button
        @type  title: str
        """

        PM_GroupBox.__init__(self, parentWidget, title)

        self.vBoxLayout.setMargin(0)
        self.vBoxLayout.setSpacing(0)

        self.gridLayout.setMargin(0)
        self.gridLayout.setSpacing(0)

        self.MessageTextEdit = PM_TextEdit(
            self,
            label='',
            spanWidth=True,
            addToParent=False,
            ##cursorPosition = 'beginning'
        )
        # We pass addToParent = False to suppress the usual call by
        # PM_TextEdit.__init__ of self.addPmWidget(new textedit widget),
        # since we need to add it to self in a different way (below).
        # [bruce 071103 refactored this from what used to be a special case
        #  in PM_TextEdit.__init__ based on self being an instance of
        #  PM_MessageGroupBox.]

        # Needed for Intel MacOS. Otherwise, the horizontal scrollbar
        # is displayed in the MessageGroupBox. Mark 2007-05-24.
        # Shouldn't be needed with _setHeight() in PM_TextEdit.

        #Note 2008-06-17: We now permit a vertical scrollbar in message groupbox
        #--Ninad

        self.MessageTextEdit.setHorizontalScrollBarPolicy(
            Qt.ScrollBarAlwaysOff)

        # Add self.MessageTextEdit to self's vBoxLayout.
        self.vBoxLayout.addWidget(self.MessageTextEdit)
        # We should be calling the PM's getMessageTextEditPalette() method,
        # but that will take some extra work which I will do soon. Mark 2007-06-21
        self.MessageTextEdit.setPalette(
            getPalette(None, QPalette.Base, pmMessageBoxColor))
        self.MessageTextEdit.setReadOnly(True)
        #@self.MessageTextEdit.labelWidget = None # Never has one. Mark 2007-05-31
        self._widgetList.append(self.MessageTextEdit)
        self._rowCount += 1

        # wrapWrapMode seems to be set to QTextOption.WrapAnywhere on MacOS,
        # so let's force it here. Mark 2007-05-22.
        self.MessageTextEdit.setWordWrapMode(QTextOption.WordWrap)

        parentWidget.MessageTextEdit = self.MessageTextEdit

        # These two policies very important. Mark 2007-05-22
        self.setSizePolicy(
            QSizePolicy(QSizePolicy.Policy(QSizePolicy.Preferred),
                        QSizePolicy.Policy(QSizePolicy.Fixed)))

        self.MessageTextEdit.setSizePolicy(
            QSizePolicy(QSizePolicy.Policy(QSizePolicy.Preferred),
                        QSizePolicy.Policy(QSizePolicy.Fixed)))

        self.setWhatsThis("""<b>Messages</b>
                          <p>This prompts the user for a requisite operation and/or displays 
helpful messages to the user.</p>""")

        # Hide until insertHtmlMessage() loads a message.
        self.hide()
Example #17
0
    def __init__(self, parentWidget, title = "", showWidget = True):
        """
        Constructor for PM_dockWidget
        
        @param showWidget: If true, this class will show the widget 
        immediately in the __init__ method itself. This is the default behavior 
        and subclasses may pass appropriate value to this flag
        @type showWidget: bool
        """
        self.labelWidget  = None    
        self._title         = ""
        self._widgetList    = []
        self._rowCount      = 0
    
        QDockWidget.__init__(self, parentWidget)
        
        self.parentWidget = parentWidget        
        
        self._title = title
        
        self.label = ''
        self.labelColumn = 0
        self.spanWidth = True
        self.labelWidget = None
        
        if self.label: # Create this widget's QLabel.
            self.labelWidget = QLabel()
            self.labelWidget.setText(self.label)
            
        self.setEnabled(True) 
        self.setFloating(False)
        self.setVisible(showWidget)
        self.setWindowTitle(self._title)
        self.setAutoFillBackground(True)
        self.setPalette(getPalette( None,
                                    QPalette.Window,
                                    pmGrpBoxColor))

        self.parentWidget.addDockWidget(Qt.BottomDockWidgetArea, self)
        
        #Define layout
        self._containerWidget = QWidget()
        self.setWidget(self._containerWidget)        
        
        # Create vertical box layout
        self.vBoxLayout = QVBoxLayout(self._containerWidget)
        self.vBoxLayout.setMargin(1)
        self.vBoxLayout.setSpacing(0)
        
        # Create grid layout
        self.gridLayout = QGridLayout()
        self.gridLayout.setMargin(1)
        self.gridLayout.setSpacing(1)
        
        # Insert grid layout in its own vBoxLayout
        self.vBoxLayout.addLayout(self.gridLayout)
                         
        #self.parentWidget.addPmWidget(self)
        self._loadWidgets()
        
        try:
            self._addWhatsThisText()
        except:
            print_compact_traceback("Error loading whatsthis text for this " \
                                    "property manager dock widget.")
        
        try:
            self._addToolTipText()
        except:
            print_compact_traceback("Error loading tool tip text for this " \
                                    "property manager dock widget.")
    def __init__(self, parentWidget, title = "", showWidget = True):
        """
        Constructor for PM_dockWidget

        @param showWidget: If true, this class will show the widget
        immediately in the __init__ method itself. This is the default behavior
        and subclasses may pass appropriate value to this flag
        @type showWidget: bool
        """
        self.labelWidget  = None
        self._title         = ""
        self._widgetList    = []
        self._rowCount      = 0

        QDockWidget.__init__(self, parentWidget)

        self.parentWidget = parentWidget

        self._title = title

        self.label = ''
        self.labelColumn = 0
        self.spanWidth = True
        self.labelWidget = None

        if self.label: # Create this widget's QLabel.
            self.labelWidget = QLabel()
            self.labelWidget.setText(self.label)

        self.setEnabled(True)
        self.setFloating(False)
        self.setVisible(showWidget)
        self.setWindowTitle(self._title)
        self.setAutoFillBackground(True)
        self.setPalette(getPalette( None,
                                    QPalette.Window,
                                    pmGrpBoxColor))

        self.parentWidget.addDockWidget(Qt.BottomDockWidgetArea, self)

        #Define layout
        self._containerWidget = QWidget()
        self.setWidget(self._containerWidget)

        # Create vertical box layout
        self.vBoxLayout = QVBoxLayout(self._containerWidget)
        self.vBoxLayout.setMargin(1)
        self.vBoxLayout.setSpacing(0)

        # Create grid layout
        self.gridLayout = QGridLayout()
        self.gridLayout.setMargin(1)
        self.gridLayout.setSpacing(1)

        # Insert grid layout in its own vBoxLayout
        self.vBoxLayout.addLayout(self.gridLayout)

        #self.parentWidget.addPmWidget(self)
        self._loadWidgets()

        try:
            self._addWhatsThisText()
        except:
            print_compact_traceback("Error loading whatsthis text for this " \
                                    "property manager dock widget.")

        try:
            self._addToolTipText()
        except:
            print_compact_traceback("Error loading tool tip text for this " \
                                    "property manager dock widget.")
    def __init__(self, win):
        """
        Constructor for Ui_ReportsDockWidget.
        @param win: The main window
        @type  win: QMainWindow
        """
        QDockWidget.__init__(self, win)
        
        self.win = win
        #Define layout
        self._containerWidget = QWidget()
        self.setWidget(self._containerWidget)        
        
        # Create vertical box layout
        self.vBoxLayout = QVBoxLayout(self._containerWidget)
        vBoxLayout = self.vBoxLayout
        vBoxLayout.setMargin(0)
        vBoxLayout.setSpacing(0)
        
        self.setEnabled(True) 
        self.setFloating(False)
        self.setVisible(True)
        self.setWindowTitle(self._title)
        self.setAutoFillBackground(True)
        self.setPalette(getPalette( None,
                                    QPalette.Window,
                                    pmGrpBoxColor))
        
        # Create the reports tabwidget. It will contain the history tab
        # and possibly other tabs containing reports.
        self.reportsTabWidget = QTabWidget()
        self.reportsTabWidget.setObjectName("reportsTabWidget")
        self.reportsTabWidget.setCurrentIndex(0)
        self.reportsTabWidget.setAutoFillBackground(True)
        vBoxLayout.addWidget(self.reportsTabWidget)

        # Create the history tab. It will contain the history widget.
        self.historyTab = QWidget()
        self.historyTab.setObjectName("historyTab")
        self.reportsTabWidget.addTab(self.historyTab, "History") 

        self.historyTabLayout = QVBoxLayout(self.historyTab)
        historyTabLayout = self.historyTabLayout
        historyTabLayout.setMargin(0)
        historyTabLayout.setSpacing(0)
        
        self._addHistoryWidget()
        
        self.setMinimumHeight(100)
        self.setSizePolicy(
                QSizePolicy(QSizePolicy.Policy(QSizePolicy.Expanding),
                            QSizePolicy.Policy(QSizePolicy.Expanding)))
        
        win.addDockWidget(Qt.BottomDockWidgetArea, self)
        
        # Since the connection to the toggle() slot hasn't been made yet,
        # we must set the checkmark and hide/show self manually.
        if env.prefs[displayReportsWidget_prefs_key]:
            self.win.viewReportsAction.setChecked(True) 
            # No slot connected yet, so show self manually.
            self.show()
        else:
            self.win.viewReportsAction.setChecked(False)
            # No slot connected yet, so hide self manually.
            self.hide()
Example #20
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))
Example #21
0
    def __init__(self, win):
        """
        Constructor for Ui_ReportsDockWidget.
        @param win: The main window
        @type  win: QMainWindow
        """
        QDockWidget.__init__(self, win)
        
        self.win = win
        #Define layout
        self._containerWidget = QWidget()
        self.setWidget(self._containerWidget)        
        
        # Create vertical box layout
        self.vBoxLayout = QVBoxLayout(self._containerWidget)
        vBoxLayout = self.vBoxLayout
        vBoxLayout.setMargin(0)
        vBoxLayout.setSpacing(0)
        
        self.setEnabled(True) 
        self.setFloating(False)
        self.setVisible(True)
        self.setWindowTitle(self._title)
        self.setAutoFillBackground(True)
        self.setPalette(getPalette( None,
                                    QPalette.Window,
                                    pmGrpBoxColor))
        
        # Create the reports tabwidget. It will contain the history tab
        # and possibly other tabs containing reports.
        self.reportsTabWidget = QTabWidget()
        self.reportsTabWidget.setObjectName("reportsTabWidget")
        self.reportsTabWidget.setCurrentIndex(0)
        self.reportsTabWidget.setAutoFillBackground(True)
        vBoxLayout.addWidget(self.reportsTabWidget)

        # Create the history tab. It will contain the history widget.
        self.historyTab = QWidget()
        self.historyTab.setObjectName("historyTab")
        self.reportsTabWidget.addTab(self.historyTab, "History") 

        self.historyTabLayout = QVBoxLayout(self.historyTab)
        historyTabLayout = self.historyTabLayout
        historyTabLayout.setMargin(0)
        historyTabLayout.setSpacing(0)
        
        self._addHistoryWidget()
        
        self.setMinimumHeight(100)
        self.setSizePolicy(
                QSizePolicy(QSizePolicy.Policy(QSizePolicy.Expanding),
                            QSizePolicy.Policy(QSizePolicy.Expanding)))
        
        win.addDockWidget(Qt.BottomDockWidgetArea, self)
        
        # Since the connection to the toggle() slot hasn't been made yet,
        # we must set the checkmark and hide/show self manually.
        if env.prefs[displayReportsWidget_prefs_key]:
            self.win.viewReportsAction.setChecked(True) 
            # No slot connected yet, so show self manually.
            self.show()
        else:
            self.win.viewReportsAction.setChecked(False)
            # No slot connected yet, so hide self manually.
            self.hide()
    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))
Example #23
0
 def getPalette(self):
     """
     Return a palette for Command Manager 'Commands area'(flyout toolbar)
     (Palette for Tool Buttons in command toolbar command area)
     """
     return getPalette(None, QPalette.Button, cmdTbarCmdAreaBtnColor)
    def __init__(self,
                 parentWidget,
                 title = "Message"
                 ):
        """
        PM_MessageGroupBox constructor.

        @param parentWidget: the PM_Dialog containing this message groupbox.
        @type  parentWidget: PM_Dialog

        @param title: The title on the collapse button
        @type  title: str
        """

        PM_GroupBox.__init__(self, parentWidget, title)

        self.vBoxLayout.setMargin(0)
        self.vBoxLayout.setSpacing(0)

        self.gridLayout.setMargin(0)
        self.gridLayout.setSpacing(0)


        self.MessageTextEdit = PM_TextEdit(self,
                                           label='',
                                           spanWidth = True,
                                           addToParent = False,
                                           ##cursorPosition = 'beginning'
                                       )
            # We pass addToParent = False to suppress the usual call by
            # PM_TextEdit.__init__ of self.addPmWidget(new textedit widget),
            # since we need to add it to self in a different way (below).
            # [bruce 071103 refactored this from what used to be a special case
            #  in PM_TextEdit.__init__ based on self being an instance of
            #  PM_MessageGroupBox.]

        # Needed for Intel MacOS. Otherwise, the horizontal scrollbar
        # is displayed in the MessageGroupBox. Mark 2007-05-24.
        # Shouldn't be needed with _setHeight() in PM_TextEdit.

        #Note 2008-06-17: We now permit a vertical scrollbar in message groupbox
        #--Ninad

        self.MessageTextEdit.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)

        # Add self.MessageTextEdit to self's vBoxLayout.
        self.vBoxLayout.addWidget(self.MessageTextEdit)
        # We should be calling the PM's getMessageTextEditPalette() method,
        # but that will take some extra work which I will do soon. Mark 2007-06-21
        self.MessageTextEdit.setPalette(getPalette( None,
                                                    QPalette.Base,
                                                    pmMessageBoxColor))
        self.MessageTextEdit.setReadOnly(True)
        #@self.MessageTextEdit.labelWidget = None # Never has one. Mark 2007-05-31
        self._widgetList.append(self.MessageTextEdit)
        self._rowCount += 1


        # wrapWrapMode seems to be set to QTextOption.WrapAnywhere on MacOS,
        # so let's force it here. Mark 2007-05-22.
        self.MessageTextEdit.setWordWrapMode(QTextOption.WordWrap)

        parentWidget.MessageTextEdit = self.MessageTextEdit

        # These two policies very important. Mark 2007-05-22
        self.setSizePolicy(
            QSizePolicy(QSizePolicy.Policy(QSizePolicy.Preferred),
                        QSizePolicy.Policy(QSizePolicy.Fixed)))

        self.MessageTextEdit.setSizePolicy(
            QSizePolicy(QSizePolicy.Policy(QSizePolicy.Preferred),
                        QSizePolicy.Policy(QSizePolicy.Fixed)))

        self.setWhatsThis("""<b>Messages</b>
                          <p>This prompts the user for a requisite operation and/or displays
helpful messages to the user.</p>""")

        # Hide until insertHtmlMessage() loads a message.
        self.hide()