Example #1
0
 def __init__(self, widget, value=None, label=None, displayLabel=True, orientation='vertical', selectionMode=QAbstractItemView.SingleSelection, enableDragDrop = 0, dragDropCallback = None, dataValidityCallback = None, sizeHint = None, callback=None, items = None, *args, **kwargs):
     kwargs.setdefault('includeInReports', True)
     kwargs.setdefault('sizePolicy', QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred))
     widgetState.__init__(self,widget,label,**kwargs)
     QListWidget.__init__(self, *args)
     self.label = label
     self.widget = self.controlArea
     if displayLabel:
         self.hb = groupBox(self.controlArea,label=label,orientation=orientation)
         
     else:
         self.hb = widgetBox(self.controlArea,orientation=orientation)
         
     self.hb.layout().addWidget(self)
     self.ogValue = value
     self.ogLabels = label
     self.enableDragDrop = enableDragDrop
     self.dragDopCallback = dragDropCallback
     self.dataValidityCallback = dataValidityCallback
     self.defaultSizeHint = QSize(150,100)
     self.setSelectionMode(selectionMode)
     if enableDragDrop:
         self.setDragEnabled(1)
         self.setAcceptDrops(1)
         self.setDropIndicatorShown(1)
         #self.setDragDropMode(QAbstractItemView.DragDrop)
         
         self.dragStartPosition = 0
     
     self.listItems = OrderedDict()
     if items:
         self.addItems(items)
     
     if callback:
         QObject.connect(self, SIGNAL('itemClicked(QListWidgetItem*)'), callback)
Example #2
0
 def __init__(self,widget):
     
     widgetState.__init__(self,widget, 'tabWidget',includeInReports=True)
     QTabWidget.__init__(self,self.controlArea)
     self.controlArea.layout().addWidget(self)
     
     self.tabs = {}
Example #3
0
    def __init__(self, widget, label = _('Formula Entry'), displayLabel=True, includeInReports=True):
        # make a widgetBox to hold everything
        widgetState.__init__(self,widget,label,includeInReports)
        
        box = groupBox(self.controlArea,label=label)

        ## add the elements to the box
        #place the command keys
        self.buttonsBox = groupBox(box, label = _("Formula Commands"))
        self.plusButton = button(self.buttonsBox, _("And (+)"), callback = self.plusButtonClicked)
        self.plusButton.setEnabled(False)
        self.colonButton = button(self.buttonsBox, _("Interacting With (:)"), callback = self.colonButtonClicked)
        self.colonButton.setEnabled(False)
        self.starButton = button(self.buttonsBox, _("Together and Interacting (*)"), callback = self.starButtonClicked)
        self.starButton.setEnabled(False)
        button(self.buttonsBox, _('Clear'), self.clearFormula)
        self.elementsListBox = listBox(self.buttonsBox, label = _('Elements'), callback = self.FormulaEntryElementSelected)
        self.elementsListBox.setEnabled(True)
        
        # place the formula line edit
        self.modelBox = groupBox(box, label = _("Model Formula"), orientation = 'horizontal')
        self.extrasBox = widgetBox(self.modelBox)
        self.outcomeVariable = comboBox(self.modelBox, label = _('Outcome (f(x)):'))
        widgetLabel(self.modelBox, ' = ')
        self.modelLineEdit = lineEdit(self.modelBox, label = _('model'), displayLabel=False)
        self.label = label
Example #4
0
 def __init__(self, widget, label=None, displayLabel=True, value=None, orientation='horizontal', decimals=0, max = None, min = None, callback=None, *args, **kwargs):
     kwargs.setdefault('includeInReports', True)
     kwargs.setdefault('sizePolicy', QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred))
     self.widget = widget
     
     widgetState.__init__(self,widget,label,**kwargs)
     QDoubleSpinBox.__init__(self)
     self.setDecimals(decimals)
     self.label = label
     if displayLabel:
         self.hb = widgetBox(self.controlArea,orientation=orientation)
         
         widgetLabel(self.hb, label,sizePolicy=QSizePolicy(QSizePolicy.Minimum,QSizePolicy.Minimum))
         
         self.hb.layout().addWidget(self)
     else:
         self.controlArea.layout().addWidget(self)
     
     if max:
         self.setMaximum(int(max))
     if min:
         self.setMinimum(int(min))
     self.setWrapping(True) # we always allow the spin box to wrap around
     if value:
         self.setValue(value)
     if callback:
         QObject.connect(self, SIGNAL('valueChanged(double)'), callback)
Example #5
0
 def __init__(self, widget, label=None, displayLabel=True, includeInReports=True, value=None, 
 orientation='horizontal', decimals=0, max = None, min = None, callback=None, toolTip = None, *args):
     
     self.widget = widget
     
     widgetState.__init__(self,widget,label,includeInReports)
     QDoubleSpinBox.__init__(self)
     self.setDecimals(decimals)
     self.label = label
     if displayLabel:
         self.hb = widgetBox(self.controlArea,orientation=orientation)
         widgetLabel(self.hb, label)
         self.hb.layout().addWidget(self)
     else:
         self.controlArea.layout().addWidget(self)
     
     if max:
         self.setMaximum(int(max))
     if min:
         self.setMinimum(int(min))
     if toolTip:
         self.setToolTip(unicode(toolTip))
     self.setWrapping(True) # we always allow the spin box to wrap around
     if value:
         self.setValue(value)
     if callback:
         QObject.connect(self, SIGNAL('valueChanged(double)'), callback)
Example #6
0
    def __init__(self,widget,label, callback = None, icon=None, 
    width = None, height = None,alignment=Qt.AlignLeft, toggleButton = False, setChecked = False,**kwargs):
        kwargs.setdefault('includeInReports', False)
        kwargs.setdefault('sizePolicy', QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred))
        if icon and (not label or label == ''):
            widgetState.__init__(self,widget,os.path.basename(icon),**kwargs)
        else:
            widgetState.__init__(self,widget,label,**kwargs)
            
        if icon:
            QPushButton.__init__(self,QIcon(icon), label,self.controlArea)
        else:
            QPushButton.__init__(self,label,self.controlArea)

        self.controlArea.layout().addWidget(self)
        if alignment:
            self.controlArea.layout().setAlignment(self, alignment)
        
        if icon or width == -1:
            pass
        elif width: 
            self.setFixedWidth(width)
#        elif len(label)*7+5 < 50:
#            self.setFixedWidth(50)
#        else:
#            self.setFixedWidth(len(label)*7+5)
            
        if height:
            self.setFixedHeight(height)
        if toggleButton:
            self.setCheckable(True)
            if setChecked:
                self.setChecked(True)
        if callback:
            QObject.connect(self, SIGNAL("clicked()"), callback)
Example #7
0
    def __init__(self,widget, orientation=QVBoxLayout(), addSpace=False, 
    margin = -1, spacing = -1, addToLayout = 1, **kwargs):
        kwargs.setdefault('includeInReports', True)
        kwargs.setdefault('sizePolicy', QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred))
        widgetState.__init__(self,widget, 'scrollArea',**kwargs)
        QScrollArea.__init__(self,self.controlArea)
            
        if margin == -1: margin = 0
        self.controlArea.layout().addWidget(self)
        
        try:
            if isinstance(orientation, QLayout):
                self.setLayout(orientation)
            elif orientation == 'horizontal' or not orientation:
                self.setLayout(QHBoxLayout())
            else:
                self.setLayout(QVBoxLayout())
        except:
            self.setLayout(QVBoxLayout())
            
        if self.layout() == 0 or self.layout() == None:
            self.setLayout(QVBoxLayout())

        
        if spacing == -1: spacing = 4
        self.layout().setSpacing(spacing)
        if margin != -1:
            self.layout().setMargin(margin)

        if addSpace and isinstance(addSpace, int):
            separator(widget, 0, addSpace)
        elif addSpace:
            separator(widget)
Example #8
0
    def __init__(self,widget,label=None, displayLabel=True, data=None, keys = None, rows = 0, columns = 0, sortable = False, selectionMode = -1, addToLayout = 1, callback = None,**kwargs):
        
        kwargs.setdefault('includeInReports', True)
        kwargs.setdefault('sizePolicy', QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred))
        widgetState.__init__(self,widget,label,**kwargs)
        
        if displayLabel:
            mainBox = groupBox(self.controlArea,label=label, orientation='vertical')
        else:
            mainBox = widgetBox(self.controlArea,orientation='vertical')
        
        QTableWidget.__init__(self,rows,columns,widget)
        mainBox.layout().addWidget(self)

        
        self.sortIndex = None
        self.oldSortingIndex = None
        self.data = None

        ###
        if selectionMode != -1:
            self.setSelectionMode(selectionMode)
        if data:
            if keys:
                self.setTable(data, keys)
            else:
                self.setTable(data)
        if sortable:
            self.setSortingEnabled(True)
            self.connect(self.horizontalHeader(), SIGNAL("sectionClicked(int)"), self.sort)
        if callback:
            QObject.connect(self, SIGNAL('cellClicked(int, int)'), callback)
Example #9
0
    def __init__(self,
                 widget,
                 label=None,
                 displayLabel=True,
                 includeInReports=True,
                 items=None,
                 editable=False,
                 orientation='horizontal',
                 callback=None):

        widgetState.__init__(self, widget, label, includeInReports)
        QComboBox.__init__(self, self.controlArea)

        if displayLabel:
            self.hb = widgetBox(self.controlArea, orientation=orientation)
            widgetLabel(self.hb, label)
            self.hb.layout().addWidget(self)
            self.hasLabel = True
        else:
            self.controlArea.layout().addWidget(self)
            self.hasLabel = False
        self.label = label

        self.items = OrderedDict()
        self.setEditable(editable)

        if items:
            self.addItems(items)

        if callback:
            QObject.connect(self, SIGNAL('activated(int)'), callback)
Example #10
0
    def __init__(self,
                 caption=_('Search Dialog'),
                 url='',
                 icon=None,
                 orientation='horizontal'):
        widgetState.__init__(self,
                             None,
                             _('SearchDialog'),
                             includeInReports=False)
        QDialog.__init__(self)

        self.setWindowTitle(caption)
        try:
            if isinstance(orientation, QLayout):
                self.setLayout(orientation)
            elif orientation == 'horizontal' or not orientation:
                self.setLayout(QHBoxLayout())
            else:
                self.setLayout(QVBoxLayout())
        except:
            self.setLayout(QVBoxLayout())
        self.thisLayout = self.layout()
        self.webView = webViewBox(self,
                                  label=_('Search Dialog'),
                                  displayLabel=False)
        self.setMinimumSize(600, 400)
        if url and url != '':
            self.webView.load(QUrl(url))

        if icon:
            self.setWindowIcon(icon)
 def __init__(self, widget, label = None, displayLabel = False,**kwargs):
     kwargs.setdefault('includeInReports', False)
     kwargs.setdefault('sizePolicy', QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred))
     widgetState.__init__(self,widget, 'stackedWidget',**kwargs)
     QStackedWidget.__init__(self, self.controlArea)
     self.controlArea.layout().addWidget(self)
     self.stackIndex = []
Example #12
0
 def __init__(self,widget,width=8, height=8, **kwargs):
     kwargs.setdefault('includeInReports', True)
     kwargs.setdefault('sizePolicy', QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred))
     widgetState.__init__(self, widget, 'separator',**kwargs)
     QWidget.__init__(self,self.controlArea)
     self.controlArea.layout().addWidget(self)       
     self.setFixedSize(width, height)
Example #13
0
    def __init__(self,widget,label = None, displayLabel= True, setChecked=False,
    orientation='vertical',callback = None, **kwargs):
        kwargs.setdefault('includeInReports', True)
        kwargs.setdefault('sizePolicy', QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred))
        QWidget.__init__(self,widget)
        widgetState.__init__(self,widget,label,**kwargs)
        

        self.controlArea.layout().addWidget(self)

        self.box = widgetBox(self.controlArea,orientation=orientation)
        
        self.controlArea.layout().setAlignment(Qt.AlignTop | Qt.AlignLeft)
        self.box.setSizePolicy(QSizePolicy(QSizePolicy.MinimumExpanding,
        QSizePolicy.Preferred))
        
        # if orientation=='vertical':
            # self.box.setSizePolicy(QSizePolicy(QSizePolicy.Preferred,
            # QSizePolicy.MinimumExpanding))
        # else:
            # self.box.setSizePolicy(QSizePolicy(QSizePolicy.MinimumExpanding,
            # QSizePolicy.Preferred))
            
        self.label = label
        self.items = OrderedDict()
        self.buttons = QButtonGroup(self.box)
        self.buttons.setExclusive(False)
        self.addButton('TRUE', label)


        if callback:
            QObject.connect(self.buttons, SIGNAL('buttonClicked(int)'), callback)
        if setChecked:
            self.setChecked('TRUE')
    def __init__(self, widget, label = _('Formula Entry'), displayLabel=True, **kwargs):
        kwargs.setdefault('includeInReports', True)
        kwargs.setdefault('sizePolicy', QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred))
        # make a widgetBox to hold everything
        widgetState.__init__(self,widget,label,**kwargs)
        
        box = groupBox(self.controlArea,label=label)

        ## add the elements to the box
        #place the command keys
        self.buttonsBox = groupBox(box, label = _("Formula Commands"), orientation = 'horizontal')
        self.plusButton = button(self.buttonsBox, _("And (+)"), callback = self.plusButtonClicked)
        self.plusButton.setEnabled(False)
        self.colonButton = button(self.buttonsBox, _("Interacting With (:)"), callback = self.colonButtonClicked)
        self.colonButton.setEnabled(False)
        self.starButton = button(self.buttonsBox, _("Together and Interacting (*)"), callback = self.starButtonClicked)
        self.starButton.setEnabled(False)
        button(self.buttonsBox, _('Clear'), self.clearFormula)
        self.elementsListBox = listBox(box, label = _('Elements'), callback = self.FormulaEntryElementSelected)
        self.elementsListBox.setEnabled(True)
        
        # place the formula line edit
        self.modelBox = groupBox(box, label = _("Model Formula"), orientation = 'horizontal')
        self.extrasBox = widgetBox(self.modelBox)
        self.outcomeVariable = comboBox(self.modelBox, label = _('Outcome (f(x)):'))
        widgetLabel(self.modelBox, ' = ')
        self.modelLineEdit = lineEdit(self.modelBox, label = _('model'), displayLabel=False)
        self.label = label
Example #15
0
    def __init__(self,widget,label=None, displayLabel=True, 
    items=None, editable=False, orientation='horizontal',callback = None,**kwargs):
        kwargs.setdefault('includeInReports', True)
        kwargs.setdefault('sizePolicy', QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred))
        widgetState.__init__(self,widget,label,**kwargs)
        QComboBox.__init__(self,self.controlArea)
        
        if displayLabel:
            self.hb = widgetBox(self.controlArea,orientation=orientation)
            lb = widgetLabel(self.hb, label)
            self.hb.layout().addWidget(self)
            self.hasLabel = True
            self.hb.layout().setAlignment(lb,Qt.AlignRight)
            lb.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred)
        else:
            self.controlArea.layout().addWidget(self)
            self.hasLabel = False
        self.label = label
        
        self.setSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.Preferred)
        
        self.items = OrderedDict()
        self.setEditable(editable)

        if items:
            self.addItems(items)

        if callback:
            QObject.connect(self, SIGNAL('activated(int)'), callback)
Example #16
0
    def __init__(self,
                 widget,
                 html='',
                 label=None,
                 displayLabel=True,
                 includeInReports=True,
                 orientation='vertical',
                 alignment=None,
                 editable=True,
                 printable=False,
                 clearable=False,
                 **args):

        widgetState.__init__(self, widget, label, includeInReports)

        QTextEdit.__init__(self, self.controlArea)
        self.label = label
        if displayLabel:
            self.hb = groupBox(self.controlArea,
                               label=label,
                               orientation=orientation)
        else:
            self.hb = widgetBox(self.controlArea, orientation=orientation)

        self.hb.layout().addWidget(self)
        if alignment:
            self.controlArea.layout().setAlignment(self.hb, alignment)
        if printable:
            button(self.hb, _("Print"), self.printMe)
        if clearable:
            button(self.hb, _("Clear"), callback=self.clear)
        if not editable:
            self.setReadOnly(True)
        self.setFontFamily('Courier')
        self.insertHtml(html)
Example #17
0
 def __init__(self, widget, label = None, displayLabel = True, startColor = '#000000', callback = None, width = 15, height = 15,**kwargs):
     """Constructor, typically called with label, startColor, callback, and toolTip
     
     """
     kwargs.setdefault('includeInReports', True)
     kwargs.setdefault('sizePolicy', QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred))
     widgetState.__init__(self,widget, label, **kwargs)
     
     QToolButton.__init__(self, self.controlArea)
     
     
     if label and displayLabel:
         self.hb = redRWidgetBox(self.controlArea,orientation='horizontal')
         lb = widgetLabel(self.hb, label)
         self.hb.layout().addWidget(self)
         self.hasLabel = True
         self.hb.layout().setAlignment(lb,Qt.AlignRight)
         lb.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred)
     else:
         self.controlArea.layout().addWidget(self)
         self.hasLabel = False
         
     self.label = label
     self.w = width
     self.h = height
     self.setMinimumSize(width, height)
     self.callback = callback
     self.color = startColor
     self.setMaximumSize(self.w + 5, self.h + 5)
     self.connect(self, SIGNAL("clicked()"), self.showColorDialog)
     self.updateColor()
Example #18
0
 def __init__(self,widget, position = QTabWidget.North, **kwargs):
     kwargs.setdefault('includeInReports', True)
     kwargs.setdefault('sizePolicy', QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred))
     widgetState.__init__(self,widget, 'tabWidget',**kwargs)
     QTabWidget.__init__(self,self.controlArea)
     self.controlArea.layout().addWidget(self)
     
     self.tabs = {}
     self.setTabPosition(position)
Example #19
0
    def __init__(self,
                 widget,
                 label=None,
                 displayLabel=True,
                 includeInReports=True,
                 buttons=None,
                 toolTips=None,
                 setChecked=None,
                 orientation='vertical',
                 callback=None):

        if toolTips and len(toolTips) != len(buttons):
            raise RuntimeError(
                _('Number of buttons and toolTips must be equal'))

        QWidget.__init__(self, widget)
        widgetState.__init__(self, widget, label, includeInReports)

        self.controlArea.layout().setAlignment(Qt.AlignTop | Qt.AlignLeft)

        self.controlArea.layout().addWidget(self)

        if displayLabel:
            self.box = groupBox(self.controlArea,
                                label=label,
                                orientation=orientation)
            # self.layout().addWidget(self.box)
        else:
            self.box = widgetBox(self.controlArea, orientation=orientation)

        # if orientation=='vertical':
        # self.box.setSizePolicy(QSizePolicy(QSizePolicy.Preferred,
        # QSizePolicy.MinimumExpanding))
        # else:
        # self.box.setSizePolicy(QSizePolicy(QSizePolicy.MinimumExpanding,
        # QSizePolicy.Preferred))

        self.label = label
        self.items = OrderedDict()
        self.buttons = QButtonGroup(self.box)
        self.buttons.setExclusive(False)
        if buttons:
            self.addButtons(buttons)

        # if buttons:
        # for i,b in zip(range(len(buttons)),buttons):
        # w = QCheckBox(b,self.box)
        # if toolTips:
        # w.setToolTip(toolTips[i])
        # self.buttons.addButton(w,i)
        # self.box.layout().addWidget(w)

        if callback:
            QObject.connect(self.buttons, SIGNAL('buttonClicked(int)'),
                            callback)
        if setChecked:
            self.setChecked(setChecked)
Example #20
0
    def __init__(self,
                 widget,
                 value=None,
                 label=None,
                 displayLabel=True,
                 includeInReports=True,
                 orientation='vertical',
                 selectionMode=QAbstractItemView.SingleSelection,
                 enableDragDrop=0,
                 dragDropCallback=None,
                 dataValidityCallback=None,
                 sizeHint=None,
                 callback=None,
                 toolTip=None,
                 items=None,
                 *args):

        widgetState.__init__(self, widget, label, includeInReports)
        QListWidget.__init__(self, *args)
        self.label = label
        self.widget = self.controlArea
        if displayLabel:
            self.hb = groupBox(self.controlArea,
                               label=label,
                               orientation=orientation)

        else:
            self.hb = widgetBox(self.controlArea, orientation=orientation)

        self.hb.layout().addWidget(self)
        self.ogValue = value
        self.ogLabels = label
        self.enableDragDrop = enableDragDrop
        self.dragDopCallback = dragDropCallback
        self.dataValidityCallback = dataValidityCallback
        if not sizeHint:
            self.defaultSizeHint = QSize(150, 100)
        else:
            self.defaultSizeHint = sizeHint
        self.setSelectionMode(selectionMode)
        if enableDragDrop:
            self.setDragEnabled(1)
            self.setAcceptDrops(1)
            self.setDropIndicatorShown(1)
            #self.setDragDropMode(QAbstractItemView.DragDrop)

            self.dragStartPosition = 0
        if toolTip:
            self.setToolTip(toolTip)

        self.listItems = OrderedDict()
        if items:
            self.addItems(items)

        if callback:
            QObject.connect(self, SIGNAL('itemClicked(QListWidgetItem*)'),
                            callback)
Example #21
0
    def __init__(self,
                 widget,
                 label=None,
                 displayLabel=True,
                 includeInReports=True,
                 Rdata=None,
                 editable=False,
                 rows=None,
                 columns=None,
                 sortable=False,
                 selectionMode=-1,
                 addToLayout=1,
                 callback=None):

        widgetState.__init__(self, widget, widget.label, includeInReports)
        if displayLabel:
            mainBox = groupBox(self.controlArea,
                               label=label,
                               orientation='vertical')
        else:
            mainBox = widgetBox(self.controlArea, orientation='vertical')

        QTableView.__init__(self, mainBox)
        mainBox.layout().addWidget(self)

        self.R = Rcommand
        self.sortIndex = None
        self.oldSortingIndex = None
        self.Rdata = None
        self.parent = widget
        self.tm = None
        self.editable = editable

        self.setAlternatingRowColors(True)

        if widget and addToLayout and widget.layout():
            widget.layout().addWidget(self)
        elif widget and addToLayout:
            try:
                widget.addWidget(self)
            except:  # there seems to be no way to add this widget
                pass
        if selectionMode != -1:
            self.setSelectionMode(selectionMode)

        if Rdata:
            self.setRTable(Rdata)
        if sortable:
            self.setSortingEnabled(True)
            self.connect(self.horizontalHeader(),
                         SIGNAL("sectionClicked(int)"), self.sort)
        # if editable:
        # self.horizontalHeader().hide()
        # self.verticalHeader().hide()
        if callback:
            QObject.connect(self, SIGNAL('cellClicked(int, int)'), callback)
Example #22
0
 def __init__(self, widget = None, orientation = 'horizontal'):
     widgetState.__init__(self,widget, 'splitter',includeInReports=False)
     QSplitter.__init__(self, widget)
     
     self.controlArea.layout().addWidget(self)
     
     if orientation == 'horizontal':
         self.setOrientation(Qt.Horizontal)
     else:
         self.setOrientation(Qt.Vertical)
Example #23
0
 def __init__(self, widget, label="", icon=None, wordWrap=False, **kwargs):
     kwargs.setdefault("sizePolicy", QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Minimum))
     widgetState.__init__(self, widget, _("widgetLabel"), includeInReports=False, **kwargs)
     QLabel.__init__(self, self.controlArea)
     self.controlArea.layout().addWidget(self)
     if icon:
         label = "<img style='margin-left:5px' src=\"%s\" /> %s" % (icon, label)
     self.setText(label)
     self.setWordWrap(wordWrap)
     self.setTextInteractionFlags(Qt.TextBrowserInteraction)
Example #24
0
    def __init__(self,
                 widget,
                 label=None,
                 displayLabel=True,
                 includeInReports=True,
                 orientation='vertical',
                 addSpace=False,
                 sizePolicy=None,
                 margin=-1,
                 spacing=-1,
                 flat=0,
                 alignment=Qt.AlignTop):
        if label:
            widgetState.__init__(self, widget, label, includeInReports)
        else:
            widgetState.__init__(self, widget, _('Group Box'),
                                 includeInReports)

        if displayLabel:
            QGroupBox.__init__(self, label)
        else:
            QGroupBox.__init__(self)

        self.label = label
        self.controlArea.layout().addWidget(self)

        self.controlArea.layout().setAlignment(alignment)

        try:
            if isinstance(orientation, QLayout):
                self.setLayout(orientation)
            elif orientation == 'horizontal' or not orientation:
                self.setLayout(QHBoxLayout())
            else:
                self.setLayout(QVBoxLayout())
        except:
            self.setLayout(QVBoxLayout())

        if self.layout() == 0 or self.layout() == None:
            self.setLayout(QVBoxLayout())

        if spacing == -1: spacing = 8
        self.layout().setSpacing(spacing)
        if margin != -1:
            self.layout().setMargin(margin)
        if widget:
            if addSpace and isinstance(addSpace, int):
                separator(self.controlArea, 0, addSpace)
            elif addSpace:
                separator(self.controlArea)

        if sizePolicy:
            self.setSizePolicy(sizePolicy)
Example #25
0
 def __init__(self, widget = None, orientation = 'horizontal',**kwargs):
     kwargs.setdefault('includeInReports', False)
     kwargs.setdefault('sizePolicy', QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred))
     widgetState.__init__(self,widget, 'splitter',**kwargs)
     QSplitter.__init__(self, widget)
     
     self.controlArea.layout().addWidget(self)
     self.controlArea.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
     if orientation == 'horizontal':
         self.setOrientation(Qt.Horizontal)
     else:
         self.setOrientation(Qt.Vertical)
Example #26
0
    def __init__(self,
                 widget,
                 label,
                 callback=None,
                 disabled=0,
                 icon=None,
                 toolTip=None,
                 width=None,
                 height=None,
                 alignment=Qt.AlignLeft,
                 toggleButton=False):

        if icon and (not label or label == ''):
            widgetState.__init__(self,
                                 widget,
                                 os.path.basename(icon),
                                 includeInReports=False)
        else:
            widgetState.__init__(self, widget, label, includeInReports=False)

        if icon:
            QPushButton.__init__(self, QIcon(icon), label, self.controlArea)
        else:
            QPushButton.__init__(self, label, self.controlArea)

        self.controlArea.layout().addWidget(self)
        if alignment:
            self.controlArea.layout().setAlignment(self, alignment)

        if icon or width == -1:
            pass
        elif width:
            self.setFixedWidth(width)
        elif len(label) * 7 + 5 < 50:
            self.setFixedWidth(50)
        else:
            self.setFixedWidth(len(label) * 7 + 5)

        if height:
            self.setFixedHeight(height)
        self.setDisabled(disabled)

        if toolTip:
            self.setToolTip(toolTip)

        if toggleButton:
            self.setCheckable(True)

        if callback:
            QObject.connect(self, SIGNAL("clicked()"), callback)
Example #27
0
 def __init__(self,widget,label = '', icon=None, wordWrap=False):
     widgetState.__init__(self,widget, _('widgetLabel'),includeInReports=False)
     QLabel.__init__(self,self.controlArea)
     # if icon:
         # icon = QIcon(icon)
         # box = redRWidgetBox(widget,orientation='horizontal')
         # box.layout().addWidget(icon)
         # box.layout().addWidget(self)
     # else:
     self.controlArea.layout().addWidget(self)
     if icon:
         label = "<img style='margin-left:5px' src=\"%s\" /> %s" % (icon, label)
     self.setText(label)
     self.setWordWrap(wordWrap)
Example #28
0
    def __init__(self, parent = None, layout = 'vertical',title=None, callback = None, **kwargs):
        kwargs.setdefault('includeInReports', True)
        kwargs.setdefault('sizePolicy', QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred))
        QDialog.__init__(self,parent)
        widgetState.__init__(self, self, 'dialog',**kwargs)
        

        if title:
            self.setWindowTitle(title)
        if layout == 'horizontal':
            self.setLayout(QHBoxLayout())
        else:
            self.setLayout(QVBoxLayout())
        if callback:
            QObject.connect(self, SIGNAL('accepted()'), callback)
            QObject.connect(self, SIGNAL('rejected()'), callback)
Example #29
0
 def __init__(self,widget, addToLayout = 1, alignment=Qt.AlignTop, spacing = -1, margin = -1,**kwargs):
     kwargs.setdefault('includeInReports', True)
     kwargs.setdefault('sizePolicy', QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred))
     widgetState.__init__(self,widget, _('GridBox'),**kwargs)
     QWidget.__init__(self,self.controlArea)
     
     self.controlArea.layout().addWidget(self)
     
     self.setLayout(QGridLayout())
     
     self.controlArea.layout().setAlignment(alignment)            
     if spacing == -1: spacing = 4
     self.layout().setSpacing(spacing)
     if margin == -1: margin = 0
     self.layout().setMargin(margin)
     self.widgetArray = {}
Example #30
0
 def __init__(self,widget,label = '', wordWrap=True,**kwargs):
     kwargs.setdefault('includeInReports', False)
     kwargs.setdefault('sizePolicy', QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred))
     widgetState.__init__(self, widget, 'statusLabel',**kwargs)
     QLabel.__init__(self,self.controlArea)
     
     box = redRWidgetBox(self.controlArea,orientation='horizontal')
     
     self.controlArea.layout().addWidget(box)
     box.layout().addWidget(self)
     
     #self.statusIndicator = redRwidgetLabel(box,label='aaaaa  ')
     #widget.layout().addWidget(self.statusIndicator)
     self.status = 0
     self.setText(label)
     self.setWordWrap(wordWrap)
Example #31
0
    def __init__(self,
                 parent=None,
                 layout='vertical',
                 title=None,
                 callback=None):
        QDialog.__init__(self, parent)
        widgetState.__init__(self, self, 'dialog', includeInReports=True)

        if title:
            self.setWindowTitle(title)
        if layout == 'horizontal':
            self.setLayout(QHBoxLayout())
        else:
            self.setLayout(QVBoxLayout())
        if callback:
            QObject.connect(self, SIGNAL('accepted()'), callback)
            QObject.connect(self, SIGNAL('rejected()'), callback)
Example #32
0
    def __init__(self,widget, orientation='vertical', addSpace=False, includeInReports=True,
    sizePolicy = None, margin = -1, spacing = -1, addToLayout = 1, alignment=Qt.AlignTop, helpButton = False):

        widgetState.__init__(self,widget, _('WidgetBox'),includeInReports)
        QWidget.__init__(self,self.controlArea)
            
        self.controlArea.layout().addWidget(self)
        # self.setFlat(flat)
        # if widget and widget.layout():
            # widget.layout().addWidget(self)
        
        try:
            if isinstance(orientation, QLayout):
                self.setLayout(orientation)
            elif orientation == 'horizontal' or not orientation:
                self.setLayout(QHBoxLayout())
            elif orientation == 'grid':
                self.setLayout(QGridLayout())
            else:
                self.setLayout(QVBoxLayout())
        except:
            self.setLayout(QVBoxLayout())
            
        if self.layout() == 0 or self.layout() == None:
            self.setLayout(QVBoxLayout())
        if helpButton:
            icon = QPixmap(os.path.join(redREnviron.directoryNames['redRDir'], 'canvas', 'icons', 'information.png'))
            tlabel = QLabel()
            tlabel.setPixmap(icon)
            self.layout().addWidget(tlabel)

            
        self.controlArea.layout().setAlignment(alignment)            

        if spacing == -1: spacing = 8
        self.layout().setSpacing(spacing)
        if margin == -1: margin = 0
        if margin != -1:
            self.layout().setMargin(margin)
        if widget:
            if addSpace and isinstance(addSpace, int):
                separator(self.controlArea, 0, addSpace)
            elif addSpace:
                separator(self.controlArea)
        if sizePolicy:
            self.setSizePolicy(sizePolicy)
    def __init__(self, widget, parent, graph, autoSend = 0, 
    buttons = (1, 4, 5, 0, 6, 7), name = "Zoom / Select", exclusiveList = "__toolbars"):
        widgetState.__init__(self, widget,'zoomSelectToolbar',includeInReports=False)
        if not hasattr(zoomSelectToolbar, "builtinFunctions"):
            zoomSelectToolbar.builtinFunctions = \
                 (None,
                 (_("Zooming"), "buttonZoom", "activateZooming", QIcon(dlg_zoom), Qt.ArrowCursor, 1),
                 (_("Panning"), "buttonPan", "activatePanning", QIcon(dlg_pan), Qt.OpenHandCursor, 1),
                 (_("Selection"), "buttonSelect", "activateSelection", QIcon(dlg_select), Qt.CrossCursor, 1),
                 (_("Rectangle selection"), "buttonSelectRect", "activateRectangleSelection", QIcon(dlg_rect), Qt.CrossCursor, 1),
                 (_("Polygon selection"), "buttonSelectPoly", "activatePolygonSelection", QIcon(dlg_poly), Qt.CrossCursor, 1),
                 (_("Remove last selection"), "buttonRemoveLastSelection", "removeLastSelection", QIcon(dlg_undo), None, 0),
                 (_("Remove all selections"), "buttonRemoveAllSelections", "removeAllSelections", QIcon(dlg_clear), None, 0),
                 #("Send selections", "buttonSendSelections", "sendData", QIcon(dlg_send), None, 0),
                 (_("Zoom to extent"), "buttonZoomExtent", "zoomExtent", QIcon(dlg_zoom_extent), None, 0),
                 (_("Zoom selection"), "buttonZoomSelection", "zoomSelection", QIcon(dlg_zoom_selection), None, 0)
                )

        QGroupBox.__init__(self, name, parent)
        self.setLayout(QHBoxLayout())
        self.layout().setMargin(6)
        self.layout().setSpacing(4)
        if parent.layout():
            parent.layout().addWidget(self)

        self.graph = graph # save graph. used to send signals
        self.exclusiveList = exclusiveList

        self.widget = None
        self.functions = [type(f) == int and zoomSelectToolbar.builtinFunctions[f] or f for f in buttons]
        for b, f in enumerate(self.functions):
            if not f:
                self.layout().addSpacing(10)
            else:
                button = createButton(self, f[0], lambda x=b: self.action(x), f[3], toggle = f[5])
                setattr(self, f[1], button)
                if f[1] == "buttonSendSelections":
                    button.setEnabled(not autoSend)

        if not hasattr(widget, exclusiveList):
            setattr(widget, exclusiveList, [self])
        else:
            getattr(widget, exclusiveList).append(self)

        self.widget = widget    # we set widget here so that it doesn't affect the value of self.widget.toolbarSelection
        self.action(0)
Example #34
0
    def __init__(self,widget, label=None, displayLabel=True, Rdata=None, editable=False, rows=None, columns=None,
    sortable=False, selectionMode = -1, addToLayout = 1,callback=None,**kwargs):
        kwargs.setdefault('includeInReports', True)
        kwargs.setdefault('sizePolicy', QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred))
        widgetState.__init__(self,widget, widget.label,**kwargs)
        if displayLabel:
            mainBox = groupBox(self.controlArea,label=label, orientation='vertical')
        else:
            mainBox = widgetBox(self.controlArea,orientation='vertical')
        
        QTableView.__init__(self,mainBox)
        mainBox.layout().addWidget(self)

        
        self.R = Rcommand
        self.sortIndex = None
        self.oldSortingIndex = None
        self.Rdata = None
        self.parent = widget
        self.tm=None
        self.editable=editable
        
        
        self.setAlternatingRowColors(True)
        
        if widget and addToLayout and widget.layout():
            widget.layout().addWidget(self)
        elif widget and addToLayout:
            try:
                widget.addWidget(self)
            except: # there seems to be no way to add this widget
                pass
        if selectionMode != -1:
            self.setSelectionMode(selectionMode)
                
        if Rdata:
            self.setRTable(Rdata)
        if sortable:
            self.setSortingEnabled(True)
            self.connect(self.horizontalHeader(), SIGNAL("sectionClicked(int)"), self.sort)
        # if editable:
            # self.horizontalHeader().hide()
            # self.verticalHeader().hide()
        if callback:
            QObject.connect(self, SIGNAL('cellClicked(int, int)'), callback)
Example #35
0
    def __init__(self,widget,label=None, displayLabel=True, buttons=None,toolTips = None, setChecked = None,
    orientation='vertical',callback = None,**kwargs):
        kwargs.setdefault('includeInReports', True)
        kwargs.setdefault('sizePolicy', QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred))
        QWidget.__init__(self,widget)
        widgetState.__init__(self,widget,label,**kwargs)
        
        
        self.label = label
        

        if displayLabel:
            self.box = groupBox(self.controlArea,label=label,orientation=orientation)
            self.controlArea.layout().addWidget(self.box)
        else:
            self.box = widgetBox(self.controlArea,orientation=orientation)

        self.controlArea.layout().setAlignment(Qt.AlignTop | Qt.AlignLeft)
        self.box.setSizePolicy(QSizePolicy(QSizePolicy.MinimumExpanding,
        QSizePolicy.Preferred))
        # if orientation=='vertical':
            # self.box.setSizePolicy(QSizePolicy(QSizePolicy.Preferred,
            # QSizePolicy.MinimumExpanding))
        # else:
            # self.box.setSizePolicy(QSizePolicy(QSizePolicy.MinimumExpanding,
            # QSizePolicy.Preferred))
        
        self.items = OrderedDict()
        self.buttons = QButtonGroup(self.box)
        if buttons:
            self.addButtons(buttons)

        # for i,b in zip(range(len(buttons)),buttons):
            # w = QRadioButton(b)
            # if toolTips:
                # w.setToolTip(toolTips[i])
            # self.buttons.addButton(w)
            # self.box.layout().addWidget(w)

        if callback:
            QObject.connect(self.buttons, SIGNAL('buttonClicked(int)'), callback)

        if setChecked:
            self.setChecked(setChecked)
Example #36
0
    def __init__(self,widget, orientation='vertical', addSpace=False, margin = -1, spacing = -1, addToLayout = 1, alignment=Qt.AlignTop, helpButton = False, **kwargs):
        kwargs.setdefault('includeInReports', True)
        kwargs.setdefault('sizePolicy', QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred))
        widgetState.__init__(self,widget, _('WidgetBox'), **kwargs)
        QWidget.__init__(self,self.controlArea)
            
        self.controlArea.layout().addWidget(self)
        # self.setFlat(flat)
        # if widget and widget.layout():
            # widget.layout().addWidget(self)
        
        try:
            if isinstance(orientation, QLayout):
                self.setLayout(orientation)
            elif orientation == 'horizontal' or not orientation:
                self.setLayout(QHBoxLayout())
            elif orientation == 'grid':
                self.setLayout(QGridLayout())
            else:
               self.setLayout(QVBoxLayout())
        except:
            self.setLayout(QVBoxLayout())
            
        if self.layout() == 0 or self.layout() == None:
            self.setLayout(QVBoxLayout())
        if helpButton:
            icon = QPixmap(os.path.join(redREnviron.directoryNames['redRDir'], 'canvas', 'icons', 'information.png'))
            tlabel = QLabel()
            tlabel.setPixmap(icon)
            self.layout().addWidget(tlabel)

            
        self.controlArea.layout().setAlignment(alignment)            

        if spacing == -1: spacing = 4
        self.layout().setSpacing(spacing)
        if margin == -1: margin = 0
        if margin != -1:
            self.layout().setMargin(margin)
        if widget:
            if addSpace and isinstance(addSpace, int):
                separator(self.controlArea, 0, addSpace)
            elif addSpace:
                separator(self.controlArea)
Example #37
0
    def __init__(self,widget, label = None, displayLabel=True, orientation='vertical', addSpace=False, 
    sizePolicy = None, margin = -1, spacing = -1, flat = 0,alignment=Qt.AlignTop, **kwargs):        
        kwargs.setdefault('includeInReports', True)
        kwargs.setdefault('sizePolicy', QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred))
        if label:
            widgetState.__init__(self,widget,label,**kwargs)
        else:
            widgetState.__init__(self,widget,_('Group Box'),**kwargs)
        
        if displayLabel:
            QGroupBox.__init__(self,label)
        else:
            QGroupBox.__init__(self)
       
        self.label = label
        self.controlArea.layout().addWidget(self)
        
        self.controlArea.layout().setAlignment(alignment)            

        try:
            if isinstance(orientation, QLayout):
                self.setLayout(orientation)
            elif orientation == 'horizontal' or not orientation:
                self.setLayout(QHBoxLayout())
            else:
                self.setLayout(QVBoxLayout())
        except:
            self.setLayout(QVBoxLayout())
            
        if self.layout() == 0 or self.layout() == None:
            self.setLayout(QVBoxLayout())

        if spacing == -1: spacing = 8
        self.layout().setSpacing(spacing)
        if margin != -1:
            self.layout().setMargin(margin)
        if widget:
            if addSpace and isinstance(addSpace, int):
                separator(self.controlArea, 0, addSpace)
            elif addSpace:
                separator(self.controlArea)
        
        if sizePolicy:
            self.setSizePolicy(sizePolicy)
Example #38
0
    def __init__(self, widget, label = None, displayLabel=False, sortable=True,
    orientation='vertical', callback = None, **kwargs):
        kwargs.setdefault('includeInReports', True)
        kwargs.setdefault('sizePolicy', QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred))
        widgetState.__init__(self,widget,label,**kwargs)

        QTreeWidget.__init__(self, self.controlArea)
        self.setSortingEnabled(sortable)
        if displayLabel:
            self.hb = widgetBox(self.controlArea,orientation=orientation)
            widgetLabel(self.hb, label)
            if width != -1:
                sb = widgetBox(self.hb)
                sb.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
            self.hb.layout().addWidget(self)
        else:
            self.controlArea.layout().addWidget(self)
        if callback:
            QObject.connect(self, SIGNAL('currentItemChanged(QTreeWidgetItem*, QTreeWidgetItem*)'), callback)
Example #39
0
 def __init__(self,widget,label=None, displayLabel=True,includeInReports=True, 
 url=None,orientation='vertical', followHere = False):
     widgetState.__init__(self,widget,label,includeInReports)
     QtWebKit.QWebView.__init__(self,self.controlArea)
     
     if displayLabel:
         hb = widgetBox(self.controlArea,orientation=orientation)
         widgetLabel(hb, label)
         hb.layout().addWidget(self)
     else:
         self.controlArea.layout().addWidget(self)
 
     self.page().setLinkDelegationPolicy(QtWebKit.QWebPage.DelegateAllLinks)
     if not followHere:
         self.connect(self, SIGNAL('linkClicked(QUrl)'), self.followLink)
     if url:
         try:
             self.load(QUrl(url))
         except: pass 
Example #40
0
    def __init__(self,widget,label = None, displayLabel= True, buttons = None,toolTips = None, setChecked=None,
    orientation='vertical',callback = None, **kwargs):
        kwargs.setdefault('includeInReports', True)
        kwargs.setdefault('sizePolicy', QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred))
        """Constructor, common parameters will be widget, label, buttons (a list or list-tuple of key values for buttons), toolTips (a list of toolTips for the buttons), and setChecked (a list of keys to check from the buttons)"""
        if toolTips and len(toolTips) != len(buttons):
            raise RuntimeError(_('Number of buttons and toolTips must be equal'))
 
        QWidget.__init__(self,widget)
        widgetState.__init__(self,widget,label,**kwargs)
        

        self.controlArea.layout().addWidget(self)

        if displayLabel:
            self.box = groupBox(self.controlArea,label=label,orientation=orientation)
            # self.layout().addWidget(self.box)
        else:
            self.box = widgetBox(self.controlArea,orientation=orientation)
        
        self.controlArea.layout().setAlignment(Qt.AlignTop | Qt.AlignLeft)
        self.box.setSizePolicy(QSizePolicy(QSizePolicy.MinimumExpanding,
        QSizePolicy.Preferred))
        
        # if orientation=='vertical':
            # self.box.setSizePolicy(QSizePolicy(QSizePolicy.Preferred,
            # QSizePolicy.MinimumExpanding))
        # else:
            # self.box.setSizePolicy(QSizePolicy(QSizePolicy.MinimumExpanding,
            # QSizePolicy.Preferred))
            
        self.label = label
        self.items = OrderedDict()
        self.buttons = QButtonGroup(self.box)
        self.buttons.setExclusive(False)
        if buttons:
            self.addButtons(buttons)


        if callback:
            QObject.connect(self.buttons, SIGNAL('buttonClicked(int)'), callback)
        if setChecked:
            self.setChecked(setChecked)
Example #41
0
    def __init__(self,widget,text='', label=None, displayLabel=True, includeInReports=True,
    id=None, orientation='horizontal', toolTip = None,  width = 0, callback = None, textChangedCallBack=None,
    sp='shrinking', **args):

        widgetState.__init__(self,widget,label,includeInReports)
        QLineEdit.__init__(self,widget)
        
        if displayLabel:
            self.hb = widgetBox(self.controlArea,orientation=orientation, spacing=2)
            if sp == 'shrinking':
                self.hb.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred)
            lb = widgetLabel(self.hb, label)
            if width != -1:
                sb = widgetBox(self.hb)
                sb.setSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.Preferred)
            self.hb.layout().addWidget(self)
            self.hb.layout().setAlignment(lb,Qt.AlignRight)
        else:
            self.controlArea.layout().addWidget(self)
        
        if toolTip and displayLabel: 
            self.hb.setToolTip(toolTip)
        elif toolTip:
            self.setToolTip(toolTip)
            
        if width == 0:
            self.setMaximumWidth(175)
            self.setMinimumWidth(175)
        elif width == -1:
            pass
        else:
            self.setMaximumWidth(width)
            self.setMinimumWidth(width)
        self.setText(text)
        self.id = id
        self.label = label
        # self.setText('asdf')
        if callback:
            QObject.connect(self, SIGNAL('returnPressed()'), callback)
        
        if textChangedCallBack:
            QObject.connect(self, SIGNAL('textEdited(QString)'), textChangedCallBack)
Example #42
0
    def __init__(self,
                 widget,
                 orientation=QVBoxLayout(),
                 addSpace=False,
                 sizePolicy=None,
                 margin=-1,
                 spacing=-1,
                 addToLayout=1):

        widgetState.__init__(self, widget, 'scrollArea', includeInReports=True)
        QScrollArea.__init__(self, self.controlArea)

        if margin == -1: margin = 0
        self.controlArea.layout().addWidget(self)

        try:
            if isinstance(orientation, QLayout):
                self.setLayout(orientation)
            elif orientation == 'horizontal' or not orientation:
                self.setLayout(QHBoxLayout())
            else:
                self.setLayout(QVBoxLayout())
        except:
            self.setLayout(QVBoxLayout())

        if self.layout() == 0 or self.layout() == None:
            self.setLayout(QVBoxLayout())

        if sizePolicy:
            self.setSizePolicy(sizePolicy)
        # else:
        # self.setSizePolicy(QSizePolicy.Fixed,QSizePolicy.Fixed)

        if spacing == -1: spacing = 4
        self.layout().setSpacing(spacing)
        if margin != -1:
            self.layout().setMargin(margin)

        if addSpace and isinstance(addSpace, int):
            separator(widget, 0, addSpace)
        elif addSpace:
            separator(widget)
Example #43
0
    def __init__(self, widget, label = None, displayLabel=False, includeInReports=True, 
    orientation='vertical', toolTip = None, callback = None):
        
        widgetState.__init__(self,widget,label,includeInReports)

        QTreeWidget.__init__(self, self.controlArea)
        
        if displayLabel:
            self.hb = widgetBox(self.controlArea,orientation=orientation)
            widgetLabel(self.hb, label)
            if width != -1:
                sb = widgetBox(self.hb)
                sb.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
            self.hb.layout().addWidget(self)
        else:
            self.controlArea.layout().addWidget(self)

        if toolTip: self.setToolTip(toolTip)
        if callback:
            QObject.connect(self, SIGNAL('currentItemChanged(QTreeWidgetItem*, QTreeWidgetItem*)'), callback)
Example #44
0
    def __init__(self,widget,label=None, displayLabel=True, includeInReports=True,
    buttons=None,toolTips = None, setChecked = None,
    orientation='vertical',callback = None, **args):
        
        QWidget.__init__(self,widget)
        widgetState.__init__(self,widget,label,includeInReports,**args)
        
        self.controlArea.layout().setAlignment(Qt.AlignTop | Qt.AlignLeft)
        self.label = label
        

        if displayLabel:
            self.box = groupBox(self.controlArea,label=label,orientation=orientation)
            self.controlArea.layout().addWidget(self.box)
        else:
            self.box = widgetBox(self.controlArea,orientation=orientation)

        # if orientation=='vertical':
            # self.box.setSizePolicy(QSizePolicy(QSizePolicy.Preferred,
            # QSizePolicy.MinimumExpanding))
        # else:
            # self.box.setSizePolicy(QSizePolicy(QSizePolicy.MinimumExpanding,
            # QSizePolicy.Preferred))
        
        self.items = OrderedDict()
        self.buttons = QButtonGroup(self.box)
        if buttons:
            self.addButtons(buttons)

        # for i,b in zip(range(len(buttons)),buttons):
            # w = QRadioButton(b)
            # if toolTips:
                # w.setToolTip(toolTips[i])
            # self.buttons.addButton(w)
            # self.box.layout().addWidget(w)

        if callback:
            QObject.connect(self.buttons, SIGNAL('buttonClicked(int)'), callback)

        if setChecked:
            self.setChecked(setChecked)
Example #45
0
    def __init__(self,
                 widget,
                 label=None,
                 displayLabel=True,
                 includeInReports=True,
                 data=None,
                 rows=0,
                 columns=0,
                 sortable=False,
                 selectionMode=-1,
                 addToLayout=1,
                 callback=None):

        widgetState.__init__(self, widget, label, includeInReports)

        if displayLabel:
            mainBox = groupBox(self.controlArea,
                               label=label,
                               orientation='vertical')
        else:
            mainBox = widgetBox(self.controlArea, orientation='vertical')

        QTableWidget.__init__(self, rows, columns, widget)
        mainBox.layout().addWidget(self)

        self.sortIndex = None
        self.oldSortingIndex = None
        self.data = None

        ###
        if selectionMode != -1:
            self.setSelectionMode(selectionMode)
        if data:
            self.setTable(data)
        if sortable:
            self.setSortingEnabled(True)
            self.connect(self.horizontalHeader(),
                         SIGNAL("sectionClicked(int)"), self.sort)
        if callback:
            QObject.connect(self, SIGNAL('cellClicked(int, int)'), callback)
Example #46
0
    def __init__(self,widget,label = _('Commit'), callback = None, processOnInput=None,processOnChange=None,
    icon=None, orientation='horizontal', width = None, height = None, alignment=Qt.AlignRight, toggleButton = False,**kwargs):
        kwargs.setdefault('includeInReports', False)
        kwargs.setdefault('sizePolicy', QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred))
        widgetState.__init__(self,widget,label,**kwargs)
        icon = str(redREnviron.directoryNames['libraryDir']+'/base/icons/fork.png').replace('\\', '/')

        box = widgetBox(self.controlArea,orientation=orientation,alignment=alignment,includeInReports=False)
        
        box2 = widgetBox(box,orientation='vertical',margin=0,spacing=0)
        if processOnChange is dict:
            self.processOnChangeState = checkBox(box2, label=_('processOnChange'), displayLabel=False,
            buttons = [processOnInput['name']],
            toolTips = [processOnInput['toolTip']]
            )
        elif processOnChange == True:
            self.processOnChangeState = checkBox(box2, label=_('processOnChange'), displayLabel=False,
            buttons = [_('Process On Parameter Change')],
            toolTips = [_('Try to process as soon as a parameter is changed.')]
            )
        
        if processOnInput is dict:
            self.processOnInputState = checkBox(box2, label=_('processOnInput'), displayLabel=False,
            buttons = [processOnInput['name']],
            toolTips = [processOnInput['toolTip']]
            )
        elif processOnInput == True:
            self.processOnInputState = checkBox(box2, label=_('processOnInput'), displayLabel=False,
            buttons = [_('Process On Data Input')],
            toolTips = [_('Try to process as soon as data is received by the widget. The current state of parameters will be applied.')]
            )

        button.__init__(self, widget = box, label = label, callback = callback, 
        icon = icon, width = width, height = 35, 
        toggleButton = toggleButton,**kwargs)
        
        self.setIcon(QIcon(icon))
        self.setIconSize(QSize(20, 20))
Example #47
0
    def __init__(self,widget,html='',label=None, displayLabel=True, orientation='vertical', alignment=None, editable=True, printable=False,clearable=False,**kwargs):
        kwargs.setdefault('includeInReports', True)
        kwargs.setdefault('sizePolicy', QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding))
        widgetState.__init__(self,widget, label,**kwargs)

        QTextEdit.__init__(self,self.controlArea)
        self.label = label
        if displayLabel:
            self.hb = groupBox(self.controlArea,label=label,orientation=orientation)
        else:
            self.hb = widgetBox(self.controlArea,orientation=orientation)

        self.hb.layout().addWidget(self)
        if alignment:
            self.controlArea.layout().setAlignment(self.hb,alignment)
        if printable:
            button(self.hb, _("Print"), self.printMe)
        if clearable:
            button(self.hb, _("Clear"), callback = self.clear)
        if not editable:
            self.setReadOnly(True)
        self.setFontFamily('Courier')
        self.insertHtml(html)
Example #48
0
 def __init__(self,widget,label=None, displayLabel=True, url=None,orientation='vertical', followHere = False, **kwargs):
     kwargs.setdefault('includeInReports', True)
     kwargs.setdefault('sizePolicy', QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred))
     widgetState.__init__(self,widget,label, **kwargs)
     QtWebKit.QWebView.__init__(self,self.controlArea)
     # factory = QtWebKit.QWebPluginFactory()
     # self.page().setPluginFactory(factory)
     self.controlArea.setSizePolicy(QSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding))
     self.setSizePolicy(QSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding))
     if displayLabel:
         hb = widgetBox(self.controlArea,orientation=orientation)
         widgetLabel(hb, label)
         hb.layout().addWidget(self)
     else:
         self.controlArea.layout().addWidget(self)
 
     self.page().setLinkDelegationPolicy(QtWebKit.QWebPage.DelegateAllLinks)
     if not followHere:
         self.connect(self, SIGNAL('linkClicked(QUrl)'), self.followLink)
     if url:
         try:
             self.load(QUrl(url))
         except: pass 
Example #49
0
 def __init__(self, caption = _('Search Dialog'), url = '', icon = None, orientation = 'horizontal'):
     kwargs.setdefault('includeInReports', False)
     kwargs.setdefault('sizePolicy', QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred))
     widgetState.__init__(self,None, _('SearchDialog'),**kwargs)
     QDialog.__init__(self)
     
     self.setWindowTitle(caption)
     try:
         if isinstance(orientation, QLayout):
             self.setLayout(orientation)
         elif orientation == 'horizontal' or not orientation:
             self.setLayout(QHBoxLayout())
         else:
             self.setLayout(QVBoxLayout())
     except:
         self.setLayout(QVBoxLayout())
     self.thisLayout = self.layout()
     self.webView = webViewBox(self,label=_('Search Dialog'), displayLabel=False)
     self.setMinimumSize(600, 400)
     if url and url != '':
         self.webView.load(QUrl(url))
     
     if icon:
         self.setWindowIcon(icon)
Example #50
0
    def __init__(self,widget,text='', label=None, displayLabel=True, id=None, orientation='horizontal', width = 0, callback = None, textChangedCallBack=None, sp='shrinking', **kwargs):
        kwargs.setdefault('includeInReports', True)
        kwargs.setdefault('sizePolicy', QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred))
        widgetState.__init__(self,widget,label,**kwargs)
        QLineEdit.__init__(self,widget)
        
        if displayLabel:
            self.hb = widgetBox(self.controlArea,orientation=orientation, spacing=2)
            if sp == 'shrinking':
                self.hb.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred)
            lb = widgetLabel(self.hb, label)
            if width != -1:
                sb = widgetBox(self.hb)
                sb.setSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.Preferred)
            self.hb.layout().addWidget(self)
            self.hb.layout().setAlignment(lb,Qt.AlignRight)
        else:
            self.controlArea.layout().addWidget(self)

        if width == 0:
            self.setMaximumWidth(175)
            self.setMinimumWidth(175)
        elif width == -1:
            pass
        else:
            self.setMaximumWidth(width)
            self.setMinimumWidth(width)
        self.setText(text)
        self.id = id
        self.label = label
        # self.setText('asdf')
        if callback:
            QObject.connect(self, SIGNAL('returnPressed()'), callback)
        
        if textChangedCallBack:
            QObject.connect(self, SIGNAL('textEdited(QString)'), textChangedCallBack)
Example #51
0
    def __init__(self, widget, label='', wordWrap=True):
        widgetState.__init__(self,
                             widget,
                             'statusLabel',
                             includeInReports=False)
        QLabel.__init__(self, self.controlArea)
        # if icon:
        # icon = QIcon(icon)
        # box = redRWidgetBox(widget,orientation='horizontal')
        # box.layout().addWidget(icon)
        # box.layout().addWidget(self)
        # else:
        #widget.layout().addWidget(self)

        box = redRWidgetBox(self.controlArea, orientation='horizontal')

        self.controlArea.layout().addWidget(box)
        box.layout().addWidget(self)

        #self.statusIndicator = redRwidgetLabel(box,label='aaaaa  ')
        #widget.layout().addWidget(self.statusIndicator)
        self.status = 0
        self.setText(label)
        self.setWordWrap(wordWrap)
Example #52
0
    def __init__(self,
                 widget,
                 label=_('Commit'),
                 callback=None,
                 processOnInput=None,
                 processOnChange=None,
                 disabled=0,
                 icon=None,
                 orientation='horizontal',
                 toolTip=None,
                 width=None,
                 height=None,
                 alignment=Qt.AlignRight,
                 toggleButton=False):

        widgetState.__init__(self, widget, label, includeInReports=False)
        icon = str(redREnviron.directoryNames['libraryDir'] +
                   '/base/icons/fork.png').replace('\\', '/')

        box = widgetBox(self.controlArea,
                        orientation=orientation,
                        alignment=alignment,
                        includeInReports=False)

        box2 = widgetBox(box, orientation='vertical', margin=0, spacing=0)
        if processOnChange is dict:
            self.processOnChangeState = checkBox(
                box2,
                label=_('processOnChange'),
                displayLabel=False,
                buttons=[processOnInput['name']],
                toolTips=[processOnInput['toolTip']])
        elif processOnChange == True:
            self.processOnChangeState = checkBox(
                box2,
                label=_('processOnInput'),
                displayLabel=False,
                buttons=[_('Process On Parameter Change')],
                toolTips=[
                    _('Try to process as soon as a parameter is changed.')
                ])

        if processOnInput is dict:
            self.processOnInputState = checkBox(
                box2,
                label=_('processOnInput'),
                displayLabel=False,
                buttons=[processOnInput['name']],
                toolTips=[processOnInput['toolTip']])
        elif processOnInput == True:
            self.processOnInputState = checkBox(
                box2,
                label=_('processOnInput'),
                displayLabel=False,
                buttons=[_('Process On Data Input')],
                toolTips=[
                    _('Try to process as soon as data is received by the widget. The current state of parameters will be applied.'
                      )
                ])

        button.__init__(self,
                        widget=box,
                        label=label,
                        callback=callback,
                        disabled=disabled,
                        icon=icon,
                        toolTip=toolTip,
                        width=width,
                        height=35,
                        toggleButton=toggleButton)

        self.setIcon(QIcon(icon))
        self.setIconSize(QSize(20, 20))
Example #53
0
    def __init__(self,widget,label=None, displayLabel=True, Rdata=None, 
    editable=False, sortable=True, filterable=False,
    selectionBehavior=QAbstractItemView.SelectRows, 
    selectionMode = QAbstractItemView.ExtendedSelection, 
    showResizeButtons = True,
    onFilterCallback = None,
    callback=None,
    selectionCallback=None,**kwargs):
        kwargs.setdefault('includeInReports', True)
        kwargs.setdefault('sizePolicy', QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred))
        widgetState.__init__(self,widget,label,**kwargs)
        
        if displayLabel:
            mainBox = groupBox(self.controlArea,label=label, orientation='vertical')
        else:
            mainBox = widgetBox(self.controlArea,orientation='vertical')
        self.label = label
        
        QTableView.__init__(self,self.controlArea)
        mainBox.layout().addWidget(self)
        box = widgetBox(mainBox,orientation='horizontal')
        leftBox = widgetBox(box,orientation='horizontal')
        if filterable:
            self.clearButton = button(leftBox,label=_('Clear All Filtering'), callback=self.clearFiltering)
        self.dataInfo = widgetLabel(leftBox,label='',wordWrap=False) 
        box.layout().setAlignment(leftBox, Qt.AlignLeft)

        
        if showResizeButtons:
            resizeColsBox = widgetBox(box, orientation="horizontal")
            resizeColsBox.layout().setAlignment(Qt.AlignRight)
            box.layout().setAlignment(resizeColsBox, Qt.AlignRight)
            widgetLabel(resizeColsBox, label = _("Resize columns: "))
            button(resizeColsBox, label = "+", callback=self.increaseColWidth, 
            toolTip = _("Increase the width of the columns"), width=30)
            button(resizeColsBox, label = "-", callback=self.decreaseColWidth, 
            toolTip = _("Decrease the width of the columns"), width=30)
            button(resizeColsBox, label = _("Resize To Content"), callback=self.resizeColumnsToContents, 
            toolTip = _("Set width based on content size"))

        
        self.R = Rcommand
        self.Rdata = None
        self.filteredData = None
        self.sortIndex = None
        self.criteriaList = {}
        self.parent = widget
        self.tm=None
        self.sortable=sortable
        self.editable=editable
        self.filterable=filterable
        self.onFilterCallback = onFilterCallback
        self.selectionCallback = selectionCallback
        # self.selections = QItemSelection()
        self.working = False

        self.setHorizontalHeader(myHeaderView(self))
        self.setSelectionBehavior(selectionBehavior)
        self.setAlternatingRowColors(True)
        
        # self.horizontalHeader().setMovable(True)
        
        if selectionMode != -1:
            self.setSelectionMode(selectionMode)
    
        if Rdata:
            self.setRTable(Rdata)

        if editable:
            self.horizontalHeader().hide()
            self.verticalHeader().hide()
            
        if sortable:
            self.horizontalHeader().setSortIndicatorShown(True)
            self.horizontalHeader().setSortIndicator(-1,0)
        if filterable or sortable:
            self.horizontalHeader().setClickable(True)
            self.horizontalHeader().setContextMenuPolicy(Qt.CustomContextMenu)
            self.horizontalHeader().customContextMenuRequested.connect(self.headerClicked)

            
        if callback:
            QObject.connect(self, SIGNAL('clicked (QModelIndex)'), callback)
Example #54
0
    def __init__(self, parent,label=None, displayLabel=True,includeInReports=True, name = '', data = None):
        ## want to init a graphics view with a new graphics scene, the scene will be accessable through the widget.
        widgetState.__init__(self,parent,label,includeInReports)
        
        QGraphicsView.__init__(self, self.controlArea)
        # if displayLabel:
            # self.controlArea = groupBox(parent,label=label, orientation='vertical')
        # else:
            # self.controlArea = widgetBox(parent,orientation='vertical')
        
        #self.controlArea = widgetBox(parent)
        self.topArea = widgetBox(self.controlArea,
        sizePolicy = QSizePolicy(QSizePolicy.Minimum,QSizePolicy.Maximum),includeInReports=False)
        self.middleArea = widgetBox(self.controlArea)
        self.bottomArea = widgetBox(self.controlArea,includeInReports=False)
        
        self.middleArea.layout().addWidget(self)  # place the widget into the parent widget
        scene = QGraphicsScene()
        self.setScene(scene)
        self.parent = parent
        self.data = data
        
        self.widgetSelectionRect = None
        self.mainItem = None
        self.query = ''
        self.function = 'plot'
        self.layers = []
        self.image = 'plot'+unicode(time.time()) # the base file name without an extension
        self.imageFileName = ''
        self.currentScale = 1

    ################################
    ####   Themes              #####
    ################################
        
        
        self.options = {
            'device': {
                'Rcall': 'Cairo',
                'parameters': {
                    'type':{
                            'default':'svg',
                            'qtWidget': 'imageType'
                        }
                    ,'dpi':{
                            'default':'75',
                            'qtWidget': 'dpi'
                        }
                    ,'bg': {
                            'default':'#FFFFFF', 
                            'color': '#FFFFFF',
                            'qtWidget':'bgColor'
                            
                            }
                    ,'height': {
                            'default':400, 
                            'qtWidget': 'dheight'
                            }
                    ,'width': {
                            'default':400, 
                            'qtWidget': 'dwidth'
                            }
                    ,'units': {
                            'default':'px', 
                            'qtWidget': 'units'
                            }
                    }
                }
            ,'main': {
                'Rcall': 'plot',
                'parameters': {
                    'col': {
                        'default':None, 
                        'qtWidget':'colorSeries',
                        'series': '',
                        'seriesLen': 0,
                        'getFunction': self.getColorSeries,
                        'setFunction': self.setColorSeries,
                        }
                    ,'lty': {
                        'default':None, 
                        'qtWidget':'linesListBox',
                        'getFunction': self.getLineTypes,
                        'setFunction': self.setLineTypes,
                        }
                    ,'lwd': {
                        'default':None, 
                        'qtWidget':'lineWidth'
                        }
                    ,'pch': {
                        'default':None, 
                        'qtWidget':'pointListBox',
                        'getFunction': self.getLineTypes,
                        'setFunction': self.setLineTypes,
                        }
                }
            },
            'title': {
                'Rcall': 'title',
                'parameters': {
                    'main': {
                          'default':"Title", 
                          'qtWidget':'mainTitle' 
                          }
                    ,'xlab': {
                        'default':"XLab", 
                        'qtWidget':'xLab'
                        }
                    ,'ylab': {
                        'default':"YLab", 
                        'qtWidget':'yLab'
                        }   
                    ,'col.main': {
                          'default':'#000000', 
                          'qtWidget':'titleColor' 
                          }
                    ,'col.sub': {
                          'default':'#000000', 
                          'qtWidget':'subColor' 
                          }
                    ,'col.lab': {
                          'default':'#000000', 
                          'qtWidget':'labColor' 
                          }                        
                }
            },
            'par': {
                'Rcall':'par',
                'parameters': {
                    'cex.axis': {
                          'default':1, 
                          'qtWidget':'axisFont' 
                          }
                    ,'cex.lab': {
                          'default':1, 
                          'qtWidget':'labFont' 
                          }
                    ,'cex': {
                          'default':1, 
                          'qtWidget':'plotFont' 
                          }
                    ,'cex.main': {
                          'default':1, 
                          'qtWidget':'mainFont' 
                          }
                    ,'cex.sub': {
                          'default':1, 
                          'qtWidget':'subFont' 
                          }
                    ,'col.axis': {
                          'default':'#000000', 
                          'qtWidget':'axisColor' 
                          }
                    # ,'family': {
                          # 'default':'serif', 
                          # 'qtWidget':'fontCombo' 
                          # }
                }
            }
        }
        # ,'fg' : None
        # ,'legendNames' : None
        # ,'legendLocation' : "'bottomleft'"
        # }
        
        self.optionWidgets = {}
        self.colorList = ['#000000', '#ff0000', '#00ff00', '#0000ff']       


    ################################
    ####   Setup Tabs          #####
    ################################
        self.graphicOptionsButton = button(self.topArea,label='Graphic Options',
        toggleButton = True,callback=self.displayGraphicOptions)
        self.graphicOptionsWidget = widgetBox(self.topArea)
        self.graphicOptions = tabWidget(self.graphicOptionsWidget)
        self.graphicOptions.setFixedHeight(180)
        hbox = widgetBox(self.graphicOptionsWidget,orientation='horizontal',alignment= Qt.AlignLeft)
        self.resizeCheck = checkBox(hbox,label='resize',displayLabel=False,buttons={'true':'Resize Image'},setChecked='true')
        button(hbox,label='Update Graphic', alignment=Qt.AlignLeft, callback=self.plotMultiple)
        

        self.labels = self.graphicOptions.createTabPage('Main')
        self.points = self.graphicOptions.createTabPage('Points/Lines')
        self.advanced = self.graphicOptions.createTabPage('Advanced')
        #self.graphicOptions.hide()
        
        firstTab = widgetBox(self.labels,orientation='horizontal',alignment=Qt.AlignLeft | Qt.AlignTop)
        secondTab = widgetBox(self.points,orientation='horizontal',alignment=Qt.AlignLeft | Qt.AlignTop)
        advancedTab = widgetBox(self.advanced,orientation='vertical',alignment=Qt.AlignLeft | Qt.AlignTop)
    ################################
    ####   Advanced Tabs       #####
    ################################
        
        self.optionWidgets['extrasLineEdit'] = lineEdit(advancedTab, label = 'Advanced plotting parameters', 
        toolTip = 'Add extra parameters to the main plot.\nPlease see documentation for more details about parameters.')
        
        self.optionWidgets['onlyAdvanced'] = checkBox(advancedTab,
        buttons=['Only use the advanced options here'],
        label='advancedOnly',displayLabel=False)

    ################################
    ####   First Tabs          #####
    ################################
        imageBox = groupBox(firstTab,label='Image Properties', orientation='vertical',
        sizePolicy = QSizePolicy(QSizePolicy.Maximum ,QSizePolicy.Minimum))
        
        self.optionWidgets['imageType'] = comboBox(imageBox,label='Image Type',items=['svg','png'])
        self.optionWidgets['imageType'].setSizePolicy(QSizePolicy.MinimumExpanding,QSizePolicy.Minimum)
        
        hbox = widgetBox(imageBox,orientation='horizontal')
        self.optionWidgets['dheight'] = spinBox(hbox, label = 'Height', min = 1, max = 5000, value = 400)
        self.optionWidgets['dwidth'] = spinBox(hbox, label = 'Width', min = 1, max = 5000, value = 400)
        hbox = widgetBox(imageBox,orientation='horizontal')
        self.optionWidgets['units'] = comboBox(hbox,label='units',items=[('px','Pixel'),('in','Inches')])
        self.optionWidgets['dpi'] = comboBox(hbox,label='DPI',items=['75','100','150','auto'],editable=True)
        
        
        labelBox = groupBox(firstTab,label='Labels', orientation='vertical',
        sizePolicy = QSizePolicy(QSizePolicy.Maximum ,QSizePolicy.Minimum))
        
        self.optionWidgets['mainTitle'] = lineEdit(labelBox,label='Main Title')
        self.optionWidgets['xLab'] = lineEdit(labelBox,label='X Axis Label')        
        self.optionWidgets['yLab'] = lineEdit(labelBox,label='Y Axis Label')

        
        fontBox = groupBox(firstTab,label='Sizes', orientation='vertical',
        sizePolicy = QSizePolicy(QSizePolicy.Maximum ,QSizePolicy.Minimum))
        fontColumnBox = widgetBox(fontBox,orientation='horizontal')
        fontColumn1 = widgetBox(fontColumnBox,orientation='vertical')
        fontColumn2 = widgetBox(fontColumnBox,orientation='vertical')
        
        #self.optionWidgets['fontCombo'] = comboBox(fontColumn1, items = ['serif', 'sans', 'mono'], label='Font Family')
        
        self.optionWidgets['lineWidth'] = spinBox(fontColumn1,label='Point/Line Size',decimals=2,min=1,max=50)
        self.optionWidgets['plotFont'] = spinBox(fontColumn1, label = 'Plot Text Size',decimals=2, min = 1, max = 50)
        self.optionWidgets['axisFont'] = spinBox(fontColumn1, label = 'Axis Text Size',decimals=2, min = 1, max = 50)
        self.optionWidgets['mainFont'] = spinBox(fontColumn2, label = 'Title Text Size',decimals=2, min = 1, max = 50)
        self.optionWidgets['subFont'] = spinBox(fontColumn2, label = 'Subtitle Text Size',decimals=2, min = 1, max = 50)
        self.optionWidgets['labFont'] = spinBox(fontColumn2, label = ' XY Label Text Size',decimals=2, min = 1, max = 50)
        
        colorBox = groupBox(firstTab,label='Colors', orientation='vertical',
        sizePolicy = QSizePolicy(QSizePolicy.Maximum ,QSizePolicy.Minimum))
        
        hbox = widgetBox(colorBox,orientation='horizontal')

        self.optionWidgets['colorSeries'] = comboBox(hbox,label='Generate Colors Series',orientation='vertical',
        items = ['select','rainbow','heat.colors','terrain.colors','topo.colors','cm.colors'])
        self.optionWidgets['colorSeriesLen'] = spinBox(hbox,label='Length of Series',displayLabel=False, min=0, max=500)
        hbox.layout().setAlignment(self.optionWidgets['colorSeriesLen'].controlArea, Qt.AlignBottom)
        
        self.optionWidgets['bgColor'] = ColorIcon(colorBox,label='Background')

        #self.optionWidgets['customColors'] = button(colorBox,label='Custom Plot Colors',callback=self.setPlotColors)

    
    ################################
    ####   Second Tabs         #####
    ################################
        colorBox2 = groupBox(secondTab,label='Colors', orientation='vertical',
        sizePolicy = QSizePolicy(QSizePolicy.Maximum ,QSizePolicy.Minimum))
        
        # colorColumnBox = widgetBox(colorBox2,orientation='horizontal')
        # colorColumn1 = widgetBox(colorColumnBox,orientation='vertical')
        # colorColumn2 = widgetBox(colorColumnBox,orientation='vertical')
      
         
        self.optionWidgets['titleColor'] = ColorIcon(colorBox2,label='Title')
        self.optionWidgets['subColor'] = ColorIcon(colorBox2,label='Subtitle')
        self.optionWidgets['labColor'] = ColorIcon(colorBox2,label='Subtitle')
        self.optionWidgets['axisColor'] = ColorIcon(colorBox2,label='Axis')
        
        lineBox = groupBox(secondTab,label='Lines', orientation='vertical',
        sizePolicy = QSizePolicy(QSizePolicy.Maximum ,QSizePolicy.Minimum))
       
        self.optionWidgets['linesListBox'] = listBox(lineBox, label = 'Line types', displayLabel=False,
        selectionMode = QAbstractItemView.ExtendedSelection,
        items = [(1,'________'), (2,'- - - -'), (3,'........'), (4,'_._._._.'), 
        (5,'__ __ __'), (6,'__.__.__.')])
        
        
        
        pointBox = groupBox(secondTab,label='Points', orientation='vertical',
        sizePolicy = QSizePolicy(QSizePolicy.Maximum ,QSizePolicy.Minimum))
        
        items = []
        for i in range(1,26):
            items.append((i-1,QListWidgetItem(QIcon(os.path.join(redREnviron.directoryNames['picsDir'],
            'R icon (%d).png' %i)),'')))
        
        for i in range(32,128):
            items.append((i-1,'%s' % (chr(i))))
            
        self.optionWidgets['pointListBox'] = listBox(pointBox, label = 'Line types', displayLabel=False,
        selectionMode = QAbstractItemView.ExtendedSelection, items = items)
        


        self.setTheme(self.options)
    ################################
    ### right click menu     #######
    ################################
        self.menu = QMenu(self)
        save = self.menu.addMenu('Save As')
        save.addAction('Bitmap')
        save.addAction('PDF')
        save.addAction('Post Script')
        save.addAction('JPEG')
        self.menu.addAction('Copy')
        self.menu.addAction('Fit In Window')
        self.menu.addAction('Zoom Out')
        self.menu.addAction('Zoom In')
        self.menu.addAction('Undock')
        self.menu.addAction('Redock')
        
        self.dialog = QDialog()
        self.dialog.setWindowTitle('Red-R Graphics View' + name)
        self.dialog.setLayout(QHBoxLayout())
        
        self.standardImageType = 'svg'
        QObject.connect(self.dialog, SIGNAL('finished(int)'), self.dialogClosed)
Example #55
0
 def __init__(self, parent,label=_('Graph'), displayLabel=True,includeInReports=True, name = '', data = None):
     ## want to init a graphics view with a new graphics scene, the scene will be accessable through the widget.
     self.R = RSession.Rcommand
     self.require_librarys = RSession.require_librarys
     widgetState.__init__(self,parent,label,includeInReports)
     
     QGraphicsView.__init__(self, self.controlArea)
     if displayLabel:
         self.controlArea = groupBox(self.controlArea,label=label, orientation='vertical')
     else:
         self.controlArea = widgetBox(self.controlArea,orientation='vertical')
     
     #self.controlArea = widgetBox(parent)
     self.topArea = widgetBox(self.controlArea)
     self.middleArea = widgetBox(self.controlArea)
     self.bottomArea = widgetBox(self.controlArea)
     self.middleArea.layout().addWidget(self)  # place the widget into the parent widget
     scene = QGraphicsScene()
     self.setScene(scene)
     self.parent = self.controlArea
     self.widgetSelectionRect = None
     self.mainItem = None
     self.query = ''
     self.function = 'plot'
     self.data = data
     self.layers = []
     self._bg = None
     self._cex = None
     self._cexAxis = None
     self._cexLab = None
     self._cexMain = None
     self._cexSub = None
     self._col = None
     self._colAxis = None
     self._colMain = None
     self._colSub = None
     self._family = None
     self._fg = None
     self._lty = None
     self._lwd = None
     self._legendNames = None
     self._legendLocation = 'bottomleft'
     self._pch = None
     self.colorList = ['#000000', '#ff0000', '#00ff00', '#0000ff']
     self._replotAfterChange = True
     self._dheight = 4
     self._dwidth = 4
     self.image = 'plot'+unicode(time.time()) # the base file name without an extension
     self.imageFileName = ''
     self.currentScale = 1
     
     ## bottom menu bar
     self.menuBar = QMenuBar(self.bottomArea)
     self.bottomArea.layout().addWidget(self.menuBar)
     
     self.menuParameters = QMenu(_('Parameters'), self)
     colors = self.menuParameters.addMenu(_('Colors'))
     colors.addAction(_('Set Plotting Colors'), self.setPlotColors)
     colors.addAction(_('Set Axis Colors'), self.setAxisColors)
     colors.addAction(_('Set Label Colors'), self.setLabelColors)
     colors.addAction(_('Set Main Title Color'), self.setTitleColors)
     colors.addAction(_('Set Subtitle Color'), self.setSubtitleColors)
     colors.addAction(_('Set Forground Color'), self.setForgroundColors)
     colors.addAction(_('Set Background Color'), self.setBackgroundColors)
     
     font = self.menuParameters.addMenu(_('Font'))
     ffa = font.addMenu(_('Set Font Family'))
     
     legend = self.menuParameters.addMenu(_('Legend'))
     ll = legend.addMenu(_('Legend Location'))
     ll.addAction(_('Set to bottom right'), lambda x = 'bottomright': self._setLegendLocation(x))
     ll.addAction(_('Set to bottom left'), lambda x = 'bottomleft': self._setLegendLocation(x))
     ll.addAction(_('Set to top right'), lambda x = 'topleft': self._setLegendLocation(x))
     ll.addAction(_('Set to top left'), lambda x = 'topright': self._setLegendLocation(x))
     fontComboAction = QWidgetAction(font)
     self.fontCombo = comboBox(None, items = ['serif', 'sans', 'mono'], label='fonts', displayLabel=False,
         #'HersheySerif', 'HersheySans', 'HersheyScript',
         #'HersheyGothicEnglish', 'HersheyGothicGerman', 'HersheyGothicItalian', 'HersheySymbol', 'HersheySansSymbol'], 
         callback = self.setFontFamily)
     fontComboAction.setDefaultWidget(self.fontCombo)
     ffa.addAction(fontComboAction)
     #font.addAction(_('Set Font Magnification'), self.setFontMagnification)
     wb = widgetBox(None)
     self.fontMag = spinBox(wb, label = 'Font Magnification:', min = 0, max = 500, value = 100) #, callback = self.setFontMagnification)
     QObject.connect(self.fontMag, SIGNAL('editingFinished ()'), self.setFontMagnification) ## must define ourselves because the function calls the attribute and this causes an error in Qt
     magAction = QWidgetAction(font)
     magAction.setDefaultWidget(wb)
     font.addAction(magAction)
     
     self.menuParameters.setToolTip(_('Set the parameters of the rendered image.\nThese parameters are standard graphics parameters which may or may not be applicable or rendered\ndepending on the image type and the settings of the plotting widget.'))
     fa = font.addMenu(_('Font Attributes'))
     lines = self.menuParameters.addMenu(_('Lines'))
     lines.addAction(_('Set Line Type'), self.setLineType)
     lines.addAction(_('Set Line Width'), self.setLineWidth)
     points = self.menuParameters.addMenu(_('Points'))
     points.addAction(_('Set Point Characters'), self.setPointCharacters)
     
     self.imageParameters = QMenu(_('Image'), self)
     type = self.imageParameters.addMenu(_('Type'))
     type.addAction(_('Set Image Vector Graphics'), self.setImageSVG).setToolTip(_('Renders the image using vector graphics which are scaleable and zoomable,\nbut may not show all graphical options such as forground color changes.'))
     type.addAction(_('Set Image Bitmap Graphics'), self.setImagePNG).setToolTip(_('Redners the image using bitmap graphics which will become distorted on zooming,\nbut will show all graphical options.'))
     #type.addAction(_('Set Image JPEG'), self.setImageJPEG)
     type.setToolTip(_('Changes the plotting type of the rendered image.\nDifferent image types may enable or disable certain graphics parameters.'))
     
     self.fileParameters = QMenu(_('File'), self)
     save = self.fileParameters.addMenu(_('Save'))
     save.addAction(_('Bitmap'), self.saveAsBitmap)
     save.addAction(_('PDF'), self.saveAsPDF)
     save.addAction(_('Post Script'), self.saveAsPostScript)
     save.addAction(_('JPEG'), self.saveAsJPEG)
     
     printScene = self.fileParameters.addAction(_('Print'), self.printMe)
     
     self.menuBar.addMenu(self.fileParameters)
     self.menuBar.addMenu(self.menuParameters)
     #self.menuBar.addMenu(self.imageParameters)
     
     ### lower Line Edit
     self.extrasLineEdit = lineEdit(self.bottomArea, label = _('Advanced plotting parameters'), 
         toolTip = _('Add extra parameters to the main plot.\nPlease see documentation for more details about parameters.'), callback = self.replot)
     
     ### right click menu
     self.menu = QMenu(self)
     save = self.menu.addMenu(_('Save As'))
     save.addAction(_('Bitmap'))
     save.addAction(_('PDF'))
     save.addAction(_('Post Script'))
     save.addAction(_('JPEG'))
     self.menu.addAction(_('Copy'))
     self.menu.addAction(_('Fit In Window'))
     self.menu.addAction(_('Zoom Out'))
     self.menu.addAction(_('Zoom In'))
     self.menu.addAction(_('Undock'))
     self.menu.addAction(_('Redock'))
     self.dialog = QDialog()
     self.dialog.setWindowTitle(_('Red-R Graphics View') + name)
     self.dialog.setLayout(QHBoxLayout())
     
     self.standardImageType = 'svg'
     self.plotExactlySwitch = False ## a switch that can be activated to allow plotting exactly as the plot is sent, no function generation will be performed and all attribute alteration will be disabled
     QObject.connect(self.dialog, SIGNAL('finished(int)'), self.dialogClosed)
Example #56
0
 def __init__(self,widget,width=8, height=8):
     widgetState.__init__(self, widget, 'separator',includeInReports=False)
     QWidget.__init__(self,self.controlArea)
     self.controlArea.layout().addWidget(self)       
     self.setFixedSize(width, height)
Example #57
0
    def __init__(self,
                 widget,
                 parent,
                 graph,
                 autoSend=0,
                 buttons=(1, 4, 5, 0, 6, 7),
                 name="Zoom / Select",
                 exclusiveList="__toolbars"):
        widgetState.__init__(self,
                             widget,
                             'zoomSelectToolbar',
                             includeInReports=False)
        if not hasattr(zoomSelectToolbar, "builtinFunctions"):
            zoomSelectToolbar.builtinFunctions = \
                 (None,
                 (_("Zooming"), "buttonZoom", "activateZooming", QIcon(dlg_zoom), Qt.ArrowCursor, 1),
                 (_("Panning"), "buttonPan", "activatePanning", QIcon(dlg_pan), Qt.OpenHandCursor, 1),
                 (_("Selection"), "buttonSelect", "activateSelection", QIcon(dlg_select), Qt.CrossCursor, 1),
                 (_("Rectangle selection"), "buttonSelectRect", "activateRectangleSelection", QIcon(dlg_rect), Qt.CrossCursor, 1),
                 (_("Polygon selection"), "buttonSelectPoly", "activatePolygonSelection", QIcon(dlg_poly), Qt.CrossCursor, 1),
                 (_("Remove last selection"), "buttonRemoveLastSelection", "removeLastSelection", QIcon(dlg_undo), None, 0),
                 (_("Remove all selections"), "buttonRemoveAllSelections", "removeAllSelections", QIcon(dlg_clear), None, 0),
                 #("Send selections", "buttonSendSelections", "sendData", QIcon(dlg_send), None, 0),
                 (_("Zoom to extent"), "buttonZoomExtent", "zoomExtent", QIcon(dlg_zoom_extent), None, 0),
                 (_("Zoom selection"), "buttonZoomSelection", "zoomSelection", QIcon(dlg_zoom_selection), None, 0)
                )

        QGroupBox.__init__(self, name, parent)
        self.setLayout(QHBoxLayout())
        self.layout().setMargin(6)
        self.layout().setSpacing(4)
        if parent.layout():
            parent.layout().addWidget(self)

        self.graph = graph  # save graph. used to send signals
        self.exclusiveList = exclusiveList

        self.widget = None
        self.functions = [
            type(f) == int and zoomSelectToolbar.builtinFunctions[f] or f
            for f in buttons
        ]
        for b, f in enumerate(self.functions):
            if not f:
                self.layout().addSpacing(10)
            else:
                button = createButton(self,
                                      f[0],
                                      lambda x=b: self.action(x),
                                      f[3],
                                      toggle=f[5])
                setattr(self, f[1], button)
                if f[1] == "buttonSendSelections":
                    button.setEnabled(not autoSend)

        if not hasattr(widget, exclusiveList):
            setattr(widget, exclusiveList, [self])
        else:
            getattr(widget, exclusiveList).append(self)

        self.widget = widget  # we set widget here so that it doesn't affect the value of self.widget.toolbarSelection
        self.action(0)
Example #58
0
    def __init__(self,
                 widget,
                 label=None,
                 displayLabel=True,
                 includeInReports=True,
                 Rdata=None,
                 editable=False,
                 sortable=True,
                 filterable=False,
                 selectionBehavior=QAbstractItemView.SelectRows,
                 selectionMode=QAbstractItemView.ExtendedSelection,
                 showResizeButtons=True,
                 onFilterCallback=None,
                 callback=None,
                 selectionCallback=None):

        widgetState.__init__(self, widget, label, includeInReports)

        if displayLabel:
            mainBox = groupBox(self.controlArea,
                               label=label,
                               orientation='vertical')
        else:
            mainBox = widgetBox(self.controlArea, orientation='vertical')
        self.label = label

        QTableView.__init__(self, self.controlArea)
        mainBox.layout().addWidget(self)
        box = widgetBox(mainBox, orientation='horizontal')
        leftBox = widgetBox(box, orientation='horizontal')
        if filterable:
            self.clearButton = button(leftBox,
                                      label=_('Clear All Filtering'),
                                      callback=self.clearFiltering)
        self.dataInfo = widgetLabel(leftBox, label='', wordWrap=False)
        box.layout().setAlignment(leftBox, Qt.AlignLeft)

        if showResizeButtons:
            resizeColsBox = widgetBox(box, orientation="horizontal")
            resizeColsBox.layout().setAlignment(Qt.AlignRight)
            box.layout().setAlignment(resizeColsBox, Qt.AlignRight)
            widgetLabel(resizeColsBox, label=_("Resize columns: "))
            button(resizeColsBox,
                   label="+",
                   callback=self.increaseColWidth,
                   toolTip=_("Increase the width of the columns"),
                   width=30)
            button(resizeColsBox,
                   label="-",
                   callback=self.decreaseColWidth,
                   toolTip=_("Decrease the width of the columns"),
                   width=30)
            button(resizeColsBox,
                   label=_("Resize To Content"),
                   callback=self.resizeColumnsToContents,
                   toolTip=_("Set width based on content size"))

        self.R = Rcommand
        self.Rdata = None
        self.filteredData = None
        self.sortIndex = None
        self.criteriaList = {}
        self.parent = widget
        self.tm = None
        self.sortable = sortable
        self.editable = editable
        self.filterable = filterable
        self.onFilterCallback = onFilterCallback
        self.selectionCallback = selectionCallback
        self.selections = QItemSelection()
        self.working = False

        self.setHorizontalHeader(myHeaderView(self))
        self.setSelectionBehavior(selectionBehavior)
        self.setAlternatingRowColors(True)

        if selectionMode != -1:
            self.setSelectionMode(selectionMode)

        if Rdata:
            self.setRTable(Rdata)

        if editable:
            self.horizontalHeader().hide()
            self.verticalHeader().hide()

        # if sortable:
        # self.horizontalHeader().setSortIndicatorShown(True)
        # self.horizontalHeader().setSortIndicator(-1,0)
        if filterable or sortable:
            self.horizontalHeader().setClickable(True)
            # QObject.connect(self.horizontalHeader(), SIGNAL('sectionClicked (int)'), self.selectColumn)
            self.horizontalHeader().setContextMenuPolicy(Qt.CustomContextMenu)
            self.horizontalHeader().customContextMenuRequested.connect(
                self.headerClicked)

        if callback:
            QObject.connect(self, SIGNAL('clicked (QModelIndex)'), callback)