示例#1
0
    def __init__(self, parent=None, signalManager=None):
        OWRpy.__init__(self)
        self.setRvariableNames(["hclust"])
        self.data = {}
        self.RFunctionParam_d = ''
        self.inputs.addInput('id0', 'd', redRRDataFrame, self.processd)

        self.outputs.addOutput('id0', 'hclust Output', redRRList)

        self.RFunctionParammethod_comboBox = comboBox(self.controlArea,
                                                      label="Cluster Method:",
                                                      items=[
                                                          "complete", "ward",
                                                          "single", "average",
                                                          "mcquitty",
                                                          "centroid"
                                                      ])
        self.RFunctionParamdistmethod_comboBox = comboBox(
            self.controlArea,
            label='Dist Method:',
            items=[
                "euclidean", "maximum", "manhattan", "canberra", "binary",
                "minkowski"
            ])
        redRCommitButton(self.bottomAreaRight,
                         "Commit",
                         callback=self.commitFunction)
示例#2
0
    def __init__(self, **kwargs):
        OWRpy.__init__(self, **kwargs)
        self.RFunctionParam_data = ""
        self.setRvariableNames(["norm"])
        self.require_librarys(["reshape", "gregmisc"])
        self.inputs.addInput("data", "Data Table", signals.RDataFrame.RDataFrame, self.processdata)
        self.outputs.addOutput("data", "Data Table", signals.RDataFrame.RDataFrame)
        """Input sigals are base.RDataFrame, Output signals are base.RDataFrame"""

        self.GUIPARAM_Grouping = comboBox(self.controlArea, label="Sample Groupings")
        self.GUIPARAM_NormGroup = comboBox(
            self.controlArea, label="Normalization Groupings", callback=self.setGUIPARAM_NormPoint
        )
        self.GUIPARAM_NormPoint = comboBox(self.controlArea, label="Normalization Point")
        self.GUIPARAM_Measure = comboBox(self.controlArea, label="Measure Values")
        """
        .. rrgui:: Sample Groupings; the column that will be used to normalize against.

        .. rrgui:: Normalization Groupings; the column that holds the normalization descriptors for each group.
        
        .. rrgui:: Normalization Point; the point in the Normalization Groupings that the Sample Groupings values will be normalized to.
        
        .. rrgui:: Measure Values; the values that will be normalized.
        """

        self.GUIOUTPUT_Text = textEdit(self.controlArea, label="Data Sample")

        redRCommitButton(self.bottomAreaRight, "Commit", callback=self.commitFunction)
示例#3
0
文件: ConSig.py 项目: aourednik/Red-R
 def __init__(self, parent=None, signalManager=None):
     OWRpy.__init__(self)
     self.setRvariableNames(['genesScores', 'conceptScores'])
     self.concepts = ''          ## the concepts, optional will replace the reading of the file
     self.geneIDs = ''           ## the geneIDs to be found in the concepts
     self.reference = ''         ## the set of reference genes, 
     self.packageDir = ''        ## the packageDir where all of the concept files are stored if not otherwise available.
     self.map = None
     self.go = None
     
     self.inputs.addInput('geneIDs', 'Gene ID List', redRDataFrame, self.processGeneIDs)
     self.inputs.addInput('consigData', 'Concepts Data [optional]', redRDataFrame, self.processConcepts)
     self.inputs.addInput('referenceList', 'Gene Reference List [optional]', redRRList, self.processReference)
     
     self.outputs.addOutput('scores', 'ConSig Concept Scores', redRDataFrame)
     self.outputs.addOutput('genescores', 'ConSig Gene Scores', redRDataFrame)
     
     myTabWidget = redRTabWidget(self.controlArea)
     geneIDArea = myTabWidget.createTabPage('Gene ID\'s')
     conceptsArea = myTabWidget.createTabPage('Concepts')
     fileSetupArea = myTabWidget.createTabPage('File Setup')
     
     ## file selection for consig files
     self.dirLabel = redRWidgetLabel(fileSetupArea, 'No Directory Currently Selected')
     button(fileSetupArea, label = 'Change File Directory', callback = self.changeFileDir)
     
     ## concepts area
     button(conceptsArea, label = 'Parse Concepts', callback = self.parseConcepts)
     
     ## 
     self.genes_geneIDCol = comboBox(geneIDArea, label = 'Gene ID Column')
     self.genes_scoreCol = comboBox(geneIDArea, label = 'Gene Scores (Weights)')
     
     redRCommitButton(self.controlArea, label = 'Commit', callback = self.commit)
示例#4
0
    def __init__(self, parent=None, signalManager=None):
        OWRpy.__init__(self)
        self.setRvariableNames(["pairwise.t.test"])
        self.RFunctionParam_x = ""
        self.RFunctionParam_pool_sd = "TRUE"
        self.RFunctionParam_g = ""
        self.RFunctionParam_p_adjust_method = "p.adjust.methods"
        self.indata = ''
        self.inputs.addInput('id0', 'R Data Frame', redRRDataFrame,
                             self.process)

        self.outputs.addOutput('id0', 'pairwise.t.test Output', redRRVariable)

        box = widgetBox(self.controlArea)
        self.RFunctionParam_x = comboBox(box, label="Values:")
        self.RFunctionParam_pool_sd = comboBox(
            box, label="Pool Standard Deviation:", items=['True', 'False'])
        self.RFunctionParam_g = comboBox(box, label="Groups Column:")
        self.RFunctionParam_p_adjust_method = comboBox(
            box,
            label="P-value Adjust Method:",
            items=[
                "holm", "hochberg", "hommel", "bonferroni", "BH", "BY", "fdr",
                "none"
            ])
        self.alternative = comboBox(box,
                                    label='Alternative Hypothesis:',
                                    items=['two.sided', 'greater', 'less'])
        redRCommitButton(self.bottomAreaRight,
                         "Commit",
                         callback=self.commitFunction)
        self.RoutputWindow = textEdit(box, label='R Output')
示例#5
0
 def __init__(self, **kwargs):
     OWRpy.__init__(self, **kwargs)
     self.setRvariableNames(['genesScores', 'conceptScores'])
     self.concepts = ''          ## the concepts, optional will replace the reading of the file
     self.geneIDs = ''           ## the geneIDs to be found in the concepts
     self.reference = ''         ## the set of reference genes, 
     self.packageDir = ''        ## the packageDir where all of the concept files are stored if not otherwise available.
     self.map = None
     self.go = None
     
     self.inputs.addInput('geneIDs', 'Gene ID List', redRDataFrame, self.processGeneIDs)
     self.inputs.addInput('consigData', 'Concepts Data [optional]', redRDataFrame, self.processConcepts)
     self.inputs.addInput('referenceList', 'Gene Reference List [optional]', redRRList, self.processReference)
     
     self.outputs.addOutput('scores', 'ConSig Concept Scores', redRDataFrame)
     self.outputs.addOutput('genescores', 'ConSig Gene Scores', redRDataFrame)
     
     myTabWidget = redRTabWidget(self.controlArea)
     geneIDArea = myTabWidget.createTabPage('Gene ID\'s')
     conceptsArea = myTabWidget.createTabPage('Concepts')
     fileSetupArea = myTabWidget.createTabPage('File Setup')
     
     ## file selection for consig files
     self.dirLabel = redRWidgetLabel(fileSetupArea, 'No Directory Currently Selected')
     button(fileSetupArea, label = 'Change File Directory', callback = self.changeFileDir)
     
     ## concepts area
     button(conceptsArea, label = 'Parse Concepts', callback = self.parseConcepts)
     
     ## 
     self.genes_geneIDCol = comboBox(geneIDArea, label = 'Gene ID Column')
     self.genes_scoreCol = comboBox(geneIDArea, label = 'Gene Scores (Weights)')
     
     redRCommitButton(self.controlArea, label = 'Commit', callback = self.commit)
 def addComboBox(self, key, name, items):
     """Adds a comboBox to the DynamicComboBox"""
     if key in self.comboBoxes.keys():
         if items:
             self.comboBoxes[key].update(items)
     else:
         self.comboBoxes[key] = comboBox(self, label = name, items = items, orientation = self.orientation, callback = self.callback, toolTip = self.toolTip)
示例#7
0
    def __init__(self, parent=None, signalManager=None):
        OWRpy.__init__(self)
        self.RFunctionParam_x = ''
        self.inputs.addInput('id0', 'x', redRRModelFit, self.processx)

        self.RFunctionParamtype_comboBox = comboBox(
            self.controlArea,
            label="type:",
            items=["'b',both", "'l','lines'", "'p',points"])
        self.RFunctionParamlegendpos_comboBox = comboBox(
            self.controlArea,
            label="legendpos:",
            items=["'topright'", "'topleft'", "'bottomright'", "'bottomleft'"])
        redRCommitButton(self.bottomAreaRight,
                         "Commit",
                         callback=self.commitFunction)
示例#8
0
    def __init__(self, parent=None, signalManager=None):
        OWRpy.__init__(self)
        self.RFunctionParam_y = ''
        self.RFunctionParam_x = ''
        self.inputs.addInput('id0', 'y', redRRVector, self.processy)
        self.inputs.addInput('id1', 'x', redRRVector, self.processx)

        self.RFunctionParamxlab_lineEdit = lineEdit(self.controlArea,
                                                    label="xlab:",
                                                    text='NULL')
        self.RFunctionParamspan_lineEdit = lineEdit(self.controlArea,
                                                    label="span:",
                                                    text='2/3')
        self.RFunctionParamdegree_lineEdit = lineEdit(self.controlArea,
                                                      label="degree:",
                                                      text='1')
        self.RFunctionParamfamily_comboBox = comboBox(
            self.controlArea, label="family:", items=['symmetric', 'gaussian'])
        self.RFunctionParamylab_lineEdit = lineEdit(self.controlArea,
                                                    label="ylab:",
                                                    text='NULL')
        self.RFunctionParamevaluation_lineEdit = lineEdit(self.controlArea,
                                                          label="evaluation:",
                                                          text='50')
        self.RFunctionParamylim_lineEdit = lineEdit(self.controlArea,
                                                    label="ylim:",
                                                    text='')
        self.commit = redRCommitButton(self.bottomAreaRight,
                                       "Commit",
                                       callback=self.commitFunction,
                                       processOnInput=True)
示例#9
0
    def __init__(self, parent=None, signalManager=None):
        OWRpy.__init__(self)
        self.setRvariableNames(["plsr"])
        self.data = {}
        self.RFunctionParam_data = ''
        self.inputs.addInput('id0', 'data', redRRDataFrame, self.processdata)

        self.outputs.addOutput('id0', 'plsr Output', redRRModelFit)

        self.RFunctionParamformula_lineEdit = lineEdit(self.controlArea,
                                                       label="formula:",
                                                       text='')
        self.RFunctionParamscale_radioButtons = radioButtons(
            self.controlArea,
            label="Scale the data:",
            buttons=['TRUE', 'FALSE'],
            setChecked='FALSE',
            orientation='horizontal')
        self.RFunctionParammethod_lineEdit = lineEdit(self.controlArea,
                                                      label="method:",
                                                      text='')
        self.RFunctionParamncomp_lineEdit = lineEdit(self.controlArea,
                                                     label="ncomp:",
                                                     text='10')
        self.RFunctionParamvalidation_comboBox = comboBox(
            self.controlArea, label="validation:", items=["none", "CV", "LOO"])
        redRCommitButton(self.bottomAreaRight,
                         "Commit",
                         callback=self.commitFunction)
示例#10
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
示例#11
0
    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
示例#12
0
        def __init__(self, **kwargs):
            OWRpy.__init__(self, **kwargs)
                self.RFunctionParam_x = ''
                self.inputs.addInput('id0', 'x', redRRModelFit, self.processx)

                
                self.RFunctionParamplottype_comboBox = comboBox(self.controlArea, label = "plottype:", items = ["'prediction'","'validation'","'coefficients'","'scores'","'loadings'","'biplot'","'correlation'"])
                redRCommitButton(self.bottomAreaRight, "Commit", callback = self.commitFunction)
示例#13
0
	def __init__(self, parent=None, signalManager=None):
		OWRpy.__init__(self)
		self.RFunctionParam_object = ''
		self.inputs.addInput('id0', 'object', redRRModelFit, self.processobject)

		
		self.RFunctionParamtype_comboBox = comboBox(self.controlArea, label = "type:", items = ["'p'; points","'l'; lines"])
		redRCommitButton(self.bottomAreaRight, "Commit", callback = self.commitFunction)
示例#14
0
	def __init__(self, parent=None, signalManager=None):
		OWRpy.__init__(self)
		self.RFunctionParam_x = ''
		self.inputs.addInput('id0', 'x', redRRModelFit, self.processx)

		
		self.RFunctionParamplottype_comboBox = comboBox(self.controlArea, label = "plottype:", items = ["'prediction'","'validation'","'coefficients'","'scores'","'loadings'","'biplot'","'correlation'"])
		redRCommitButton(self.bottomAreaRight, "Commit", callback = self.commitFunction)
示例#15
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)
示例#16
0
文件: sort.py 项目: aourednik/Red-R
    def __init__(self, parent=None, signalManager=None):
        OWRpy.__init__(self)
        self.setRvariableNames(["sort"])
        self.data = {}
         
        self.RFunctionParam_x = ''
        self.inputs.addInput('id0', _('Data Tabel'), redRRDataFrame, self.processx)

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

        self.standardTab = widgetBox(self.controlArea)
        self.options =  checkBox(self.standardTab,label=_('Options'),
        buttons = [_("Decreasing"), _('NA Last')], orientation='horizontal')
        # self.standardTab.layout().setAlignment(self.options,Qt.AlignLeft)
        
        self.sortingColumn1 = comboBox(self.standardTab, label = _('First Column to Sort:'))
        self.sortingColumn2 = comboBox(self.standardTab, label = _('Second Column to Sort:'))
        self.sortingColumn3 = comboBox(self.standardTab, label = _('Third Column to Sort:'))
        
        self.commit = redRCommitButton(self.bottomAreaRight, _("Commit"), callback = self.commitFunction,
        processOnInput=True)
示例#17
0
    def __init__(self, **kwargs):
        settingsList = ['output_txt', 'parameters']
        OWRpy.__init__(self, **kwargs)
        
        self.functionParams = ''
        self.widgetInputsName = []
        self.widgetInputsClass = []
        self.widgetInputsFunction = []
        self.numberInputs = 0
        self.numberOutputs = 0
        
        self.fieldList = {}
        self.functionInputs = {}
        self.processOnConnect = 1

        # GUI
        # several tabs with different parameters such as loading in a function, setting parameters, setting inputs and outputs
        tabs = tabWidget.tabWidget(self.controlArea)
        functionTab = tabs.createTabPage(_("Function Info"), orientation = 'vertical')
        codeTab = tabs.createTabPage(_("Code"))
        box = widgetBox.widgetBox(functionTab, orientation = 'horizontal')
        box.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Maximum)
        self.infoa = widgetLabel.widgetLabel(box, '')
        self.packageName = lineEdit.lineEdit(box, label = _('Package:'), orientation = 1)
        button.button(box, 'Load Package', callback = self.loadRPackage)
        self.functionName = lineEdit.lineEdit(box, label = _('Function Name:'), orientation = 1)
        button.button(box, 'Parse Function', callback = self.parseFunction)
        self.argsLineEdit = lineEdit.lineEdit(box, label = _('GUI Args'))
        self.connect(self.argsLineEdit, SIGNAL('textChanged(QString)'), self.setArgsLineEdit)
        box = widgetBox.widgetBox(functionTab)
        box.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
        self.inputArea = QTableWidget()
        box.layout().addWidget(self.inputArea)
        self.inputArea.setColumnCount(7)
        box = widgetBox.widgetBox(functionTab, orientation = 'horizontal')
        #self.inputArea.hide()
        self.connect(self.inputArea, SIGNAL("itemClicked(QTableWidgetItem*)"), self.inputcellClicked)
        
        self.functionAllowOutput = checkBox.checkBox(box, label = _('Allow Output'), buttons = [_('Allow Output')])
        self.captureROutput = checkBox.checkBox(box, label = 'Show Output', buttons = [_('Show Output')])
        
        
        #self.inputsCombobox = redRGUI.comboBox(box, label = 'Input Class:', items = self.getRvarClass_classes())
        self.outputsCombobox = comboBox.comboBox(box, label = _('Output Class:'), items = self.getRvarClass_classes())
        button.button(box, label = _('Accept Inputs'), callback = self.acceptInputs)
        button.button(box, _('Generate Code'), callback = self.generateCode)
        button.button(box, _('Launch Widget'), callback = self.launch)
        
        self.codeArea = QTextEdit()
        codeTab.layout().addWidget(self.codeArea)
示例#18
0
    def __init__(self, parent=None, signalManager=None):
        settingsList = ['output_txt', 'parameters']
        OWRpy.__init__(self)
        
        self.functionParams = ''
        self.widgetInputsName = []
        self.widgetInputsClass = []
        self.widgetInputsFunction = []
        self.numberInputs = 0
        self.numberOutputs = 0
        
        self.fieldList = {}
        self.functionInputs = {}
        self.processOnConnect = 1

        # GUI
        # several tabs with different parameters such as loading in a function, setting parameters, setting inputs and outputs
        tabs = tabWidget.tabWidget(self.controlArea)
        functionTab = tabs.createTabPage(_("Function Info"))
        codeTab = tabs.createTabPage(_("Code"))
        box = widgetBox.widgetBox(functionTab, "")
        box.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Maximum)
        self.infoa = widgetLabel.widgetLabel(box, '')
        self.packageName = lineEdit.lineEdit(box, label = _('Package:'), orientation = 1)
        button.button(box, 'Load Package', callback = self.loadRPackage)
        self.functionName = lineEdit.lineEdit(box, label = _('Function Name:'), orientation = 1)
        button.button(box, 'Parse Function', callback = self.parseFunction)
        self.argsLineEdit = lineEdit.lineEdit(box, label = _('GUI Args'))
        self.connect(self.argsLineEdit, SIGNAL('textChanged(QString)'), self.setArgsLineEdit)
        box = widgetBox.widgetBox(functionTab)
        box.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
        self.inputArea = QTableWidget()
        box.layout().addWidget(self.inputArea)
        self.inputArea.setColumnCount(7)
        box = widgetBox.widgetBox(functionTab, orientation = 'horizontal')
        #self.inputArea.hide()
        self.connect(self.inputArea, SIGNAL("itemClicked(QTableWidgetItem*)"), self.inputcellClicked)
        
        self.functionAllowOutput = checkBox.checkBox(box, label = _('Allow Output'), displayLable = False, buttons = [_('Allow Output')])
        self.captureROutput = checkBox.checkBox(box, buttons = [_('Show Output')])
        
        
        #self.inputsCombobox = redRGUI.comboBox(box, label = 'Input Class:', items = self.getRvarClass_classes())
        self.outputsCombobox = comboBox.comboBox(box, label = _('Output Class:'), items = self.getRvarClass_classes())
        button.button(box, label = _('Accept Inputs'), callback = self.acceptInputs)
        button.button(box, _('Generate Code'), callback = self.generateCode)
        button.button(box, _('Launch Widget'), callback = self.launch)
        
        self.codeArea = QTextEdit()
        codeTab.layout().addWidget(self.codeArea)
示例#19
0
    def __init__(self, parent=None, signalManager=None):
        OWRpy.__init__(self)
        self.RFunctionParam_y = ''
        self.RFunctionParam_x = ''
        self.dataFrame = ''
        self.plotAttributes = {}
        self.RFunctionParam_plotatt = ''
        self.inputs.addInput('id0', 'y', [redRRVector, redRList], self.processy)
        self.inputs.addInput('id1', 'x', redRRVector, self.processx)
        self.inputs.addInput('id2', 'plotatt', redRRPlotAttribute, self.processplotatt, multiple = True)

        
        self.RFunctionParamxlab_lineEdit = lineEdit(self.controlArea, label = "X Label:", text = 'X Label')
        self.RFunctionParamylab_lineEdit = lineEdit(self.controlArea, label = "Y Label:", text = 'Y Label')
        self.RFunctionParammain_lineEdit = lineEdit(self.controlArea, label = "Main Title:", text = 'Main Title')
        self.namesListX = comboBox(self.controlArea, label = 'X Axis Data:')
        self.namesListX.setEnabled(False)
        self.namesListY = comboBox(self.controlArea, label = 'Y Axis Data:')
        self.namesListY.setEnabled(False)
        self.graphicsView = graphicsView(self.controlArea,label='XY Plot',displayLabel=False,
        name = self.captionTitle)
        self.commit = redRCommitButton(self.bottomAreaRight, "Commit", callback = self.commitFunction,
        processOnInput=True)
示例#20
0
	def __init__(self, parent=None, signalManager=None):
		OWRpy.__init__(self)
		self.setRvariableNames(["ks.test"])
		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.RFunctionParamalternative_comboBox = comboBox(self.controlArea, label = "alternative:", items = ["two.sided","less","greater"])
		self.RFunctionParamexact_lineEdit = lineEdit(self.controlArea, label = "exact:", text = 'NULL')
		redRCommitButton(self.bottomAreaRight, "Commit", callback = self.commitFunction)
		self.RoutputWindow = textEdit(self.controlArea, label = "RoutputWindow")
示例#21
0
文件: spline.py 项目: aourednik/Red-R
    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")
示例#22
0
 def __init__(self, **kwargs):
     OWRpy.__init__(self, **kwargs))
     self.setRvariableNames(["dotchart"])
     self.data = {}
     self.RFunctionParam_x = ''
     self.labels = ''
     self.inputs.addInput('id0', 'Data', redRRMatrix, self.processx)
     self.inputs.addInput('id1', 'Labels', redRList, self.processLabels)
     
     self.standardTab = self.controlArea
     
     self.RFunctionParammain_lineEdit =  lineEdit(self.standardTab,  label = "Main Title:")
     self.RFunctionParamxlab_lineEdit =  lineEdit(self.standardTab,  label = "X Label:")
     self.RFunctionParamylab_lineEdit =  lineEdit(self.standardTab,  label = "Y Label:")
     self.labelNames = comboBox(self.standardTab, label = 'Label Data')
     self.commit = redRCommitButton(self.bottomAreaRight, "Commit", callback = self.commitFunction,
     processOnInput=True)
示例#23
0
    def __init__(self, parent=None, signalManager=None):
        OWRpy.__init__(self)
        self.setRvariableNames(["melt.data.frame", "melt.data.frame.cm"])
        self.RFunctionParam_data = ''
        self.data = {}
        self.inputs.addInput('id0', _('data'), redRRDataFrame, self.processdata)

        self.outputs.addOutput('id0', _('melt.data.frame Output'), redRRDataFrame)

        
        box = widgetBox(self.controlArea, _("Widget Box"))
        self.RFunctionParam_na_rm = comboBox(box, label = _("Remove NA:"), items = [_('Yes'), _('No')])
        self.RFunctionParam_measure_var = listBox(box, label = _("Result Variable:"), toolTip = _('The column that contains the result or the measurement that the data should be melted around.'))
        self.RFunctionParam_measure_var.setSelectionMode(QAbstractItemView.ExtendedSelection)
        self.RFunctionParam_id_var = listBox(box, label = _("Groupings:"), toolTip = _('The columns indicating the groupings of the data.'))
        self.RFunctionParam_id_var.setSelectionMode(QAbstractItemView.ExtendedSelection)
        self.RFunctionParam_variable_name = lineEdit(box, label = _("New Group Name:"), toolTip = _('The name of the new column that the groupings will be put into.'))
        self.commit = redRCommitButton(self.bottomAreaRight, _("Commit"), callback = self.commitFunction, 
        processOnInput=True)
示例#24
0
    def __init__(self,
                 parent=None,
                 signalManager=None,
                 forceInSignals=None,
                 forceOutSignals=None):
        OWRpy.__init__(self)
        # the variables
        self.parentData = {}
        self.data = ''
        self.setRvariableNames(['nameProtector', 'newDataFromNameProtector'])
        self.inputs.addInput('id0', _('Data Frame'), redRRDataFrame,
                             self.gotDF)
        self.inputs.addInput('id1', _('Vector'), redRRVector, self.gotV)

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

        ### The data frame GUI
        self.dfbox = widgetBox(self.controlArea)
        self.nameProtectDFcheckBox = checkBox(
            self.dfbox,
            label=_('Protect the names in:'),
            buttons=[_('Rows'), _('Columns')],
            toolTips=[
                _('Use make.names to protect the names in the rows.'),
                _('Use make.names to protect the names in the columns.')
            ])
        self.namesProtectDFcomboBox = comboBox(
            self.dfbox, label=_('Column names to protect:'))
        self.commit = commitButton(self.dfbox,
                                   _("Commit"),
                                   callback=self.dfCommit,
                                   processOnInput=True)

        ### The Vector GUI
        self.vbox = widgetBox(self.controlArea)
        self.vbox.hide()
        self.commitVbutton = button(self.vbox,
                                    _("Commit"),
                                    callback=self.vCommit,
                                    alignment=Qt.AlignRight)
示例#25
0
    def __init__(self, parent=None, signalManager=None):
        OWRpy.__init__(self)
        self.setRvariableNames(["fisher.test"])
        self.data = {}
        self.RFunctionParam_x = ''
        self.inputs.addInput('id0', 'x', redRRMatrix, self.processx)

        self.RFunctionParamB_lineEdit = lineEdit(
            self.controlArea,
            label="Number of Replicates for Monte Carlo:",
            text='2000')
        self.RFunctionParamhybrid_checkBox = checkBox(
            self.controlArea,
            label="Hybrid Probabilities:",
            buttons=['FALSE', 'TRUE'],
            setChecked='FALSE')
        self.RFunctionParamsimulate_p_value_lineEdit = checkBox(
            self.controlArea,
            label="simulate_p_value:",
            buttons=['FALSE,TRUE'],
            setChecked='FALSE')
        self.RFunctionParamconf_level_lineEdit = lineEdit(
            self.controlArea, label="Confidence Level:", text='0.95')
        self.RFunctionParamconf_int_lineEdit = checkBox(
            self.controlArea,
            label="Calculate Confidence Interval:",
            buttons=['TRUE', 'FALSE'],
            setChecked='TRUE')
        self.RFunctionParamalternative_comboBox = comboBox(
            self.controlArea,
            label="Alternative Hypothesis:",
            items=["two.sided", "greater", "less"])
        self.RFunctionParamor_lineEdit = lineEdit(self.controlArea,
                                                  label="Odds Ratio:",
                                                  text='1')
        redRCommitButton(self.bottomAreaRight,
                         "Commit",
                         callback=self.commitFunction)
        self.RoutputWindow = textEdit(self.controlArea,
                                      label="R Output Window")
示例#26
0
    def __init__(self, parent=None, signalManager=None):
        OWRpy.__init__(self)
        self.setRvariableNames(["dotchart"])
        self.data = {}
        self.RFunctionParam_x = ''
        self.labels = ''
        self.inputs.addInput('id0', 'Data', redRRMatrix, self.processx)
        self.inputs.addInput('id1', 'Labels', redRList, self.processLabels)

        self.standardTab = self.controlArea

        self.RFunctionParammain_lineEdit = lineEdit(self.standardTab,
                                                    label="Main Title:")
        self.RFunctionParamxlab_lineEdit = lineEdit(self.standardTab,
                                                    label="X Label:")
        self.RFunctionParamylab_lineEdit = lineEdit(self.standardTab,
                                                    label="Y Label:")
        self.labelNames = comboBox(self.standardTab, label='Label Data')
        self.commit = redRCommitButton(self.bottomAreaRight,
                                       "Commit",
                                       callback=self.commitFunction,
                                       processOnInput=True)
示例#27
0
    def __init__(self, parent=None, signalManager=None):
        OWRpy.__init__(self)
        self.setRvariableNames(["var.test"])
        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.RFunctionParamalternative_comboBox = comboBox(
            self.controlArea,
            label="alternative:",
            items=["two.sided", "less", "greater"])
        self.RFunctionParamratio_lineEdit = lineEdit(self.controlArea,
                                                     label="ratio:",
                                                     text='1')
        self.RFunctionParamconf_level_lineEdit = lineEdit(
            self.controlArea, label='Confidence Interval:', text='0.95')
        self.commit = redRCommitButton(self.bottomAreaRight,
                                       "Commit",
                                       callback=self.commitFunction,
                                       processOnInput=True)
        self.RoutputWindow = textEdit(self.controlArea, label="RoutputWindow")
示例#28
0
    def __init__(self, **kwargs):
        OWRpy.__init__(self, **kwargs)
        self.data = None
        self.RFunctionParam_x = ''
        self.plotAttributes = {}
        self.saveSettingsList = ['plotArea', 'data', 'RFunctionParam_x', 'plotAttributes']
        self.inputs.addInput('id0', 'x', redRRVariable, self.processx)

        # self.R('data <- iris')
        # self.RFunctionParam_x = 'data'
        self.data = 'iris'
        self.plotArea = graphicsView2(self.controlArea,label='Plot', displayLabel=False)
        #self.plotArea.hideTab('Points/Lines')
        
        self.plotArea.setCustomPlot(self.updatePlot)
        
        self.plotControls = self.plotArea.createTab('Barplot')
        imageBox = self.plotArea.createControlGroup('Barplot',label='Barplot')
        
        self.namesCombo = comboBox(imageBox,label='Group Name')
        self.heightCombo = listBox(self.plotControls,label='Heights',selectionMode=QAbstractItemView.ExtendedSelection)
        
        self.commit = redRCommitButton(self.bottomAreaRight, "Commit", callback = self.commitFunction,
        processOnInput=True)
 def __init__(self, **kwargs):
     OWRpy.__init__(self, **kwargs)
     
     self.require_librarys(["ggplot2"])
     self.RFunctionParam_y = ''
     self.RFunctionParam_x = ''
     self.setRvariableNames(["lineplot"])
     self.inputs.addInput('id0', 'Data Table', redRDataFrame, self.processy)
     self.colours = [(0, _('Two Color Gradient')), (1, _('Three Color Gradient')), (2, _('Sequential Brewer Colors')), (3, _('Diverging Brewer Colors')), (4, _('Qualitative Brewer Colors')), (5, _('No Color'))]
     self.colourScaleWidgets = []
     topBox = redRWidgetBox(self.controlArea, orientation = 'horizontal')
     aestheticsBox = redRGroupBox(topBox, label = _('Aesthetics'), orientation = 'horizontal')
     aestheticsBox.setSizePolicy(QSizePolicy(QSizePolicy.Maximum, QSizePolicy.Maximum))
     self.xGroup = comboBox(aestheticsBox, label = _('X Values'))
     self.yData = comboBox(aestheticsBox, label = _('Y Values'))
     self.fillData = comboBox(aestheticsBox, label = _('Fill Data'), callback = self.fillDataChanged)
     self.linetypeCombo = comboBox(aestheticsBox, label = _('Line Type'))
     self.colourScale = comboBox(aestheticsBox, label = _('Color Scale'), items = self.colours, callback = self.colourScaleChanged)
     
     ## make the scale selector
     self.colourSelectorStack = stackedWidget(aestheticsBox)
     
     
     
     ## vlaue stack 0; gradient selector
     gradientBox = self.colourSelectorStack.createWidgetBox()
     self.colourScaleWidgets.append(gradientBox)
     self.gradientFrom = colorButton(gradientBox, label = _('From'), startColor = '#000000')
     self.gradientTo = colorButton(gradientBox, label = _('To'), startColor = '#FFFFFF')
     
     ## value stack 1; gradient2 selector
     gradient2Box = self.colourSelectorStack.createWidgetBox()
     self.colourScaleWidgets.append(gradient2Box)
     self.gradient2From = colorButton(gradient2Box, label = _('From'), startColor = '#FF0000')
     self.gradient2To = colorButton(gradient2Box, label = _('To'), startColor = '#00FF00')
     self.gradient2Via = colorButton(gradient2Box, label = _('Via'), startColor = '#FFFFFF')
     
     ## value stack 2; sequential brewer colors
     sequentialBox = self.colourSelectorStack.createWidgetBox()
     self.colourScaleWidgets.append(sequentialBox)
     self.sequentialPalettes = comboBox(sequentialBox, label = _('Palette'), items = [('Blues', _('Blues')), ('BuGn', _('Blue Green')), ('BuPu', _('Blue Purple')), ('GnBu', _('Green Blue')), ('Greens', _('Greens')), ('Greys', _('Greys')), ('Oranges', _('Oranges')), ('OrRd', _('Orange Red')), ('PuBu', _('Purple Blue')), ('PuBuGn', _('Purple Blue Green')), ('PuRd', _('Purple Red')), ('Purples', _('Purples')), ('RdPu', _('Red Purple')), ('Reds', _('Reds')), ('YlGn', _('Yellow Green')), ('YlGnBu', _('Yellow Green Blue')), ('YlOrBr', _('Yellow Orange Brown')), ('YlOrRd', _('Yellow Orange Red'))])
     self.sequentialVariations = spinBox(sequentialBox, label = _('Variations'), decimals = 0, min = 3, max = 9, value = 5)
     
     ## value stack 3; diverging brewer colors
     divergingBox = self.colourSelectorStack.createWidgetBox()
     self.colourScaleWidgets.append(divergingBox)
     paletteItems = [('BrBG', _('Brown Blue Green')), ('PiYG', _('Pink Yellow Green')), ('PRGn', _('Pink Red Green')), ('PuOr', _('Purple Orange')), ('RdBu', _('Red Blue')), ('RdGy', _('Red Grey')), ('RdYlBu', _('Red Yellow Blue')), ('RdYlGn', _('Red Yellow Green')), ('Spectral', _('Spectral'))]
     self.divergingPalettes = comboBox(divergingBox, label = _('Palette'), items = paletteItems)
     self.divergingVariations = spinBox(divergingBox, label = _('Variations'), decimals = 0, min = 3, max = 11, value = 5)
     
     ## value stack 4; qualitative brewer colors
     qualitativeBox = self.colourSelectorStack.createWidgetBox()
     self.colourScaleWidgets.append(qualitativeBox)
     self.qualitativePalettes = comboBox(qualitativeBox, label = _('Palette'), items = [('Accent', _('Accent')), ('Dark2', _('Dark2')), ('Paired', _('Paired')), ('Pastel1', _('Pastel1')), ('Pastel2', _('Pastel2')), ('Set1', _('Set1')), ('Set2', _('Set2')), ('Set3', _('Set3'))])
     self.qualitativeVariations = spinBox(qualitativeBox, label = _('Variations'), decimals = 0, min = 3, max = 8, value = 5)
     
     ## value stack 5; no color
     noColorBox = self.colourSelectorStack.createWidgetBox()
     self.colourScaleWidgets.append(noColorBox)
     
     ## error bars
     errorBox = redRGroupBox(self.controlArea, label = _('Error Bar Options'), orientation = 'horizontal')
     self.errorBarData = comboBox(errorBox, label = _('Error Bar Data'))
     
     
     self.colourSelectorStack.setCurrentIndex(0)
     
     self.graphicsView = redRGGPlot(self.controlArea,label='Box Plot',displayLabel=False,
     name = self.captionTitle)
     self.commit = redRCommitButton(self.bottomAreaRight, _("Commit"), callback = self.commitFunction,
     processOnInput=True)
     self.colourScaleChanged()
示例#30
0
 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)
示例#31
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)
示例#32
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)
示例#33
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()
示例#34
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()
示例#35
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
        self.customPlotFunction = None
        self.controlGroups = {}
        self.tabs = {}
    ################################
    ####   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,
                        }
                    ,'xlim': {
                        'default':None, 
                        'qtWidget':['xstart','xend'],
                        'getFunction': self.getLimits,
                        'setFunction': self.setLimits,                    
                    }
                    ,'ylim': {
                        'default':None, 
                        'qtWidget':['ystart','yend'],
                        'getFunction': self.getLimits,
                        'setFunction': self.setLimits,                    
                    }
                }
            },
            '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.tabWidget = tabWidget(self.graphicOptionsWidget)
        self.tabWidget.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.updatePlot)
        
        self.createTab('General')
        self.createTab('Points/Lines')
        self.createTab('Advanced')

    ################################
    ####   Advanced Tabs       #####
    ################################
        imageBox = self.createControlGroup('Advanced',label='Image Properties')
        self.optionWidgets['extrasLineEdit'] = lineEdit(imageBox, label = 'Advanced plotting parameters', 
        orientation='horizontal',
        toolTip = 'Add extra parameters to the main plot.\nPlease see documentation for more details about parameters.')
        
        self.optionWidgets['onlyAdvanced'] = checkBox(imageBox,
        buttons=['Only use the advanced options here'],
        label='advancedOnly',displayLabel=False)

    ################################
    ####   First Tabs          #####
    ################################
        imageBox = self.createControlGroup('General',label='Image Properties')
        # 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 = self.createControlGroup('General',label='Labels')
        
        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 = self.createControlGroup('General',label='Sizes')
        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)
        
        limitBox = self.createControlGroup('General',label='Limits')
        col2Box = widgetBox(limitBox,orientation='horizontal')
        column1 = widgetBox(col2Box,orientation='vertical')
        column2 = widgetBox(col2Box,orientation='vertical')

        self.optionWidgets['xstart'] = lineEdit(column1,label='X Start', width=40)
        self.optionWidgets['xend'] = lineEdit(column2,label='X End', width=40)
        self.optionWidgets['ystart'] = lineEdit(column1,label='Y Start', width=40)
        self.optionWidgets['yend'] = lineEdit(column2,label='Y End', width=40)
        

    
    ################################
    ####   Second Tabs         #####
    ################################
        colorBox = self.createControlGroup('Points/Lines',label='Colors')
        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)
        colorBox2 = self.createControlGroup('Points/Lines',label='More Colors')
        
        # 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 = self.createControlGroup('Points/Lines',label='Lines')
       
        self.optionWidgets['linesListBox'] = listBox(lineBox, label = 'Line types', displayLabel=False,
        selectionMode = QAbstractItemView.ExtendedSelection,
        items = [(1,'________'), (2,'- - - -'), (3,'........'), (4,'_._._._.'), 
        (5,'__ __ __'), (6,'__.__.__.')])
        
        
        
        pointBox = self.createControlGroup('Points/Lines',label='Points')
        
        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)
示例#36
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)
        self.topArea = widgetBox(self.controlArea,
        sizePolicy = QSizePolicy(QSizePolicy.Maximum,QSizePolicy.Maximum),includeInReports=False, orientation = 'horizontal')
        self.middleArea = widgetBox(self.controlArea)
        self.bottomArea = widgetBox(self.controlArea,includeInReports=False)  #, sizePolicy = QSizePolicy(QSizePolicy.Expanding,QSizePolicy.Expanding)
        
        self.middleArea.layout().addWidget(self)  # place the widget into the parent widget
        scene = QGraphicsScene()
        self.setScene(scene)
        self.parent = parent
        self.data = data
        self.printQuery = ''
        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' 
                          # }
                }
            }
        }
        
        
        ### ggplot options
        self.optionsDialog = dialog(self.controlArea)
        self.optionsTab = tabWidget(self.optionsDialog)
        
        plotGridTab = self.optionsTab.createTabPage("Plot Grid Area", orientation = 'vertical')
        
        self.panelGridMajorTheme = comboBox(plotGridTab, label = 'Major Grid General Theme', toolTip = 'If Ignore, no options are set for this.  If not None overrides all other options set and sets the theme specified.', items = [('ignore', 'Ignore'), ('none', 'None'), ('theme_bw()', 'Black and White'), ('theme_blank()', 'Blank Theme')])
        self.panelGridMajorColour = colorButton(plotGridTab, label = "Major Grid Color")
        self.panelGridMajorSize = spinBox(plotGridTab, label = "Major Grid Size")
        self.panelGridMajorLineType = comboBox(plotGridTab, label = "Major Grid Line Type", items = [('solid', 'Solid'), ('dotted', 'Dotted'), ('dashed', 'Dashed')])
        
        self.panelGridMinorTheme = comboBox(plotGridTab, label = 'Minor Grid General Theme', toolTip = 'If Ignore, no options are set for this.  If not None overrides all other options set and sets the theme specified.', items = [('ignore', 'Ignore'), ('none', 'None'), ('theme_bw()', 'Black and White'), ('theme_blank()', 'Blank Theme')])
        self.panelGridMinorColour = colorButton(plotGridTab, label = "Minor Grid Color")
        self.panelGridMinorSize = spinBox(plotGridTab, label = "Minor Grid Size")
        self.panelGridMinorLineType = comboBox(plotGridTab, label = "Minor Grid Line Type", items = [('solid', 'Solid'), ('dotted', 'Dotted'), ('dashed', 'Dashed')])
        
        panelTab = self.optionsTab.createTabPage("panel Background Options", orientation = 'vertical')
        
        self.panelBackgroundTheme = comboBox(panelTab, label = 'panel Background Theme', toolTip = 'If Ignore, no options are set for this.  If not None overrides all other options set and sets the theme specified.', items = [('ignore', 'Ignore'), ('none', 'None'), ('theme_bw()', 'Black and White'), ('theme_blank()', 'Blank Theme')])
        
        textTab = self.optionsTab.createTabPage("Text Options", orientation = 'vertical')
        
        self.useTextOptions = comboBox(textTab, label = 'Use Text Options', items = [('ignore', 'No'), ('yes', 'Yes')])
        self.plotTitle = lineEdit(textTab, label = 'Plot Title')
        self.plotTitleSize = spinBox(textTab, label = 'Title Font Size', min = 1, value = 20)
        self.plotTitleAngle = spinBox(textTab, label = 'Title Angle', min = 0, max = 360, value = 0)
        self.plotTitleFontFace = comboBox(textTab, label = 'Font Face', items = [('none', 'None'), ('bold', 'Bold')])
        
        self.axisTitleX = lineEdit(textTab, label = 'X Axis Title')
        self.axisTitleXColor = colorButton(textTab, label = 'X Axis Color')
        self.axisTitleXSize = spinBox(textTab, label = 'X Axis Title Size', min = 1, value = 14)
        self.axisTitleXAngle = spinBox(textTab, label = 'X Axis Title Angle', min = 0, max = 360, value = 0)
        self.axisTitleXFontFace = comboBox(textTab, label = 'X Axis Title Font Face', items = [('none', 'None'), ('bold', 'Bold')])
        
        self.axisTextXSize = spinBox(textTab, label = 'X Axis Text Size', min = 1, value = 14)
        self.axisTextXColor = colorButton(textTab, label = 'X Axis Text Color')
        self.axisTextXAngle = spinBox(textTab, label = 'X Axis Text Angle', min = 0, max = 360, value = 0)
        self.axisTextXFontFace = comboBox(textTab, label = 'X Axis Text Font Face', items = [('none', 'None'), ('bold', 'Bold')])
        
        self.axisTitleY = lineEdit(textTab, label = 'Y Axis Title')
        self.axisTitleYColor = colorButton(textTab, label = 'Y Axis Color')
        self.axisTitleYSize = spinBox(textTab, label = 'Y Axis Title Size', min = 1, value = 14)
        self.axisTitleYAngle = spinBox(textTab, label = 'Y Axis Title Angle', min = 0, max = 360, value = 0)
        self.axisTitleYFontFace = comboBox(textTab, label = 'Y Axis Title Font Face', items = [('none', 'None'), ('bold', 'Bold')])
        
        self.axisTextYSize = spinBox(textTab, label = 'Y Axis Text Size', min = 1, value = 14)
        self.axisTextYColor = colorButton(textTab, label = 'Y Axis Text Color')
        self.axisTextYAngle = spinBox(textTab, label = 'Y Axis Text Angle', min = 0, max = 360, value = 0)
        self.axisTextYFontFace = comboBox(textTab, label = 'Y Axis Text Font Face', items = [('none', 'None'), ('bold', 'Bold')])
        
        self.optionsDialog.hide()
        
        self.optionWidgets = {}
        self.colorList = ['#000000', '#ff0000', '#00ff00', '#0000ff']       

        self.extraOptionsLineEdit = lineEdit(self.topArea, label = 'Extra Options', toolTip = 'These options will be appended to the plotting call, remember that these are ggplot options that will be added to the plot object')
        self.extraOptionsLineEdit.controlArea.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Minimum)
        
        self.heightSpinBox = spinBox(self.topArea, label = 'Height', min = 0, value = 7, decimals = 3)
        self.widthSpinBox = spinBox(self.topArea, label = 'Width', min = 0, value = 7, decimals = 3)
        button(self.topArea, label = 'Show Options', callback = self.optionsDialog.show)
        
    
    ################################
    ### 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')
        save.addAction('SVG')
        self.menu.addAction('Copy')
        self.menu.addAction('Fit In Window')
        self.menu.addAction('Zoom Out')
        self.menu.addAction('Zoom In')
        self.menu.addAction('R Graphics Device')
        #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.imageType = 'svg'
        QObject.connect(self.dialog, SIGNAL('finished(int)'), self.dialogClosed)
示例#37
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)
示例#38
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')
示例#39
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)
示例#40
0
    def __init__(self, canvasDlg, *args):
        apply(QDialog.__init__,(self,) + args)
        self.canvasDlg = canvasDlg
        self.settings = dict(redREnviron.settings)        # create a copy of the settings dict. in case we accept the dialog, we update the redREnviron.settings with this dict
        if sys.platform == "darwin":
            self.setWindowTitle(_("Preferences"))
        else:
            self.setWindowTitle(_("Canvas Options"))
        self.topLayout = QVBoxLayout(self)
        self.topLayout.setSpacing(0)
        self.resize(350,300)
        self.toAdd = []
        self.toRemove = []

        self.tabs = QTabWidget(self)
        GeneralTab = OWGUI.widgetBox(self.tabs, margin = 4)
        GeneralTab.layout().setAlignment(Qt.AlignTop)
        # lookandFeel = OWGUI.widgetBox(self.tabs, margin = 4)
        # lookandFeel.layout().setAlignment(Qt.AlignTop)
        ExceptionsTab = OWGUI.widgetBox(self.tabs, margin = 4)
        ExceptionsTab.layout().setAlignment(Qt.AlignTop)
        RSettings = OWGUI.widgetBox(self.tabs, margin = 4)
        RSettings.layout().setAlignment(Qt.AlignTop)
        
        self.tabs.addTab(GeneralTab, "General")
        # self.tabs.addTab(lookandFeel, "Look and Feel")
        self.tabs.addTab(ExceptionsTab, "Exceptions & Logging")
        self.tabs.addTab(RSettings, _('R Settings'))
        QObject.connect(self.tabs, SIGNAL('currentChanged(int)'), self.onTabChange)
        #GeneralTab.layout().addStretch(1)
        
        # #################################################################
        # GENERAL TAB
        generalBox = OWGUI.widgetBox(GeneralTab, _('General Options'))
        
        self.emailEdit = OWGUI.lineEdit(generalBox, self.settings, "email", _("Email Address:"), orientation = 'horizontal')
        
        # self.helpModeSelection = OWGUI.checkBox(generalBox,self.settings,'helpMode',
        # _('Show help icons'))

        
        self.dontAskBeforeCloseCB= OWGUI.checkBox(generalBox, self.settings, "dontAskBeforeClose", 
        _("Don't ask to save schema before closing"), debuggingEnabled = 0)
        
        
        # #################################################################
        # LOOK AND FEEL TAB
        
        # validator = QIntValidator(self)
        # validator.setRange(0,10000)
        lookFeelBox = OWGUI.widgetBox(GeneralTab, _("Look and Feel Options"))

        self.snapToGridCB = OWGUI.checkBox(lookFeelBox, self.settings, "snapToGrid", 
        _("Snap widgets to grid"), debuggingEnabled = 0)
        self.showSignalNamesCB = OWGUI.checkBox(lookFeelBox, self.settings, "showSignalNames", 
        _("Show signal names between widgets"), debuggingEnabled = 0)
        self.saveWidgetsPositionCB = OWGUI.checkBox(lookFeelBox, self.settings, "saveWidgetsPosition", 
        _("Save size and position of widgets"), debuggingEnabled = 0)
        
        items = ["%d x %d" % (v,v) for v in redRStyle.iconSizeList]
        # val = min(len(items)-1, self.settings['schemeIconSize'])
        self.schemeIconSizeCombo = OWGUI.comboBoxWithCaption(lookFeelBox, self.settings, 'schemeIconSize', 
        _("Scheme icon size:"), items = items, tooltip = _("Set the size of the widget icons on the scheme"), 
        debuggingEnabled = 0)

        # redREnviron.settings["toolbarIconSize"] = min(len(items)-1, redREnviron.settings["toolbarIconSize"])
        
        self.toolbarIconSizeCombo = OWGUI.comboBoxWithCaption(lookFeelBox, self.settings, "toolbarIconSize", 
        _("Widget Tree Icon size:"), items = items, 
        tooltip = _("Set the size of the widget icons in the toolbar, tool box, and tree view area"), 
        debuggingEnabled = 0)

        # hbox1 = OWGUI.widgetBox(GeneralTab, orientation = "horizontal")
        
        # canvasDlgSettings = OWGUI.widgetBox(hbox1, "Canvas Dialog Settings")
        # schemeSettings = OWGUI.widgetBox(hbox1, "Scheme Settings") 
         
        # self.widthSlider = OWGUI.qwtHSlider(canvasDlgSettings, self.settings, "canvasWidth", 
        # minValue = 300, maxValue = 1200, label = "Canvas width:  ", step = 50, precision = " %.0f px", debuggingEnabled = 0)
        
        # self.heightSlider = OWGUI.qwtHSlider(canvasDlgSettings, self.settings, "canvasHeight", 
        # minValue = 300, maxValue = 1200, label = "Canvas height:  ", step = 50, precision = " %.0f px", debuggingEnabled = 0)
        
        # OWGUI.separator(canvasDlgSettings)
        

        OWGUI.comboBox(lookFeelBox, self.settings, "style", label = _("Window style:"), orientation = "horizontal", 
        items = redRStyle.QtStyles, sendSelectedValue = 1, debuggingEnabled = 0)
        OWGUI.checkBox(lookFeelBox, self.settings, "useDefaultPalette", _("Use style's standard palette"), debuggingEnabled = 0)
        
        self.language = comboBox(lookFeelBox, label = _('Language'), items = [u'English', u'Fran\u00E7aise', u'Deutsch'])
        # selectedWidgetBox = OWGUI.widgetBox(schemeSettings, orientation = "horizontal")
        # self.selectedWidgetIcon = ColorIcon(selectedWidgetBox, redRStyle.widgetSelectedColor)
        # selectedWidgetBox.layout().addWidget(self.selectedWidgetIcon)
        # selectedWidgetLabel = OWGUI.widgetLabel(selectedWidgetBox, " Selected widget")

        # activeWidgetBox = OWGUI.widgetBox(schemeSettings, orientation = "horizontal")
        # self.activeWidgetIcon = ColorIcon(activeWidgetBox, redRStyle.widgetActiveColor)
        # activeWidgetBox.layout().addWidget(self.activeWidgetIcon)
        # selectedWidgetLabel = OWGUI.widgetLabel(activeWidgetBox, " Active widget")

        # activeLineBox = OWGUI.widgetBox(schemeSettings, orientation = "horizontal")
        # self.activeLineIcon = ColorIcon(activeLineBox, redRStyle.lineColor)
        # activeLineBox.layout().addWidget(self.activeLineIcon)
        # selectedWidgetLabel = OWGUI.widgetLabel(activeLineBox, " Active Lines")

        # inactiveLineBox = OWGUI.widgetBox(schemeSettings, orientation = "horizontal")
        # self.inactiveLineIcon = ColorIcon(inactiveLineBox, redRStyle.lineColor)
        # inactiveLineBox.layout().addWidget(self.inactiveLineIcon)
        # selectedWidgetLabel = OWGUI.widgetLabel(inactiveLineBox, " Inactive Lines")
        
        

        # #################################################################
        # EXCEPTION TAB
        
        debug = OWGUI.widgetBox(ExceptionsTab, _("Debug"))
        # self.setDebugModeCheckBox = OWGUI.checkBox(debug, self.settings, "debugMode", "Set to debug mode") # sets the debug mode of the canvas.
        
        
        self.verbosityCombo = OWGUI.comboBox(debug, self.settings, "outputVerbosity", label = _("Set level of widget output: "), 
        orientation='horizontal', items=redRLog.logLevelsName)
        self.displayTraceback = OWGUI.checkBox(debug, self.settings, "displayTraceback", _('Display Traceback'))
        
        # self.exceptionLevel = redRSpinBox(debug, label = 'Exception Print Level:', toolTip = 'Select the level of exception that will be printed to the Red-R general output', min = 0, max = 9, value = redREnviron.settings['exceptionLevel'])
        # self.otherLevel = redRSpinBox(debug, label = 'General Print Level:', toolTip = _('Select the level of general logging that will be output to the general output'), min = 0, max = 9, value = redREnviron.settings['minSeverity'])
        
        exceptions = OWGUI.widgetBox(ExceptionsTab, _("Exceptions"))
        #self.catchExceptionCB = QCheckBox(_('Catch exceptions'), exceptions)
        self.focusOnCatchExceptionCB = OWGUI.checkBox(exceptions, self.settings, "focusOnCatchException", _('Show output window on exception'))
        # self.printExceptionInStatusBarCB = OWGUI.checkBox(exceptions, self.settings, "printExceptionInStatusBar", _('Print last exception in status bar'))
        self.printExceptionInStatusBarCB = OWGUI.checkBox(exceptions, self.settings, "uploadError", _('Submit Error Report'))
        self.printExceptionInStatusBarCB = OWGUI.checkBox(exceptions, self.settings, "askToUploadError", _('Always ask before submitting error report'))

        output = OWGUI.widgetBox(ExceptionsTab, _("Log File"))
        #self.catchOutputCB = QCheckBox(_('Catch system output'), output)
        self.writeLogFileCB  = OWGUI.checkBox(output, self.settings, "writeLogFile", 
        _("Save content of the Output window to a log file"))
        hbox = OWGUI.widgetBox(output, orientation = "horizontal")
        
        self.logFile = OWGUI.lineEdit(hbox, self.settings, "logFile", _("Log File:"), orientation = 'horizontal')
        self.okButton = OWGUI.button(hbox, self, _("Browse"), callback = self.browseLogFile)
        self.showOutputLog = redRbutton(output, label = _('Show Log File'), callback = self.showLogFile)
        self.numberOfDays = redRSpinBox(output, label = 'Keep File for X days:', min = -1, value = self.settings['keepForXDays'], callback = self.numberOfDaysChanged)
        
        # self.focusOnCatchOutputCB = OWGUI.checkBox(output, self.settings, "focusOnCatchOutput", _('Focus output window on system output'))
        # self.printOutputInStatusBarCB = OWGUI.checkBox(output, self.settings, "printOutputInStatusBar", _('Print last system output in status bar'))

        ExceptionsTab.layout().addStretch(1)

        #####################################
        # R Settings Tab
        self.rlibrariesBox = OWGUI.widgetBox(RSettings, _('R Libraries'))
        self.libInfo = redRwidgetLabel(self.rlibrariesBox, label='Repository URL: '+ self.settings['CRANrepos'])
        
        
        ################################ Global buttons  ######################
        # OK, Cancel buttons
        hbox = OWGUI.widgetBox(self, orientation = "horizontal", sizePolicy = QSizePolicy(QSizePolicy.Minimum, QSizePolicy.Fixed))
        hbox.layout().addStretch(1)
        self.okButton = OWGUI.button(hbox, self, _("OK"), callback = self.accept)
        self.cancelButton = OWGUI.button(hbox, self, _("Cancel"), callback = self.reject)
        #self.connect(self.tabOrderList, SIGNAL("currentRowChanged(int)"), self.enableDisableButtons)

        self.topLayout.addWidget(self.tabs)
        self.topLayout.addWidget(hbox)