Exemple #1
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
    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
    def __init__(self, parent=None, signalManager=None):
        OWRpy.__init__(self)
        
        self.setRvariableNames(['heatsubset'])
        self.plotOnConnect = 0
        self.plotdata = ''
        self.rowvChoice = None
        
        self.inputs.addInput('id0', 'Expression Matrix', redRRMatrix, self.processMatrix)

        
        #GUI
        mainArea = widgetBox(self.controlArea,orientation='horizontal')
        #mainArea.setMaximumWidth(300)
        options = widgetBox(mainArea,orientation='vertical')
        options.setMaximumWidth(175)
        options.setMinimumWidth(175)
        dendrogramsBox = groupBox(options, label='Calculate dendrogram ', orientation='vertical')
        self.notice = widgetLabel(dendrogramsBox,label='The data set has > 1000 rows.\nClustering on rows will likely fail.')
        self.notice.setHidden(True)
        self.dendrogramOptions = checkBox(dendrogramsBox,
        buttons = ['Rows', 'Columns'], setChecked=['Rows', 'Columns'], orientation='horizontal',
        callback=self.dendrogramChanged)
        
        functions = widgetBox(dendrogramsBox,orientation='vertical')
        self.distOptions = lineEdit(functions,label='Distance Function:', text='dist', orientation='vertical')
        self.hclustOptions = lineEdit(functions,label='Clustering Function:',text='hclust', 
        orientation='vertical')
        #self.reorderOptions = lineEdit(functions,label='Reorder Function:', text='reorder.dendrogram')
        
        
        self.scaleOptions = radioButtons(options,label='Scale',  buttons=['row','column','none'],
        setChecked='row',orientation='horizontal')
        
        otherOptions = groupBox(options,label='Other Options')
        self.narmOptions = checkBox(otherOptions, buttons = ['Remove NAs'], setChecked=['Remove NAs'])
        # self.showDendroOptions = checkBox(otherOptions,buttons=['Show dendrogram '], setChecked=['Show dendrogram '])
        
        self.colorTypeCombo = comboBox(otherOptions, label = 'Color Type:', 
        items = ['rainbow', 'heat.colors', 'terrain.colors', 'topo.colors', 'cm.colors'],callback=self.colorTypeChange)
        self.startSaturation = spinBox(otherOptions, label = 'Starting Saturation', min = 0, max = 100)
        self.endSaturation = spinBox(otherOptions, label = 'Ending Saturation', min = 0, max = 100)
        self.endSaturation.setValue(30)
        separator(otherOptions,height=10)

        self.imageWidth = spinBox(otherOptions, label = 'Image Width', min = 1, max = 1000)
        self.imageWidth.setValue(4)
        self.imageHeight = spinBox(otherOptions, label = 'Image Height', min = 1, max = 1000)
        self.imageHeight.setValue(4)
        
        
        self.notice2 = widgetLabel(options,label='The input matrix is not numeric.')
        self.notice2.setHidden(True)
        self.buttonsBox = widgetBox(options,orientation='horizontal')
        self.buttonsBox.layout().setAlignment(Qt.AlignRight)
        self.plotOnConnect = checkBox(self.buttonsBox, buttons=['Plot on Connect'])
        button(self.buttonsBox, label = "Plot", callback=self.makePlot)
Exemple #4
0
    def __init__(self, parent=None, signalManager=None):
        OWRpy.__init__(self, wantGUIDialog = 1)

        self.rowCount = 1
        self.colCount = 1
        self.maxRow = 0 # sets the most extreme row and cols
        self.maxCol = 0
        self.classes = None
        self.savedData = None
        self.setRvariableNames(['table', 'table_cm'])
        
        self.inputs.addInput('Data Table', 'Data Table', redRRDataFrame, self.processDF)
        self.outputs.addOutput('Data Table', 'Data Table', redRRDataFrame) # trace problem with outputs
        #GUI.
        
        
        box = groupBox(self.GUIDialog, label = "Options")
        redRCommitButton(self.bottomAreaRight, 'Commit', self.commitTable)
        self.rowHeaders = checkBox(box, label= 'Table Annotations', buttons=['Use Row Headers', 'Use Column Headers'])
        #self.colHeaders = checkBox(box, label=None, buttons=['Use Column Headers'])
        self.rowHeaders.setChecked(['Use Row Headers', 'Use Column Headers'])
        #self.colHeaders.setChecked(['Use Column Headers'])
        self.customClasses = button(box, 'Use Custom Column Classes', callback = self.setCustomClasses)
        button(box, 'Clear Classes', callback = self.clearClasses)
        
        self.columnDialog = QDialog()
        self.columnDialog.setLayout(QVBoxLayout())
        self.columnDialog.hide()
        self.columnNameLineEdit = lineEdit(self.columnDialog, label = 'Column Name:')
        button(self.columnDialog, 'Commit', callback = self.commitNewColumn)
        button(self.bottomAreaRight, "Add Column", callback = self.addColumn)
        button(self.bottomAreaRight, "Add Row", callback = self.addRow)
        box = groupBox(self.controlArea, label = "Table", 
        sizePolicy = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred))
        #self.splitCanvas.addWidget(box)
        

        #self.R(self.Rvariables['table'] + '<- matrix("",nrow=10,ncol=10)', wantType = 'NoConversion')
        self.dataTable = table(box, label = 'Data Table', rows = 10, columns = 10)
        # if self.dataTable.columnCount() < 1:
            # self.dataTable.setColumnCount(1)
            # self.dataTable.setHorizontalHeaderLabels(['Rownames'])
        # if self.dataTable.rowCount() < 1:
            # self.dataTable.setRowCount(1)
        # self.dataTable.setHorizontalHeaderLabels(['Rownames'])
        
        self.connect(self.dataTable, SIGNAL("cellClicked(int, int)"), self.cellClicked) # works OK
        self.connect(self.dataTable, SIGNAL("cellChanged(int, int)"), self.itemChanged)
        self.window = QDialog(self)
        self.window.setLayout(QVBoxLayout())
        self.classTable = table(self.window, label = 'Data Table', rows = self.maxCol, columns = 2)
        self.resize(700,500)
        self.move(300, 25)
    def __init__(self, parent=None, signalManager=None):
        OWRpy.__init__(self, wantGUIDialog = 1)

        self.rowCount = 10
        self.colCount = 10
        self.maxRow = 0 # sets the most extreme row and cols
        self.maxCol = 0
        self.classes = None
        self.savedData = None
        self.setRvariableNames(['table', 'table_cm'])
        
        self.inputs.addInput('Data Table', 'Data Table', redRRDataFrame, self.processDF)
        self.outputs.addOutput('Data Table', 'Data Table', redRRDataFrame) # trace problem with outputs
        #GUI.
        
        
        box = groupBox(self.GUIDialog, label = "Options")
        redRCommitButton(self.bottomAreaRight, 'Commit', self.commitTable)
        self.rowHeaders = checkBox(box, label= 'Table Annotations', buttons=['Use Row Headers', 'Use Column Headers'])
        #self.colHeaders = checkBox(box, label=None, buttons=['Use Column Headers'])
        self.rowHeaders.setChecked(['Use Row Headers', 'Use Column Headers'])
        #self.colHeaders.setChecked(['Use Column Headers'])
        self.customClasses = button(box, 'Use Custom Column Classes', callback = self.setCustomClasses)
        button(box, 'Clear Classes', callback = self.clearClasses)
        
        self.columnDialog = QDialog()
        self.columnDialog.setLayout(QVBoxLayout())
        self.columnDialog.hide()
        self.columnNameLineEdit = lineEdit(self.columnDialog, label = 'Column Name:')
        button(self.columnDialog, 'Commit', callback = self.commitNewColumn)
        #button(self.bottomAreaRight, "Add Column", callback = self.addColumn)
        #button(self.bottomAreaRight, "Add Row", callback = self.addRow)
        box = groupBox(self.controlArea, label = "Table", 
        sizePolicy = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred))
        #self.splitCanvas.addWidget(box)
        

        #self.R(self.Rvariables['table'] + '<- matrix("",nrow=10,ncol=10)', wantType = 'NoConversion')
        self.dataTable = table(box, label = 'Data Table', rows = 10, columns = 10)
        # if self.dataTable.columnCount() < 1:
            # self.dataTable.setColumnCount(1)
            # self.dataTable.setHorizontalHeaderLabels(['Rownames'])
        # if self.dataTable.rowCount() < 1:
            # self.dataTable.setRowCount(1)
        # self.dataTable.setHorizontalHeaderLabels(['Rownames'])
        
        self.connect(self.dataTable, SIGNAL("cellClicked(int, int)"), self.cellClicked) # works OK
        self.connect(self.dataTable, SIGNAL("cellChanged(int, int)"), self.itemChanged)
        self.window = QDialog(self)
        self.window.setLayout(QVBoxLayout())
        self.classTable = table(self.window, label = 'Data Table', rows = self.maxCol, columns = 2)
        self.resize(700,500)
        self.move(300, 25)
Exemple #6
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)
Exemple #7
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)
Exemple #8
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)
Exemple #9
0
    def __init__(self, parent=None, signalManager=None):
        OWRpy.__init__(self)
        self.outputs.addOutput('id0', _('R Session'), redRREnvironment)

        # print os.path.abspath('/')
        self.path = os.path.abspath('/')
        self.setRvariableNames(['sessionEnviron'])

        gbox = groupBox(self.controlArea,
                        orientation='vertical',
                        label=_('Select R session'))

        box = widgetBox(gbox, orientation='horizontal')
        self.filecombo = fileNamesComboBox(box,
                                           label=_('Session File'),
                                           displayLabel=False,
                                           orientation='vertical')
        self.filecombo.setSizePolicy(QSizePolicy.MinimumExpanding,
                                     QSizePolicy.Maximum)

        button(box, label=_('Browse'), callback=self.browseFile)
        self.commit = commitButton(gbox,
                                   label=_('Load Session'),
                                   callback=self.loadSession,
                                   alignment=Qt.AlignRight)
        #gbox.layout().setAlignment(self.commit,Qt.AlignRight)

        self.infoa = widgetLabel(self.controlArea, '')
        self.varBox = listBox(self.controlArea, label=_('Variables'))
        self.varBox.hide()
        self.infob = widgetLabel(self.controlArea, '')
Exemple #10
0
    def __init__(self,
                 parent=None,
                 signalManager=None,
                 forceInSignals=None,
                 forceOutSignals=None):
        OWRpy.__init__(self)
        print unicode(forceInSignals) + ' and ' + unicode(
            forceOutSignals) + ' appending to dummy'
        if forceInSignals:
            import signals
            for (a, b) in [signal for signal in forceInSignals]:
                print 'Appending ' + unicode(
                    a) + ' in dummy to the ' + unicode(b) + ' signal'
                self.inputs.addInput((a, a, b, None))
        if forceOutSignals:
            import signals
            for (a, b) in [signal for signal in forceOutSignals]:
                print 'Appending ' + unicode(
                    a) + ' in dummy using the ' + unicode(b) + ' signal'
                self.outputs.addOutput((a, a, b))
        print self.inputs
        print self.outputs

        box = groupBox(self.controlArea, label=_("Info"))
        self.infoa = widgetLabel(
            box, _("A widget failed to load this was put in it's place."))
        self.infob = widgetLabel(
            box,
            _("The variables that were saved with this widget are %s .\n You can use R Executor to retrieve these variables and incorporate them into your schema."
              ) % str(self.linksOut))
Exemple #11
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)
Exemple #12
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)
Exemple #13
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)
Exemple #14
0
    def __init__(self, parent=None, signalManager=None):
        OWRpy.__init__(self)
        self.RFunctionParam_object = ''
        self.saveSettingsList.extend(['RFunctionParam_object'])
        self.inputs.addInput('id0', 'object', 'All', self.processobject)

        
        box = groupBox(self.controlArea, "Output")
        self.commit = redRCommitButton(self.bottomAreaRight, "Commit", callback = self.commitFunction,
        processOnInput=True)
        self.RoutputWindow = textEdit(box,label='R Output', displayLabel=False)
Exemple #15
0
    def __init__(self, parent=None, signalManager=None):
        OWRpy.__init__(self, wantGUIDialog=1)
        self.setRvariableNames(["lm"])
        self.RFunctionParam_formula = ""
        self.RFunctionParam_data = ''
        self.modelFormula = ''
        self.processingComplete = 0

        self.inputs.addInput('id0', 'data', redRRDataFrame, self.processdata)

        self.outputs.addOutput('id0', 'lm Output', redRRLMFit)
        self.outputs.addOutput('id1', 'lm plot attribute', redRRPlotAttribute)

        #GUI

        box = widgetBox(self.GUIDialog, orientation='horizontal')
        paramBox = groupBox(self.GUIDialog, 'Parameters')
        formulaBox = widgetBox(self.controlArea)
        self.RFunctionParam_subset = lineEdit(paramBox,
                                              'NULL',
                                              label="subset:")
        self.RFunctionParam_qr = lineEdit(paramBox, 'TRUE', label="qr:")

        self.RFunctionParam_singular_ok = lineEdit(paramBox,
                                                   'TRUE',
                                                   label="singular_ok:")
        self.RFunctionParam_y = lineEdit(paramBox, 'FALSE', label="y:")
        self.RFunctionParam_weights = lineEdit(paramBox, "", label="weights:")
        self.RFunctionParam_offset = lineEdit(paramBox, "", label="offset:")
        self.RFunctionParam_contrasts = lineEdit(paramBox,
                                                 "NULL",
                                                 label="contrasts:")
        self.RFunctionParam_x = lineEdit(paramBox, "FALSE", label="x:")
        self.RFunctionParam_model = lineEdit(paramBox, "TRUE", label="model:")
        self.RFunctionParam_method = lineEdit(paramBox, "qr", label="method:")

        #start formula entry section

        buttonsBox = widgetBox(formulaBox, "Commands")
        self.formulEntry = RFormulaEntry(buttonsBox,
                                         label='Formula',
                                         displayLabel=False)

        self.commit = redRCommitButton(self.bottomAreaRight,
                                       "Commit",
                                       callback=self.commitFunction,
                                       processOnInput=True)
        #self.processButton.setEnabled(False)
        self.status.setText('Data Not Connected Yet')
Exemple #16
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)
    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)
Exemple #18
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)
Exemple #19
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)
Exemple #20
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)
Exemple #21
0
    def __init__(self, parent=None, signalManager=None):
        OWRpy.__init__(self)
        self.setRvariableNames(['datasets', "data"])
        self.data = {}
        self.outputs.addOutput('id0', _('Example Data'), redRRDataFrame)

        self.R(
            '%s <- as.data.frame(data(package = .packages(all.available = TRUE))$results[,c(1,3:4)])'
            % self.Rvariables['datasets'],
            silent=True,
            wantType='NoConversion')
        self.R('%s$Title <- as.character(%s$Title)' %
               (self.Rvariables['datasets'], self.Rvariables['datasets']),
               silent=True,
               wantType='NoConversion')

        self.table = filterTable(
            self.controlArea,
            label='R Datasets',
            includeInReports=False,
            Rdata=self.Rvariables['datasets'],
            sortable=True,
            filterable=True,
            selectionMode=QAbstractItemView.SingleSelection,
            callback=self.selectDataSet)

        box = groupBox(self.controlArea, orientation='horizontal', margin=16)
        self.controlArea.layout().setAlignment(box, Qt.AlignHCenter)
        # the package does not need to be loaded to get its datasets
        self.package = lineEdit(box, label=_('Package:'),
                                text='')  #, callback = self.loadPackage)
        self.RFunctionParamdataName_lineEdit = lineEdit(
            box, label=_("Data Name:"), text='', callback=self.commitFunction)

        self.commit = redRCommitButton(box,
                                       _("Commit"),
                                       callback=self.commitFunction,
                                       processOnChange=True,
                                       orientation='vertical')
    def __init__(self, **kwargs):
        OWRpy.__init__(self, **kwargs)

        self.rowCount = 1
        self.colCount = 1
        self.maxRow = 0 # sets the most extreme row and cols
        self.maxCol = 0
        self.classes = None
        self.savedData = None
        self.setRvariableNames(['table', 'table_cm'])
        
        self.inputs.addInput('id0', _('Data Table'), UnstructuredDict, self.processDF)

        self.outputs.addOutput('id0', _('Data Table'), UnstructuredDict)
        #GUI.
        
        redRCommitButton(self.bottomAreaRight, _('Commit'), self.commitTable)

        self.columnDialog = QDialog(self)
        self.columnDialog.setLayout(QVBoxLayout())
        self.columnDialog.hide()
        self.columnNameLineEdit = lineEdit(self.columnDialog, label = _('Column Name:'))
        button(self.columnDialog, _('Commit'), callback = self.commitNewColumn)
        button(self.bottomAreaRight, _("Add Column"), callback = self.columnDialog.show)
        
        box = groupBox(self.controlArea, label = _("Table"), 
        sizePolicy = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred))
        #self.splitCanvas.addWidget(box)
        

        self.dataTable = pyDataTable(box,label=_('Data Entry'),displayLabel=False,
        data = None)
        
        self.connect(self.dataTable, SIGNAL("cellClicked(int, int)"), self.cellClicked) # works OK
        self.connect(self.dataTable, SIGNAL("cellChanged(int, int)"), self.itemChanged)
        self.connect(self.dataTable, SIGNAL('sectionClicked (int)'), self.headerClicked)
        self.resize(700,500)
        self.move(300, 25)
Exemple #23
0
    def __init__(self, parent=None, signalManager=None):
        OWRpy.__init__(self)

        self.rowCount = 1
        self.colCount = 1
        self.maxRow = 0 # sets the most extreme row and cols
        self.maxCol = 0
        self.classes = None
        self.savedData = None
        self.setRvariableNames(['table', 'table_cm'])
        
        self.inputs.addInput('id0', _('Data Table'), redRRDataFrame, self.processDF)

        self.outputs.addOutput('id0', _('Data Table'), redRRDataFrame)
        #GUI.
        
        redRCommitButton(self.bottomAreaRight, _('Commit'), self.commitTable)

        self.columnDialog = QDialog(self)
        self.columnDialog.setLayout(QVBoxLayout())
        self.columnDialog.hide()
        self.columnNameLineEdit = lineEdit(self.columnDialog, label = _('Column Name:'))
        button(self.columnDialog, _('Commit'), callback = self.commitNewColumn)
        button(self.bottomAreaRight, _("Add Column"), callback = self.columnDialog.show)
        
        box = groupBox(self.controlArea, label = _("Table"), 
        sizePolicy = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred))
        #self.splitCanvas.addWidget(box)
        

        self.dataTable = pyDataTable(box,label=_('Data Entry'),displayLabel=False,
        data = None)
        
        self.connect(self.dataTable, SIGNAL("cellClicked(int, int)"), self.cellClicked) # works OK
        self.connect(self.dataTable, SIGNAL("cellChanged(int, int)"), self.itemChanged)
        self.connect(self.dataTable, SIGNAL('sectionClicked (int)'), self.headerClicked)
        self.resize(700,500)
        self.move(300, 25)
Exemple #24
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)
Exemple #25
0
    def __init__(self, parent=None, signalManager=None):
        OWRpy.__init__(self)
        self.setRvariableNames(["spline"])
        self.data = {}
        self.RFunctionParam_y = ''
        self.RFunctionParam_x = ''
        self.inputs.addInput('id0', 'y', redRRVector, self.processy)
        self.inputs.addInput('id1', 'x', redRRVector, self.processx)

        self.outputs.addOutput('id0', 'spline Output', redRRModelFit)
        self.outputs.addOutput('id1', 'spline plot attribute', redRRPlotAttribute)

        
        self.standardTab = groupBox(self.controlArea, label = 'Parameters')
        self.RFunctionParamxmin_lineEdit =  lineEdit(self.standardTab,  label = "xmin:", text = 'min(x)')
        self.RFunctionParamties_lineEdit =  lineEdit(self.standardTab,  label = "ties:", text = 'mean')
        self.RFunctionParammethod_lineEdit =  lineEdit(self.standardTab,  label = "method:", text = '"fmm"')
        self.RFunctionParamxmax_lineEdit =  lineEdit(self.standardTab,  label = "xmax:", text = 'max(x)')
        self.RFunctionParamn_lineEdit =  lineEdit(self.standardTab,  label = "n:", text = '3*length(x)')
        
        self.xcolumnComboBox = comboBox(self.standardTab, label = 'X data')
        self.ycolumnComboBox = comboBox(self.standardTab, label = 'Y data')
        redRCommitButton(self.bottomAreaRight, "Commit", callback = self.commitFunction)
        self.RoutputWindow = textEdit(self.controlArea, label = "RoutputWindow")
Exemple #26
0
    def __init__(self, parent=None, signalManager=None):
        OWRpy.__init__(self)
        self.RFunctionParam_x = ''
        self.setRvariableNames(['newmat', 'compColumn'])
        self.inputs.addInput('id0', _('Data Table'), redRDataFrame,
                             self.processx)
        self.outputs.addOutput('data', _('Data Table'), redRDataFrame)

        box = groupBox(self.controlArea, _("Column Selector"))
        self.columnBox = redRListBox(
            box,
            label=_('Column Box'),
            toolTip=_(
                'Select the columns to find the largest or smallest value'))
        self.columnBox.setSelectionMode(QAbstractItemView.ExtendedSelection)
        self.glSelector = redRRadioButtons(
            box,
            label=_('Comarison Selection'),
            buttons=[_('Greater Than'), _('Less Than')],
            setChecked=_('Greater Than'))

        redRCommitButton(self.bottomAreaRight,
                         _("Commit"),
                         callback=self.commitFunction)
Exemple #27
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)
Exemple #28
0
    def __init__(self, parent=None, signalManager=None):
        OWRpy.__init__(self)

        self.setRvariableNames(['heatsubset'])
        self.plotOnConnect = 0
        self.plotdata = ''
        self.rowvChoice = None

        self.inputs.addInput('id0', 'Expression Matrix', redRRMatrix,
                             self.processMatrix)

        #GUI
        mainArea = widgetBox(self.controlArea, orientation='horizontal')
        #mainArea.setMaximumWidth(300)
        options = widgetBox(mainArea, orientation='vertical')
        options.setMaximumWidth(175)
        options.setMinimumWidth(175)
        dendrogramsBox = groupBox(options,
                                  label='Calculate dendrogram ',
                                  orientation='vertical')
        self.notice = widgetLabel(
            dendrogramsBox,
            label=
            'The data set has > 1000 rows.\nClustering on rows will likely fail.'
        )
        self.notice.setHidden(True)
        self.dendrogramOptions = checkBox(dendrogramsBox,
                                          buttons=['Rows', 'Columns'],
                                          setChecked=['Rows', 'Columns'],
                                          orientation='horizontal',
                                          callback=self.dendrogramChanged)

        functions = widgetBox(dendrogramsBox, orientation='vertical')
        self.distOptions = lineEdit(functions,
                                    label='Distance Function:',
                                    text='dist',
                                    orientation='vertical')
        self.hclustOptions = lineEdit(functions,
                                      label='Clustering Function:',
                                      text='hclust',
                                      orientation='vertical')
        #self.reorderOptions = lineEdit(functions,label='Reorder Function:', text='reorder.dendrogram')

        self.scaleOptions = radioButtons(options,
                                         label='Scale',
                                         buttons=['row', 'column', 'none'],
                                         setChecked='row',
                                         orientation='horizontal')

        otherOptions = groupBox(options, label='Other Options')
        self.narmOptions = checkBox(otherOptions,
                                    buttons=['Remove NAs'],
                                    setChecked=['Remove NAs'])
        # self.showDendroOptions = checkBox(otherOptions,buttons=['Show dendrogram '], setChecked=['Show dendrogram '])

        self.colorTypeCombo = comboBox(otherOptions,
                                       label='Color Type:',
                                       items=[
                                           'rainbow', 'heat.colors',
                                           'terrain.colors', 'topo.colors',
                                           'cm.colors'
                                       ],
                                       callback=self.colorTypeChange)
        self.startSaturation = spinBox(otherOptions,
                                       label='Starting Saturation',
                                       min=0,
                                       max=100)
        self.endSaturation = spinBox(otherOptions,
                                     label='Ending Saturation',
                                     min=0,
                                     max=100)
        self.endSaturation.setValue(30)
        separator(otherOptions, height=10)

        self.imageWidth = spinBox(otherOptions,
                                  label='Image Width',
                                  min=1,
                                  max=1000)
        self.imageWidth.setValue(4)
        self.imageHeight = spinBox(otherOptions,
                                   label='Image Height',
                                   min=1,
                                   max=1000)
        self.imageHeight.setValue(4)

        self.notice2 = widgetLabel(options,
                                   label='The input matrix is not numeric.')
        self.notice2.setHidden(True)
        self.buttonsBox = widgetBox(options, orientation='horizontal')
        self.buttonsBox.layout().setAlignment(Qt.AlignRight)
        self.plotOnConnect = checkBox(self.buttonsBox,
                                      buttons=['Plot on Connect'])
        button(self.buttonsBox, label="Plot", callback=self.makePlot)
Exemple #29
0
 def createControlGroup(self,tab,label):
     imageBox = groupBox(self.tabs[tab],label=label, orientation='vertical',
     sizePolicy = QSizePolicy(QSizePolicy.Maximum ,QSizePolicy.Minimum))
     self.controlGroups[label] = imageBox
     return imageBox
Exemple #30
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)
Exemple #31
0
    def __init__(self, parent=None, signalManager=None):
        #OWWidget.__init__(self, parent, signalManager, "Sample Data")
        OWRpy.__init__(self, wantGUIDialog=1)

        self.command = ''
        self.sendthis = ''
        self.sendt = {}
        self.dfselected = None
        self.setRvariableNames(['rExecutor', 'rExecutor_cm'])

        self.inputs.addInput('id0', _('R.object'), redRRVariable, self.process)

        self.outputs.addOutput('id0', _('R Data Frame'), redRRDataFrame)
        self.outputs.addOutput('id1', _('R List'), redRRList)
        self.outputs.addOutput('id2', _('R Vector'), redRRVector)
        self.outputs.addOutput('id3', _('R.object'), 'All')
        self.outputs.addOutput('id4', _('R Matrix'), redRRMatrix)

        #self.breakme()

        #self.help.setHtml('The R Executor widget provides direct access to the R session that runs under RedR.  R Executor can recieve any output from an R compatible widget.  The recieved data can be shown using the Recieved button.  The R history can be shown by pressing the RHistory button and the complete parsing of any recieved data is shown in the Metadata section.  More infromation is available on the <a href="http://www.red-r.org/?cat=10">RedR website</a>.')

        #GUI

        #GUIDialog
        self.box = groupBox(self.GUIDialog, _("R Executor Advanced"))
        self.infob = widgetLabel(self.box, "")

        self.infoa = widgetLabel(self.box, "")
        # grid
        area = widgetBox(self.controlArea, orientation='horizontal')
        area.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)

        leftArea = widgetBox(self.box)
        leftArea.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Expanding)
        rightArea = widgetBox(area)

        runbox = groupBox(rightArea,
                          label=_("Command Edit:"),
                          orientation='horizontal')
        runbox.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Maximum)
        #self.command = lineEdit(runbox, "", orientation=QHBoxLayout(), callback = self.runR, width = -1)
        self.command = textEdit(runbox, label=_('Command Edit:'))
        #self.command.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
        processbutton = button(runbox,
                               label=_("&Run"),
                               callback=self.runR,
                               width=100)
        statusBox = groupBox(rightArea, label=_("Status"))
        self.sendStatus = widgetLabel(statusBox, _('Nothing Sent'))
        self.dataBox = groupBox(leftArea, label=_("Input Infromation"))
        self.mystatus = widgetLabel(self.dataBox, _("No Input"))

        # self.metadataBox = widgetBox(leftArea, _("Metadata"))
        # self.infoM = widgetLabel(self.metadataBox, _("No Meta Data"))
        # self.metadataLB = listBox(self.metadataBox, callback = self.insertMetaDataVar)
        varbutton = button(leftArea,
                           _("Recieved"),
                           callback=self.putrecieved,
                           width=150)
        history = button(leftArea,
                         _("RHistory"),
                         callback=self.putRHistory,
                         width=150)
        button(leftArea, _("Clear Output"), callback=self.clearOutput)

        self.lsList = listBox(self.box,
                              label=_('Available R Items'),
                              items=self.R('ls()', wantType='list'),
                              callback=self.addlsList)
        button(self.box, 'Refresh List', callback=self.refreshLsList)

        self.thistext = textEdit(rightArea,
                                 label=_('Output'),
                                 displayLabel=False)

        sendbutton = button(
            runbox,
            label=_("&Send"),
            toolTip=_(
                'Send the data in the command line into the Red-R schema.'),
            callback=self.sendThis,
            width=100)
Exemple #32
0
    def __init__(self, parent=None, signalManager=None):
        OWRpy.__init__(self)

        self.setRvariableNames(['heatsubset', 'hclust', 'heatvect'])
        self.plotOnConnect = 0
        self.plotdata = ''
        self.rowvChoice = None
        self.colvChoice = None
        self.listOfColors = ['"red"', '"white"', '"blue"']

        self.inputs.addInput('id0', 'Expression Matrix', redRRDataFrame,
                             self.processMatrix)
        self.inputs.addInput('id1', 'Classes Data', redRRVector,
                             self.processClasses)

        #self.outputs.addOutput('id0', 'Cluster Subset List', redRRVector)
        self.outputs.addOutput('id1', 'Cluster Classes', redRRVector)

        #GUI
        infobox = groupBox(self.controlArea, label="Options")

        self.commit = redRCommitButton(self.bottomAreaRight,
                                       label="Replot",
                                       callback=self.makePlot,
                                       width=200,
                                       processOnInput=True)

        button(infobox, label='Identify', callback=self.identify, width=200)
        self.groupOrHeight = radioButtons(infobox,
                                          label='Identify by:',
                                          buttons=['Groups', 'Height'],
                                          setChecked='Groups',
                                          orientation='horizontal')
        self.groupOrHeightSpin = spinBox(infobox,
                                         label='Identify Value:',
                                         min=1,
                                         value=5)
        self.startSaturation = spinBox(infobox,
                                       label='Starting Saturation:',
                                       min=0,
                                       max=100)
        self.endSaturation = spinBox(infobox,
                                     label='Ending Saturation:',
                                     min=0,
                                     max=100)
        self.endSaturation.setValue(30)
        redRButton(self.controlArea,
                   label='Reset Colors',
                   callback=self.resetColors)
        #self.classesDropdown = comboBox(infobox, label = 'Classes:', toolTip = 'If classes data is connected you may select columns in the data to represent classes of your columns in the plotted data')

        self.rowDendrogram = checkBox(
            infobox,
            label='Dendrogram Options',
            displayLabel=False,
            buttons=['Plot Row Dendrogram', 'Plot Column Dendrogram'],
            setChecked=['Plot Row Dendrogram', 'Plot Column Dendrogram'])

        self.showClasses = checkBox(infobox,
                                    label='Show Classes',
                                    displayLabel=False,
                                    buttons=['Show Classes'])
        self.showClasses.setEnabled(False)
        #OWGUI.checkBox(infobox, self, )
        self.infoa = widgetLabel(infobox, label="Nothing to report")
        self.gview1 = graphicsView(self.controlArea,
                                   label='Heatmap',
                                   displayLabel=False)
        self.gview1.image = 'heatmap1_' + self.widgetID
Exemple #33
0
    def __init__(self, parent=None, signalManager=None):
        #Here we init the parent class of our widget OWRpy.
        OWRpy.__init__(self)
        
        #create a R variable cor in the R session.
        #the output variable will not conflict with some other widgets variables
        self.setRvariableNames(["distri"])

        # Define the outputs of this widget
        self.outputs.addOutput('id0', 'Results', redRRVector)

        
        #START THE GUI LAYOUT
        area = widgetBox(self.controlArea,orientation='horizontal')       
        options = widgetBox(area,orientation='vertical')
        area.layout().setAlignment(options,Qt.AlignTop)
        self.count = RedRSpinBox(options, label='# Observations to Generate', min = 0,max=60000000, value = 10)
        
        self.methodButtons = redRcomboBox(options,  label = "Distributions", 
        items = [("rnorm", "Normal"),
        ('rbeta','Beta'),
        ('rbinom','Binomial'),
        ('rcauchy','Cauchy'),
        ('rchisq','Chi Square'),
        ('rexp','Exponential'),
        ('rf','F'),
        ('rgamma','Gamma') ],
        editable=True, callback = self.onDistChange)
        
        textBoxWidth = 70
        self.distOptions = widgetBox(options)
        self.normalDist = groupBox(self.distOptions,label='Normal Distribution')
        self.normMean = redRlineEdit(self.normalDist, label='Mean',id='mean', text='0', width=textBoxWidth)
        self.normSD = redRlineEdit(self.normalDist, label='Standard Deviations',id='sd', text='1',width=textBoxWidth)
        
        self.betaDist = groupBox(self.distOptions,label='Beta Distribution')
        self.betaShape1 = redRlineEdit(self.betaDist, label='Shape 1', id='shape1', width=textBoxWidth,text='1')
        self.betaShape2 = redRlineEdit(self.betaDist, label='Shape 2', id='shape2', width=textBoxWidth,text='1')
        self.betaNCP = redRlineEdit(self.betaDist, label='Non-centrality', id='ncp', width=textBoxWidth,text='0')
        self.betaDist.hide()

        
        self.binomDist = groupBox(self.distOptions,label='Binomial Distribution')
        self.binomSize = redRlineEdit(self.binomDist, label='Size', id='size', width=textBoxWidth,text='1')
        self.binomProb = redRlineEdit(self.binomDist, label='Probability', id='prob', width=textBoxWidth,text='.5')
        self.binomDist.hide()
        
        
        self.cauchyDist = groupBox(self.distOptions,label='Cauchy Distribution')
        self.cauchyLocation = redRlineEdit(self.cauchyDist, label='Location', id='location', width=textBoxWidth,text='0')
        self.cauchyScale = redRlineEdit(self.cauchyDist, label='Scale', id='scale', width=textBoxWidth,text='1')
        self.cauchyDist.hide()
        
        self.gammaDist = groupBox(self.distOptions,label='Gamma Distribution')
        self.gammaShape = redRlineEdit(self.gammaDist, label='Shape', id='location', width=textBoxWidth,text='1')
        self.gammaRate = redRlineEdit(self.gammaDist, label='Rate', id='scale', width=textBoxWidth,text='1')
        self.gammaScale = redRlineEdit(self.gammaDist, label='Scale', id='scale', width=textBoxWidth,text='.5')
        self.gammaDist.hide()
        
        self.chiDist = groupBox(self.distOptions,label='Chi Square Distribution')
        self.chiDF = redRlineEdit(self.chiDist, label='Degrees of Freedom', id='df', width=textBoxWidth,text='1')
        self.chiNCP = redRlineEdit(self.chiDist, label='Non-centrality', id='ncp', width=textBoxWidth,text='0')
        self.chiDist.hide()
        
        self.fDist = groupBox(self.distOptions,label='F Distribution')
        self.fDF1 = redRlineEdit(self.fDist, label='Degrees of Freedom 1', id='df1', width=textBoxWidth,text='1')
        self.fDF2 = redRlineEdit(self.fDist, label='Degrees of Freedom 2', id='df2', width=textBoxWidth,text='1')
        self.fNCP = redRlineEdit(self.fDist, label='Non-centrality', id='ncp', width=textBoxWidth,text='0')
        self.fDist.hide()
        
        self.expDist = groupBox(self.distOptions,label='Exponential Distribution')
        self.expRate = redRlineEdit(self.expDist, label='Rate ', id='rate', width=textBoxWidth,text='1')
        self.expDist.hide()
        
        commit = redRCommitButton(options, "Commit", toolTip='Calculate values', callback = self.commitFunction)
        options.layout().setAlignment(commit, Qt.AlignRight)
 def __init__(self, parent,label=_('Graph'), displayLabel=True,name = '', data = None,**kwargs):
     ## want to init a graphics view with a new graphics scene, the scene will be accessable through the widget.
     
     kwargs.setdefault('includeInReports', True)
     kwargs.setdefault('sizePolicy', QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred))
     widgetState.__init__(self,parent,label,**kwargs)
     
     QGraphicsView.__init__(self, self.controlArea)
     self.R = RSession.Rcommand
     self.require_librarys = RSession.require_librarys
     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,
     sizePolicy = QSizePolicy(QSizePolicy.Minimum,QSizePolicy.Maximum),includeInReports=False)
     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)
     if sys.platform == 'win32':
         save.addAction('WMF', self.saveAsWMF)
     
     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)
Exemple #35
0
    def __init__(self, parent=None, signalManager=None):
        OWRpy.__init__(self)
        self.path = os.path.abspath('/')

        self.data = None
        self.inputs.addInput("list", _("R Data"), signals.RVariable.RVariable,
                             self.processlist)

        self.fileType = radioButtons(self.controlArea,
                                     label=_('Save File Type'),
                                     buttons=[_('Text'),
                                              _('R Data File')],
                                     setChecked=_('Text'),
                                     orientation='horizontal',
                                     callback=self.selectFileType)

        self.rDataFileOptions = widgetBox(self.controlArea,
                                          orientation='vertical')
        self.varName = redRlineEdit(self.rDataFileOptions,
                                    label=_("Variable Name"))
        self.textFileOptions = widgetBox(self.controlArea,
                                         orientation='vertical')
        self.rDataFileOptions.setDisabled(True)
        self.delimiter = radioButtons(self.textFileOptions,
                                      label=_('Column Seperator'),
                                      buttons={
                                          '\t': _('Tab'),
                                          ' ': _('Space'),
                                          ',': _('Comma'),
                                          '?': _('Other')
                                      },
                                      setChecked='\t',
                                      orientation='horizontal')
        self.otherSepText = redRlineEdit(self.delimiter.box,
                                         label=_('Seperator'),
                                         displayLabel=False,
                                         text=';',
                                         width=20,
                                         orientation='horizontal')
        QObject.connect(self.otherSepText,
                        SIGNAL('textChanged(const QString &)'),
                        lambda: self.delimiter.setChecked('Other'))

        twoColHolder = groupBox(self.textFileOptions,
                                label=_('File Options'),
                                orientation='horizontal')
        colOne = widgetBox(twoColHolder)
        colTwo = widgetBox(twoColHolder)

        self.fileOptions = redRcheckBox(
            colOne,
            label=_('Options'),
            displayLabel=False,
            buttons=[_('append'),
                     _('quote'),
                     _('row.names'),
                     _('col.names')],
            setChecked=[_('quote'), _('col.names')],
            toolTips=[
                _('If TRUE, the output is appended to the file.'),
                _(' If TRUE, any character or factor columns will be surrounded by double quotes.'
                  ),
                _('a logical value indicating whether the row names of data are to be written.'
                  ),
                _('a logical value indicating whether the column names of data are to be written.'
                  )
            ],
            orientation='vertical')

        self.eolChr = redRlineEdit(colTwo,
                                   label=_('End of line Chr:'),
                                   text='\\n',
                                   width=50)
        self.naStr = redRlineEdit(colTwo,
                                  label=_('Missing Value String:'),
                                  text='NA',
                                  width=50)
        self.decStr = redRlineEdit(colTwo,
                                   label=_('Decimel point Chr:'),
                                   text='.',
                                   width=50)

        self.qmethod = radioButtons(
            self.textFileOptions,
            label=_('Deal with embedded double quote characters '),
            buttons=[_('escape'), _('double')],
            setChecked=_('escape'),
            orientation='horizontal')

        self.browseBox = groupBox(self.controlArea,
                                  label=_("Save File"),
                                  addSpace=True,
                                  orientation='vertical')

        box = widgetBox(self.browseBox, orientation='horizontal')
        self.fileLocation = redRlineEdit(box,
                                         label=_('File Location'),
                                         displayLabel=False,
                                         orientation='horizontal')

        redRbutton(box, label=_('Browse'), callback=self.browseFile)

        self.commit = commitButton(self.bottomAreaRight,
                                   _("Save"),
                                   callback=self.commitFunction,
                                   processOnInput=True)
Exemple #36
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)
Exemple #37
0
    def __init__(self, parent=None, signalManager=None):

        OWRpy.__init__(self)
        self.setRvariableNames(['Plot', 'paint', 'selected'])
        self.inputs.addInput('id0', 'x', redRRDataFrame, self.gotX)

        self.outputs.addOutput('id0', 'Scatterplot Output', redRRDataFrame)

        self.data = None
        self.parent = None
        self.dataParent = None

        # GUI
        area = widgetBox(self.controlArea, orientation='horizontal')

        options = widgetBox(area, orientation='vertical')
        options.setMaximumWidth(250)
        # options.setMinimumWidth(250)
        options.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
        dataSelection = groupBox(options, orientation='vertical')
        self.xColumnSelector = comboBox(dataSelection,
                                        label='X data',
                                        items=[],
                                        callback=self.onSourceChange)
        self.yColumnSelector = comboBox(dataSelection,
                                        label='Y data',
                                        items=[],
                                        callback=self.onSourceChange)
        self.paintCMSelector = comboBox(dataSelection,
                                        label='Color Points By:',
                                        items=[''],
                                        callback=self.onSourceChange)

        # plot area
        plotarea = groupBox(area, label="Graph")
        plotarea.setSizePolicy(QSizePolicy.MinimumExpanding,
                               QSizePolicy.MinimumExpanding)
        #plotarea.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)

        self.graph = redRGraph(plotarea,
                               label='Scatter Plot',
                               displayLabel=False,
                               onSelectionCallback=self.onSelectionCallback)

        #plotarea.layout().addWidget(self.graph)
        #self.zoomSelectToolbarBox = groupBox(self.GUIDialog, label = "Plot Tool Bar")

        separator(options, height=8)
        buttonBox = groupBox(options, orientation='vertical')

        box1 = widgetBox(buttonBox, orientation='horizontal')
        box1.layout().setAlignment(Qt.AlignRight)
        self.plotOnInput = checkBox(
            box1,
            label='commit',
            displayLabel=False,
            buttons=['Plot on Change'],
            toolTips=[
                'Whenever X, Y or color data source changes plot the results.'
            ])
        button(box1,
               label="Plot",
               callback=self.plot,
               toolTip='Plot the data.')

        box2 = widgetBox(buttonBox, orientation='horizontal')
        box2.layout().setAlignment(Qt.AlignRight)

        self.commitOnInput = checkBox(
            box2,
            label='commit',
            displayLabel=False,
            buttons=['Commit on Selection'],
            toolTips=['Whenever this selection changes, send data forward.'])
        button(box2,
               label="Select",
               callback=self.sendMe,
               toolTip='Subset the data according to your selection.')

        separator(options, height=8)
        self.zoomSelectToolbar = zoomSelectToolbar(self, options, self.graph)
        self.paintLegend = textEdit(options, label='Legend')
Exemple #38
0
    def __init__(self, parent=None, signalManager=None):
        OWRpy.__init__(self)  #initialize the widget
        self.dataClass = None
        self.dataParent = None
        self.setRvariableNames(['rowcolSelector', 'rowcolSelectorNot'])
        self.SubsetByAttached = 0

        self.inputs.addInput('id0', _('Data Table'), redRRDataFrame,
                             self.setWidget)
        self.inputs.addInput('id1', _('Subsetting Vector'), redRRList,
                             self.setSubsettingVector)

        self.outputs.addOutput('id0', _('Selected Items'), redRRDataFrame)
        self.outputs.addOutput('id1', _('Non-selected Items'), redRRDataFrame)

        #set the gui

        area = widgetBox(self.controlArea, orientation='horizontal')
        options = widgetBox(area, orientation='vertical')

        self.rowcolBox = radioButtons(options,
                                      label=_('Select On'),
                                      buttons=[_('Column'),
                                               _('Row')],
                                      setChecked=_('Column'),
                                      callback=self.rowcolButtonSelected,
                                      orientation='horizontal')

        self.sendSection = checkBox(options,
                                    label=_('Create subset from:'),
                                    displayLabel=True,
                                    buttons=[_('Selected'),
                                             _('Not Selected')],
                                    setChecked=[_('Selected')],
                                    orientation='horizontal')

        # toolTips = [_("Select True to send data from the Data slot where the selections that you made are True."),
        # _("Select False to send data from the Not Data slot that are not the selections you made.")])

        self.invertButton = button(options,
                                   _("Invert Selection"),
                                   callback=self.invertSelection)

        separator(options, height=15)

        self.subsetBox = groupBox(options, label=_('Subset by'))
        self.subsetColumn = comboBox(self.subsetBox,
                                     label=_("Column:"),
                                     orientation='vertical',
                                     items=[_('Select')])
        self.subOnAttachedButton = button(self.subsetBox,
                                          _("Subset by column"),
                                          callback=self.subOnAttached)
        self.subsetBox.setDisabled(True)

        separator(options, height=20)

        info = widgetBox(options)
        options.layout().setAlignment(info, Qt.AlignBottom)
        self.infoBox = widgetLabel(info)
        separator(info, height=15)
        self.selectionInfoBox = widgetLabel(info)
        mainArea = widgetBox(area, orientation='vertical')
        self.attributes = listBox(mainArea,
                                  label=_('Select'),
                                  callback=self.onSelect)
        self.attributes.setSelectionMode(QAbstractItemView.ExtendedSelection)

        self.subsetButton = commitButton(mainArea,
                                         _("Subset on Selection"),
                                         callback=self.subset,
                                         processOnChange=True,
                                         processOnInput=True,
                                         alignment=Qt.AlignRight)
    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)
Exemple #40
0
    def __init__(self, parent=None, signalManager=None):

        OWRpy.__init__(self)
        self.path = os.path.abspath('/')
        self.colClasses = []
        self.myColClasses = []
        self.colNames = []
        self.dataTypes = []
        self.useheader = 1

        #set R variable names
        self.setRvariableNames(
            ['dataframe_org', 'dataframe_final', 'filename', 'parent'])

        #signals
        self.outputs.addOutput(
            'od1', _('Output Data'),
            rdf.RDataFrame)  #[("data.frame", rdf.RDataFrame)]
        #GUI
        area = widgetBox(self.controlArea,
                         orientation='horizontal',
                         alignment=Qt.AlignTop)
        #area.setSizePolicy(QSizePolicy(QSizePolicy.MinimumExpanding ,QSizePolicy.MinimumExpanding))
        #area.layout().setAlignment(Qt.AlignTop)
        options = widgetBox(area, orientation='vertical')
        options.setMaximumWidth(300)
        # options.setMinimumWidth(300)
        options.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
        #area.layout().setAlignment(options,Qt.AlignTop)

        self.browseBox = groupBox(options,
                                  label=_("Load File"),
                                  addSpace=True,
                                  orientation='vertical')
        box = widgetBox(self.browseBox, orientation='horizontal')
        self.filecombo = fileNamesComboBox(box,
                                           label=_('Files'),
                                           displayLabel=False,
                                           orientation='horizontal',
                                           callback=self.scanNewFile)
        self.filecombo.setSizePolicy(QSizePolicy.MinimumExpanding,
                                     QSizePolicy.Minimum)
        button(box, label=_('Browse'), callback=self.browseFile)

        self.fileType = radioButtons(options,
                                     label=_('File Type'),
                                     buttons=[_('Text'), _('Excel')],
                                     setChecked=_('Text'),
                                     callback=self.scanNewFile,
                                     orientation='horizontal')
        self.fileType.setSizePolicy(QSizePolicy.MinimumExpanding,
                                    QSizePolicy.Minimum)
        self.fileType.hide()

        self.delimiter = radioButtons(
            options,
            label=_('Column Seperator'),
            buttons=[_('Tab'), _('Comma'),
                     _('Space'), _('Other')],
            setChecked=_('Tab'),
            callback=self.scanNewFile,
            orientation='horizontal')

        self.otherSepText = lineEdit(self.delimiter.box,
                                     label=_('Seperator'),
                                     displayLabel=False,
                                     text=';',
                                     width=20,
                                     orientation='horizontal')
        QObject.connect(self.otherSepText,
                        SIGNAL('textChanged(const QString &)'), self.otherSep)

        self.headersBox = groupBox(options,
                                   label=_("Row and Column Names"),
                                   addSpace=True,
                                   orientation='horizontal')

        self.hasHeader = checkBox(
            self.headersBox,
            label=_('Column Header'),
            displayLabel=False,
            buttons=[_('Column Headers')],
            setChecked=[_('Column Headers')],
            toolTips=[
                _('a logical value indicating whether the file contains the names of the variables as its first line. If missing, the value is determined from the file format: header is set to TRUE if and only if the first row contains one fewer field than the number of columns.'
                  )
            ],
            orientation='vertical',
            callback=self.scanNewFile)

        self.rowNamesCombo = comboBox(self.headersBox,
                                      label=_('Select Row Names'),
                                      orientation='vertical',
                                      callback=self.scanFile)
        #self.rowNamesCombo.setMaximumWidth(250)

        self.otherOptionsBox = groupBox(options,
                                        label=_("Other Options"),
                                        addSpace=True,
                                        orientation='vertical')
        # box.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Minimum)
        split = widgetBox(self.otherOptionsBox, orientation='horizontal')
        # split.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Minimum)

        self.otherOptions = checkBox(
            split,
            label=_('Options'),
            displayLabel=False,
            buttons=[
                'fill', 'strip.white', 'blank.lines.skip', 'allowEscapes',
                'StringsAsFactors'
            ],
            setChecked=['blank.lines.skip'],
            toolTips=[
                _('logical. If TRUE then in case the rows have unequal length, blank fields are implicitly added.'
                  ),
                _('logical. Used only when sep has been specified, and allows the unicodeipping of leading and trailing white space from character fields (numeric fields are always unicodeipped). '
                  ),
                _('logical: if TRUE blank lines in the input are ignored.'),
                _('logical. Should C-style escapes such as \n be processed or read verbatim (the default)? '
                  ),
                _('logical: should character vectors be converted to factors?')
            ],
            orientation='vertical',
            callback=self.scanFile)
        # box.layout().addWidget(self.otherOptions,1,1)
        box2 = widgetBox(split, orientation='vertical')
        #box2.setSizePolicy(QSizePolicy.Fixed,QSizePolicy.Fixed)
        split.layout().setAlignment(box2, Qt.AlignTop)
        self.quote = lineEdit(box2,
                              text='"',
                              label=_('Quote:'),
                              width=50,
                              orientation='horizontal')
        self.decimal = lineEdit(
            box2,
            text='.',
            label=_('Decimal:'),
            width=50,
            orientation='horizontal',
            toolTip=_(
                'Decimal sign, some countries may want to use the \'.\''))

        self.numLinesScan = lineEdit(
            box2,
            text='10',
            label=_('# Lines to Preview:'),
            toolTip=
            _('The maximum number of rows to read in while previewing the file. Negative values are ignored.'
              ),
            width=50,
            orientation='horizontal')
        self.numLinesReads = lineEdit(
            box2,
            text='-1',
            label=_('# Lines to Read:'),
            toolTip=
            _('Number of lines to read from file. Read whole file if 0 or negative values.'
              ),
            width=50,
            orientation='horizontal')

        self.numLinesSkip = lineEdit(
            box2,
            text='0',
            label=_('# Lines to Skip:'),
            toolTip=
            _("The number of lines of the data file to skip before beginning to read data."
              ),
            width=50,
            orientation='horizontal')

        holder = widgetBox(options, orientation='horizontal')
        clipboard = button(
            holder,
            label=_('Load Clipboard'),
            toolTip=
            _('Load the file from the clipboard, you can do this if\ndata has been put in the clipboard using the copy command.'
              ),
            callback=self.loadClipboard)
        rescan = button(holder,
                        label=_('Rescan File'),
                        toolTip=_("Preview a small portion of the file"),
                        callback=self.scanNewFile)
        load = button(holder,
                      label=_('Load File'),
                      toolTip=_("Load the file into Red-R"),
                      callback=self.loadFile)
        holder.layout().setAlignment(Qt.AlignRight)

        self.FileInfoBox = groupBox(options,
                                    label=_("File Info"),
                                    addSpace=True)
        self.infob = widgetLabel(self.FileInfoBox, label='')
        self.infob.setWordWrap(True)
        self.infoc = widgetLabel(self.FileInfoBox, label='')
        self.FileInfoBox.setHidden(True)

        self.tableArea = widgetBox(area)
        self.tableArea.setMinimumWidth(500)
        #self.tableArea.setHidden(True)
        self.tableArea.setSizePolicy(QSizePolicy.MinimumExpanding,
                                     QSizePolicy.MinimumExpanding)

        self.scanarea = textEdit(self.tableArea,
                                 label=_('File Preview'),
                                 includeInReports=False)
        self.scanarea.setLineWrapMode(QTextEdit.NoWrap)
        self.scanarea.setReadOnly(True)
        self.scroll = scrollArea(self.tableArea)

        self.columnTypes = widgetBox(self,
                                     orientation=QGridLayout(),
                                     margin=10)
        self.scroll.setWidget(self.columnTypes)
        #self.columnTypes.layout().setSizeConstraint(QLayout.SetMinAndMaxSize)
        self.columnTypes.setMinimumWidth(460)
        self.columnTypes.layout().setSizeConstraint(QLayout.SetMinimumSize)
        self.columnTypes.setSizePolicy(
            QSizePolicy(QSizePolicy.MinimumExpanding,
                        QSizePolicy.MinimumExpanding))
        self.columnTypes.layout().setAlignment(Qt.AlignTop | Qt.AlignLeft)
        #self.setFileList()
        import sys
        if sys.platform == "win32":
            self.require_librarys(['RODBC'])
            self.setForExcel()
Exemple #41
0
    def __init__(self, parent=None, signalManager=None):
        OWRpy.__init__(self)

        self.setRvariableNames(['math'])

        self.counter = 1
        self.functionsList = [
            'log2', 'log10', 'add', 'subtract', 'multiply', 'divide', 'match',
            'as.numeric', 'as.character', 'exp', 'logicAND', 'logicOR',
            'toDateTime (MDY)', 'toDateTime (DMY)', 'toDateTime (YMD)'
        ]

        self.inputs.addInput('id0', _('Data Frame'), redRRDataFrame,
                             self.gotData)

        self.outputs.addOutput('id0', _('Data Frame'), redRRDataFrame)

        #GUI#

        mainArea = widgetBox(self.controlArea, orientation='horizontal')
        leftArea = groupBox(mainArea, label=_('Table View'))
        rightArea = groupBox(mainArea, label=_('Math Box'))

        self.table = redRfilterTable(leftArea,
                                     label=_('Data Table'),
                                     displayLabel=False,
                                     filterable=False,
                                     sortable=False)

        self.functionLineEdit = lineEdit(rightArea,
                                         label=_('Function Search or Run'),
                                         callback=self.functionDone)
        QObject.connect(self.functionLineEdit,
                        SIGNAL('textChanged(const QString&)'),
                        lambda s: self.textChanged(s))

        self.functionListBox = listBox(rightArea,
                                       label=_('List of Functions'),
                                       displayLabel=False,
                                       includeInReports=False,
                                       items=self.functionsList,
                                       callback=self.funcionPressed)

        #self.helpButton = button(rightArea, label = 'Help') #, toolTip = 'Press this then select a function from the list for help.')
        self.dialog = dialog(self)
        self.dialogTopArea = groupBox(self.dialog, label=_('Left Side'))
        self.dialogTopLineEdit = lineEdit(self.dialogTopArea,
                                          label=_('Constant'),
                                          toolTip=_('Must be a number'))
        self.dialogTopListBox = listBox(self.dialogTopArea,
                                        label=_('Columns'),
                                        toolTip=_('Select one of the columns'),
                                        callback=self.dialogTopLineEdit.clear)

        self.dialogLabel = widgetLabel(self.dialog)

        self.dialogBottomArea = groupBox(self.dialog, label=_('Right Side'))
        self.dialogBottomLineEdit = lineEdit(self.dialogBottomArea,
                                             label=_('Constant'),
                                             toolTip=_('Must be a number'))
        self.dialogBottomListBox = listBox(
            self.dialogBottomArea,
            label=_('Columns'),
            toolTip=_('Select one of the columns'),
            callback=self.dialogBottomLineEdit.clear)
        redRCommitButton(self.dialog,
                         label=_('Done'),
                         callback=self.functionCommit)
        self.dialog.hide()
Exemple #42
0
    def __init__(self, parent,label=None, displayLabel=True,includeInReports=True, name = '', data = None, prePlottingCallback = None):
        ## want to init a graphics view with a new graphics scene, the scene will be accessable through the widget.
        graphicsView.__init__(self, parent, label = label, displayLabel = displayLabel, includeInReports = includeInReports,
            name = name, data = data)
        ## __init__(self, parent,label=_('Graph'), displayLabel=True,includeInReports=True, name = '', data = None)
        
    ################################
    ####   Themes              #####
    ################################
        
        self.prePlottingCallback = prePlottingCallback
        self.options = {
            'device': {
                'imageType':'svg',
                'dpi':'75',
                'bgColor':'#FFFFFF',
                'dheight':400,
                'dwidth':400,
                'units':'px'},
            'main':{
                'col':None,
                'lty':None,
                'lwd':None,
                'pch':None,},
            'title':{
                'main':'',
                'xlab':'',
                'ylab':'',
                'col.main':'#000000',
                'col.sub':'#000000',
                'col.lab':'#000000'},
            'par':{
                'cex.axis':1,
                'cex.lab':1,
                'cex.main':1,
                'cex.sub':1,
                'cex':1,
                'col.axis':'#000000'}
            }
        
        
        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')
        self.monkey = checkBox(hbox, label='useopts', displayLabel = False, buttons={'true':'Use Custom Plot Options'}, callback = self.enablePlotOptions)
        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=[(1, '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', 'cairo' ,'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('PDF (LATEX)')
        save.addAction('Post Script')
        save.addAction('JPEG')
        if sys.platform == 'win32':
            save.addAction('WMF')
        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)

        
        self.graphicOptionsWidget.hide()