def __init__(self, widget, html='', label=None, displayLabel=True, includeInReports=True, orientation='vertical', alignment=None, editable=True, printable=False, clearable=False, **args): widgetState.__init__(self, widget, label, includeInReports) QTextEdit.__init__(self, self.controlArea) self.label = label if displayLabel: self.hb = groupBox(self.controlArea, label=label, orientation=orientation) else: self.hb = widgetBox(self.controlArea, orientation=orientation) self.hb.layout().addWidget(self) if alignment: self.controlArea.layout().setAlignment(self.hb, alignment) if printable: button(self.hb, _("Print"), self.printMe) if clearable: button(self.hb, _("Clear"), callback=self.clear) if not editable: self.setReadOnly(True) self.setFontFamily('Courier') self.insertHtml(html)
def __init__(self, widget, label = _('Formula Entry'), displayLabel=True, includeInReports=True): # make a widgetBox to hold everything widgetState.__init__(self,widget,label,includeInReports) box = groupBox(self.controlArea,label=label) ## add the elements to the box #place the command keys self.buttonsBox = groupBox(box, label = _("Formula Commands")) self.plusButton = button(self.buttonsBox, _("And (+)"), callback = self.plusButtonClicked) self.plusButton.setEnabled(False) self.colonButton = button(self.buttonsBox, _("Interacting With (:)"), callback = self.colonButtonClicked) self.colonButton.setEnabled(False) self.starButton = button(self.buttonsBox, _("Together and Interacting (*)"), callback = self.starButtonClicked) self.starButton.setEnabled(False) button(self.buttonsBox, _('Clear'), self.clearFormula) self.elementsListBox = listBox(self.buttonsBox, label = _('Elements'), callback = self.FormulaEntryElementSelected) self.elementsListBox.setEnabled(True) # place the formula line edit self.modelBox = groupBox(box, label = _("Model Formula"), orientation = 'horizontal') self.extrasBox = widgetBox(self.modelBox) self.outcomeVariable = comboBox(self.modelBox, label = _('Outcome (f(x)):')) widgetLabel(self.modelBox, ' = ') self.modelLineEdit = lineEdit(self.modelBox, label = _('model'), displayLabel=False) self.label = label
def __init__(self, parent = None, layout = 'vertical', title = _('Line Type Dialog')): dialog.__init__(self, parent = parent, layout = layout, title = title) ## add a set of line types that can be shown in R and allow the user to pick them self.linesListBox = listBox(self, label = 'Line types:', items = ['________', '- - - -', '........', '_._._._.', '__ __ __', '__.__.__.'], callback = self.setLineTypes) self.linesListBox.setSelectionMode(QAbstractItemView.MultiSelection) button(self, _("Done"), callback = self.accept)
def __init__(self, parent = None, layout = 'vertical', title = _('Line Type Dialog')): dialog.__init__(self, parent = parent, layout = layout, title = title) ## add a set of line types that can be shown in R and allow the user to pick them self.linesListBox = listBox(self, label = 'Line types:', items = ['________', '- - - -', '........', '_._._._.', '__ __ __', '__.__.__.'], callback = self.setLineTypes) self.linesListBox.setSelectionMode(QAbstractItemView.MultiSelection) button(self, _("Done"), callback = self.accept)
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 __init__(self, parent=None, signalManager=None): OWRpy.__init__(self) self.outputs.addOutput('id0', _('R Session'), redRREnvironment) # print os.path.abspath('/') self.path = os.path.abspath('/') self.setRvariableNames(['sessionEnviron']) gbox = groupBox(self.controlArea, orientation='vertical', label=_('Select R session')) box = widgetBox(gbox, orientation='horizontal') self.filecombo = fileNamesComboBox(box, label=_('Session File'), displayLabel=False, orientation='vertical') self.filecombo.setSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.Maximum) button(box, label=_('Browse'), callback=self.browseFile) self.commit = commitButton(gbox, label=_('Load Session'), callback=self.loadSession, alignment=Qt.AlignRight) #gbox.layout().setAlignment(self.commit,Qt.AlignRight) self.infoa = widgetLabel(self.controlArea, '') self.varBox = listBox(self.controlArea, label=_('Variables')) self.varBox.hide() self.infob = widgetLabel(self.controlArea, '')
def __init__(self, widget, label = _('Formula Entry'), displayLabel=True, **kwargs): kwargs.setdefault('includeInReports', True) kwargs.setdefault('sizePolicy', QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred)) # make a widgetBox to hold everything widgetState.__init__(self,widget,label,**kwargs) box = groupBox(self.controlArea,label=label) ## add the elements to the box #place the command keys self.buttonsBox = groupBox(box, label = _("Formula Commands"), orientation = 'horizontal') self.plusButton = button(self.buttonsBox, _("And (+)"), callback = self.plusButtonClicked) self.plusButton.setEnabled(False) self.colonButton = button(self.buttonsBox, _("Interacting With (:)"), callback = self.colonButtonClicked) self.colonButton.setEnabled(False) self.starButton = button(self.buttonsBox, _("Together and Interacting (*)"), callback = self.starButtonClicked) self.starButton.setEnabled(False) button(self.buttonsBox, _('Clear'), self.clearFormula) self.elementsListBox = listBox(box, label = _('Elements'), callback = self.FormulaEntryElementSelected) self.elementsListBox.setEnabled(True) # place the formula line edit self.modelBox = groupBox(box, label = _("Model Formula"), orientation = 'horizontal') self.extrasBox = widgetBox(self.modelBox) self.outcomeVariable = comboBox(self.modelBox, label = _('Outcome (f(x)):')) widgetLabel(self.modelBox, ' = ') self.modelLineEdit = lineEdit(self.modelBox, label = _('model'), displayLabel=False) self.label = label
def __init__(self, parent=None, signalManager=None): OWRpy.__init__(self) self.setRvariableNames(["eigen"]) self.data = {} self.RFunctionParam_x = '' self.inputs.addInput('id0', _('Input Data'), redRRMatrix, self.processx) self.outputs.addOutput('id0', _('Eigen Output'), redRRList) self.RFunctionParamsymmetric_radioButtons = radioButtons( self.controlArea, label=_("symmetric:"), buttons=[_('Yes'), _('No')], setChecked=_('Yes')) self.RFunctionParamonly_values_radioButtons = radioButtons( self.controlArea, label=_("only_values:"), buttons=[_('Yes'), _('No')], setChecked=_('Yes')) self.RFunctionParamEISPACK_radioButtons = radioButtons( self.controlArea, label=_("EISPACK:"), buttons=[_('Yes'), _('No')], setChecked=_('Yes')) button(self.bottomAreaRight, _("Commit"), callback=self.commitFunction)
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)
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)
def __init__(self, parent=None, signalManager=None): OWRpy.__init__(self, wantGUIDialog = 1) self.rowCount = 10 self.colCount = 10 self.maxRow = 0 # sets the most extreme row and cols self.maxCol = 0 self.classes = None self.savedData = None self.setRvariableNames(['table', 'table_cm']) self.inputs.addInput('Data Table', 'Data Table', redRRDataFrame, self.processDF) self.outputs.addOutput('Data Table', 'Data Table', redRRDataFrame) # trace problem with outputs #GUI. box = groupBox(self.GUIDialog, label = "Options") redRCommitButton(self.bottomAreaRight, 'Commit', self.commitTable) self.rowHeaders = checkBox(box, label= 'Table Annotations', buttons=['Use Row Headers', 'Use Column Headers']) #self.colHeaders = checkBox(box, label=None, buttons=['Use Column Headers']) self.rowHeaders.setChecked(['Use Row Headers', 'Use Column Headers']) #self.colHeaders.setChecked(['Use Column Headers']) self.customClasses = button(box, 'Use Custom Column Classes', callback = self.setCustomClasses) button(box, 'Clear Classes', callback = self.clearClasses) self.columnDialog = QDialog() self.columnDialog.setLayout(QVBoxLayout()) self.columnDialog.hide() self.columnNameLineEdit = lineEdit(self.columnDialog, label = 'Column Name:') button(self.columnDialog, 'Commit', callback = self.commitNewColumn) #button(self.bottomAreaRight, "Add Column", callback = self.addColumn) #button(self.bottomAreaRight, "Add Row", callback = self.addRow) box = groupBox(self.controlArea, label = "Table", sizePolicy = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred)) #self.splitCanvas.addWidget(box) #self.R(self.Rvariables['table'] + '<- matrix("",nrow=10,ncol=10)', wantType = 'NoConversion') self.dataTable = table(box, label = 'Data Table', rows = 10, columns = 10) # if self.dataTable.columnCount() < 1: # self.dataTable.setColumnCount(1) # self.dataTable.setHorizontalHeaderLabels(['Rownames']) # if self.dataTable.rowCount() < 1: # self.dataTable.setRowCount(1) # self.dataTable.setHorizontalHeaderLabels(['Rownames']) self.connect(self.dataTable, SIGNAL("cellClicked(int, int)"), self.cellClicked) # works OK self.connect(self.dataTable, SIGNAL("cellChanged(int, int)"), self.itemChanged) self.window = QDialog(self) self.window.setLayout(QVBoxLayout()) self.classTable = table(self.window, label = 'Data Table', rows = self.maxCol, columns = 2) self.resize(700,500) self.move(300, 25)
def __init__(self, parent = None, layout = 'vertical', title = 'Color List Dialog', data = ''): QDialog.__init__(self, parent) self.setWindowTitle(title) if layout == 'horizontal': self.setLayout(QHBoxLayout()) else: self.setLayout(QVBoxLayout()) self.listOfColors = [] self.controlArea = widgetBox(self) mainArea = widgetBox(self.controlArea, 'horizontal') leftBox = widgetBox(mainArea) rightBox = widgetBox(mainArea) ## GUI # color list self.colorList = listBox(leftBox, label = 'Color List') button(leftBox, label = 'Add Color', callback = self.addColor) button(leftBox, label = 'Remove Color', callback = self.removeColor) button(leftBox, label = 'Clear Colors', callback = self.colorList.clear) button(mainArea, label = 'Finished', callback = self.accept) # attribute list self.attsList = listBox(rightBox, label = 'Data Parameters', callback = self.attsListSelected) if data: names = self.R('names('+data+')') print names self.attsList.update(names) self.data = data
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)
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)
def __init__(self, parent = None, layout = 'vertical', title = 'Color List Dialog', data = ''): QDialog.__init__(self, parent) self.setWindowTitle(title) if layout == 'horizontal': self.setLayout(QHBoxLayout()) else: self.setLayout(QVBoxLayout()) self.listOfColors = [] self.controlArea = widgetBox(self) mainArea = widgetBox(self.controlArea, 'horizontal') leftBox = widgetBox(mainArea) rightBox = widgetBox(mainArea) ## GUI # color list self.colorList = listBox(leftBox, label = 'Color List') button(leftBox, label = 'Add Color', callback = self.addColor) button(leftBox, label = 'Remove Color', callback = self.removeColor) button(leftBox, label = 'Clear Colors', callback = self.colorList.clear) button(mainArea, label = 'Finished', callback = self.accept) # attribute list self.attsList = listBox(rightBox, label = 'Data Parameters', callback = self.attsListSelected) if data: names = self.R('names('+data+')') print names self.attsList.update(names) self.data = data
def headerClicked(self, index): globalPos = QCursor.pos() #self.mapToGlobal(pos) self.menu = QDialog(None,Qt.Popup) self.menu.setLayout(QVBoxLayout()) box = widgetBox(self.menu, orientation = 'horizontal') name = lineEdit(box, label = _('New Name (Overrides Current Value)'), callback = self.menu.accept) equation = lineEdit(box, label = _('Equation (Overrides Current Values)'), callback = self.menu.accept) remove = button(box, label = _('Remove Column'), callback = lambda: self.removeColumn(index)) done = button(box, label = _('Done'), callback = self.menu.accept) res = self.menu.exec_() if res == Qt.Accept: if unicode(equation.text()) != '': self.calculateEquation(current = index, equation = unicode(equation.text())) if unicode(name.text()) != '': self.resetName(current = index, new = unicode(name.text()))
def headerClicked(self, index): globalPos = QCursor.pos() #self.mapToGlobal(pos) self.menu = QDialog(None,Qt.Popup) self.menu.setLayout(QVBoxLayout()) box = widgetBox(self.menu, orientation = 'horizontal') name = lineEdit(box, label = _('New Name (Overrides Current Value)'), callback = self.menu.accept) equation = lineEdit(box, label = _('Equation (Overrides Current Values)'), callback = self.menu.accept) remove = button(box, label = _('Remove Column'), callback = lambda: self.removeColumn(index)) done = button(box, label = _('Done'), callback = self.menu.accept) res = self.menu.exec_() if res == Qt.Accept: if unicode(equation.text()) != '': self.calculateEquation(current = , equation = unicode(equation.text())) if unicode(name.text()) != '': self.resetName(current = , new = unicode(name.text()))
def __init__(self, parent=None, signalManager=None): OWRpy.__init__(self, wantGUIDialog = 1) self.rowCount = 1 self.colCount = 1 self.maxRow = 0 # sets the most extreme row and cols self.maxCol = 0 self.classes = None self.savedData = None self.setRvariableNames(['table', 'table_cm']) self.inputs.addInput('Data Table', 'Data Table', redRRDataFrame, self.processDF) self.outputs.addOutput('Data Table', 'Data Table', redRRDataFrame) # trace problem with outputs #GUI. box = groupBox(self.GUIDialog, label = "Options") redRCommitButton(self.bottomAreaRight, 'Commit', self.commitTable) self.rowHeaders = checkBox(box, label= 'Table Annotations', buttons=['Use Row Headers', 'Use Column Headers']) #self.colHeaders = checkBox(box, label=None, buttons=['Use Column Headers']) self.rowHeaders.setChecked(['Use Row Headers', 'Use Column Headers']) #self.colHeaders.setChecked(['Use Column Headers']) self.customClasses = button(box, 'Use Custom Column Classes', callback = self.setCustomClasses) button(box, 'Clear Classes', callback = self.clearClasses) self.columnDialog = QDialog() self.columnDialog.setLayout(QVBoxLayout()) self.columnDialog.hide() self.columnNameLineEdit = lineEdit(self.columnDialog, label = 'Column Name:') button(self.columnDialog, 'Commit', callback = self.commitNewColumn) button(self.bottomAreaRight, "Add Column", callback = self.addColumn) button(self.bottomAreaRight, "Add Row", callback = self.addRow) box = groupBox(self.controlArea, label = "Table", sizePolicy = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred)) #self.splitCanvas.addWidget(box) #self.R(self.Rvariables['table'] + '<- matrix("",nrow=10,ncol=10)', wantType = 'NoConversion') self.dataTable = table(box, label = 'Data Table', rows = 10, columns = 10) # if self.dataTable.columnCount() < 1: # self.dataTable.setColumnCount(1) # self.dataTable.setHorizontalHeaderLabels(['Rownames']) # if self.dataTable.rowCount() < 1: # self.dataTable.setRowCount(1) # self.dataTable.setHorizontalHeaderLabels(['Rownames']) self.connect(self.dataTable, SIGNAL("cellClicked(int, int)"), self.cellClicked) # works OK self.connect(self.dataTable, SIGNAL("cellChanged(int, int)"), self.itemChanged) self.window = QDialog(self) self.window.setLayout(QVBoxLayout()) self.classTable = table(self.window, label = 'Data Table', rows = self.maxCol, columns = 2) self.resize(700,500) self.move(300, 25)
def setCustomClasses(self): self.classTable = table(self.window, rows = self.maxCol, columns = 2) for j in range(1, self.colCount+1): cb = QComboBox() item = self.dataTable.item(0, j) if item == None: newitem = QTableWidgetItem(unicode('NA')) else: newitem = QTableWidgetItem(unicode(item.text())) cb.addItems(['Default', 'Factor', 'Numeric', 'Character']) self.classTable.setCellWidget(j-1, 1, cb) newitem.setToolTip(unicode('Set the data type for column '+unicode(newitem.text()))) self.classTable.setItem(j-1, 0, newitem) button(self.window, 'Set Classes', callback = self.setClasses) button(self.window, 'Clear Classes', callback = self.clearClasses) self.window.show()
def setCustomClasses(self): self.classTable = table(self.window, rows = self.maxCol, columns = 2) for j in range(1, self.colCount+1): cb = QComboBox() item = self.dataTable.item(0, j) if item == None: newitem = QTableWidgetItem(unicode('NA')) else: newitem = QTableWidgetItem(unicode(item.text())) cb.addItems(['Default', 'Factor', 'Numeric', 'Character']) self.classTable.setCellWidget(j-1, 1, cb) newitem.setToolTip(unicode('Set the data type for column '+unicode(newitem.text()))) self.classTable.setItem(j-1, 0, newitem) button(self.window, 'Set Classes', callback = self.setClasses) button(self.window, 'Clear Classes', callback = self.clearClasses) self.window.show()
def __init__(self, parent=None, signalManager=None): #must initalize the parent OWRpy class OWRpy.__init__(self) ### GUI ### #create input line self.lineEdit = lineEdit(self.controlArea, label = 'Line Edit') #create submit button self.button = button(self.controlArea,label='submit',callback=self.process) #create output area self.output = textEdit(self.controlArea,label='Output')
def __init__(self, parent=None, signalManager=None): OWRpy.__init__(self) self.rowCount = 1 self.colCount = 1 self.maxRow = 0 # sets the most extreme row and cols self.maxCol = 0 self.classes = None self.savedData = None self.setRvariableNames(['table', 'table_cm']) self.inputs.addInput('id0', _('Data Table'), redRRDataFrame, self.processDF) self.outputs.addOutput('id0', _('Data Table'), redRRDataFrame) #GUI. redRCommitButton(self.bottomAreaRight, _('Commit'), self.commitTable) self.columnDialog = QDialog(self) self.columnDialog.setLayout(QVBoxLayout()) self.columnDialog.hide() self.columnNameLineEdit = lineEdit(self.columnDialog, label = _('Column Name:')) button(self.columnDialog, _('Commit'), callback = self.commitNewColumn) button(self.bottomAreaRight, _("Add Column"), callback = self.columnDialog.show) box = groupBox(self.controlArea, label = _("Table"), sizePolicy = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred)) #self.splitCanvas.addWidget(box) self.dataTable = pyDataTable(box,label=_('Data Entry'),displayLabel=False, data = None) self.connect(self.dataTable, SIGNAL("cellClicked(int, int)"), self.cellClicked) # works OK self.connect(self.dataTable, SIGNAL("cellChanged(int, int)"), self.itemChanged) self.connect(self.dataTable, SIGNAL('sectionClicked (int)'), self.headerClicked) self.resize(700,500) self.move(300, 25)
def __init__(self, **kwargs): OWRpy.__init__(self, **kwargs) self.rowCount = 1 self.colCount = 1 self.maxRow = 0 # sets the most extreme row and cols self.maxCol = 0 self.classes = None self.savedData = None self.setRvariableNames(['table', 'table_cm']) self.inputs.addInput('id0', _('Data Table'), UnstructuredDict, self.processDF) self.outputs.addOutput('id0', _('Data Table'), UnstructuredDict) #GUI. redRCommitButton(self.bottomAreaRight, _('Commit'), self.commitTable) self.columnDialog = QDialog(self) self.columnDialog.setLayout(QVBoxLayout()) self.columnDialog.hide() self.columnNameLineEdit = lineEdit(self.columnDialog, label = _('Column Name:')) button(self.columnDialog, _('Commit'), callback = self.commitNewColumn) button(self.bottomAreaRight, _("Add Column"), callback = self.columnDialog.show) box = groupBox(self.controlArea, label = _("Table"), sizePolicy = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred)) #self.splitCanvas.addWidget(box) self.dataTable = pyDataTable(box,label=_('Data Entry'),displayLabel=False, data = None) self.connect(self.dataTable, SIGNAL("cellClicked(int, int)"), self.cellClicked) # works OK self.connect(self.dataTable, SIGNAL("cellChanged(int, int)"), self.itemChanged) self.connect(self.dataTable, SIGNAL('sectionClicked (int)'), self.headerClicked) self.resize(700,500) self.move(300, 25)
def __init__(self,widget,html='',label=None, displayLabel=True, orientation='vertical', alignment=None, editable=True, printable=False,clearable=False,**kwargs): kwargs.setdefault('includeInReports', True) kwargs.setdefault('sizePolicy', QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)) widgetState.__init__(self,widget, label,**kwargs) QTextEdit.__init__(self,self.controlArea) self.label = label if displayLabel: self.hb = groupBox(self.controlArea,label=label,orientation=orientation) else: self.hb = widgetBox(self.controlArea,orientation=orientation) self.hb.layout().addWidget(self) if alignment: self.controlArea.layout().setAlignment(self.hb,alignment) if printable: button(self.hb, _("Print"), self.printMe) if clearable: button(self.hb, _("Clear"), callback = self.clear) if not editable: self.setReadOnly(True) self.setFontFamily('Courier') self.insertHtml(html)
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)
def __init__(self, parent=None, signalManager=None): OWRpy.__init__(self) #initialize the widget self.dataClass = None self.dataParent = None self.setRvariableNames(['rowcolSelector', 'rowcolSelectorNot']) self.SubsetByAttached = 0 self.inputs.addInput('id0', _('Data Table'), redRRDataFrame, self.setWidget) self.inputs.addInput('id1', _('Subsetting Vector'), redRRList, self.setSubsettingVector) self.outputs.addOutput('id0', _('Selected Items'), redRRDataFrame) self.outputs.addOutput('id1', _('Non-selected Items'), redRRDataFrame) #set the gui area = widgetBox(self.controlArea, orientation='horizontal') options = widgetBox(area, orientation='vertical') self.rowcolBox = radioButtons(options, label=_('Select On'), buttons=[_('Column'), _('Row')], setChecked=_('Column'), callback=self.rowcolButtonSelected, orientation='horizontal') self.sendSection = checkBox(options, label=_('Create subset from:'), displayLabel=True, buttons=[_('Selected'), _('Not Selected')], setChecked=[_('Selected')], orientation='horizontal') # toolTips = [_("Select True to send data from the Data slot where the selections that you made are True."), # _("Select False to send data from the Not Data slot that are not the selections you made.")]) self.invertButton = button(options, _("Invert Selection"), callback=self.invertSelection) separator(options, height=15) self.subsetBox = groupBox(options, label=_('Subset by')) self.subsetColumn = comboBox(self.subsetBox, label=_("Column:"), orientation='vertical', items=[_('Select')]) self.subOnAttachedButton = button(self.subsetBox, _("Subset by column"), callback=self.subOnAttached) self.subsetBox.setDisabled(True) separator(options, height=20) info = widgetBox(options) options.layout().setAlignment(info, Qt.AlignBottom) self.infoBox = widgetLabel(info) separator(info, height=15) self.selectionInfoBox = widgetLabel(info) mainArea = widgetBox(area, orientation='vertical') self.attributes = listBox(mainArea, label=_('Select'), callback=self.onSelect) self.attributes.setSelectionMode(QAbstractItemView.ExtendedSelection) self.subsetButton = commitButton(mainArea, _("Subset on Selection"), callback=self.subset, processOnChange=True, processOnInput=True, alignment=Qt.AlignRight)
def __init__(self, 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)
def __init__(self, widget, label=None, displayLabel=True, includeInReports=True, Rdata=None, editable=False, sortable=True, filterable=False, selectionBehavior=QAbstractItemView.SelectRows, selectionMode=QAbstractItemView.ExtendedSelection, showResizeButtons=True, onFilterCallback=None, callback=None, selectionCallback=None): widgetState.__init__(self, widget, label, includeInReports) if displayLabel: mainBox = groupBox(self.controlArea, label=label, orientation='vertical') else: mainBox = widgetBox(self.controlArea, orientation='vertical') self.label = label QTableView.__init__(self, self.controlArea) mainBox.layout().addWidget(self) box = widgetBox(mainBox, orientation='horizontal') leftBox = widgetBox(box, orientation='horizontal') if filterable: self.clearButton = button(leftBox, label=_('Clear All Filtering'), callback=self.clearFiltering) self.dataInfo = widgetLabel(leftBox, label='', wordWrap=False) box.layout().setAlignment(leftBox, Qt.AlignLeft) if showResizeButtons: resizeColsBox = widgetBox(box, orientation="horizontal") resizeColsBox.layout().setAlignment(Qt.AlignRight) box.layout().setAlignment(resizeColsBox, Qt.AlignRight) widgetLabel(resizeColsBox, label=_("Resize columns: ")) button(resizeColsBox, label="+", callback=self.increaseColWidth, toolTip=_("Increase the width of the columns"), width=30) button(resizeColsBox, label="-", callback=self.decreaseColWidth, toolTip=_("Decrease the width of the columns"), width=30) button(resizeColsBox, label=_("Resize To Content"), callback=self.resizeColumnsToContents, toolTip=_("Set width based on content size")) self.R = Rcommand self.Rdata = None self.filteredData = None self.sortIndex = None self.criteriaList = {} self.parent = widget self.tm = None self.sortable = sortable self.editable = editable self.filterable = filterable self.onFilterCallback = onFilterCallback self.selectionCallback = selectionCallback self.selections = QItemSelection() self.working = False self.setHorizontalHeader(myHeaderView(self)) self.setSelectionBehavior(selectionBehavior) self.setAlternatingRowColors(True) if selectionMode != -1: self.setSelectionMode(selectionMode) if Rdata: self.setRTable(Rdata) if editable: self.horizontalHeader().hide() self.verticalHeader().hide() # if sortable: # self.horizontalHeader().setSortIndicatorShown(True) # self.horizontalHeader().setSortIndicator(-1,0) if filterable or sortable: self.horizontalHeader().setClickable(True) # QObject.connect(self.horizontalHeader(), SIGNAL('sectionClicked (int)'), self.selectColumn) self.horizontalHeader().setContextMenuPolicy(Qt.CustomContextMenu) self.horizontalHeader().customContextMenuRequested.connect( self.headerClicked) if callback: QObject.connect(self, SIGNAL('clicked (QModelIndex)'), callback)
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()
def createMenu(self, selectedCol): #print selectedCol, pos # print _('in createMenu'), self.criteriaList globalPos = QCursor.pos() #self.mapToGlobal(pos) self.menu = QDialog(None, Qt.Popup) self.menu.setLayout(QVBoxLayout()) if self.sortable: box = widgetBox(self.menu, orientation='horizontal') box.layout().setAlignment(Qt.AlignLeft) button(box, label='A->Z', callback=lambda: self.sort(selectedCol, Qt.AscendingOrder)) widgetLabel(box, label=_('Ascending Sort')) box = widgetBox(self.menu, orientation='horizontal') box.layout().setAlignment(Qt.AlignLeft) button(box, label='Z->A', callback=lambda: self.sort(selectedCol, Qt.DescendingOrder)) widgetLabel(box, label=_('Descending Sort')) # qmenu = QMenu(self.menu) # self.menu.layout().addWidget(qmenu) # a = QAction('A->Z',self.menu) # qmenu.addAction(a) # self.menu.addAction(a) if not self.filterable: self.menu.move(globalPos) self.menu.show() return if self.sortable: hr = QFrame(self.menu) hr.setFrameStyle(QFrame.Sunken + QFrame.HLine) hr.setFixedHeight(12) self.menu.layout().addWidget(hr) clearButton = button( self.menu, label=_('Clear Filter'), callback=lambda col=selectedCol: self.createCriteriaList( col, self.menu, action='clear')) self.menu.layout().setAlignment(clearButton, Qt.AlignHCenter) clearButton.hide() self.numericLabel = widgetLabel( self.menu, label=_('Enter a value for one of these critera:')) self.numericLabel.hide() self.stringLabel = widgetLabel( self.menu, label=_( 'Enter a value for one of these critera (case sensitive):')) self.stringLabel.hide() self.factorLabel = widgetLabel(self.menu, label=_('Select Levels:')) self.factorLabel.hide() if selectedCol in self.criteriaList.keys(): clearButton.show() self.optionsBox = widgetBox(self.menu) self.optionsBox.layout().setAlignment(Qt.AlignTop) colClass = self.R('class(%s[,%d])' % (self.Rdata, selectedCol), silent=True) if colClass in ['factor', 'logical']: self.factorLabel.show() if selectedCol in self.criteriaList.keys(): checked = self.criteriaList[selectedCol]['value'] else: checked = [] if colClass == 'logical': levels = ['TRUE', 'FALSE'] else: levels = self.R('levels(%s[,%d])' % (self.Rdata, selectedCol), wantType='list', silent=True) if len(levels) > 1: levels.insert(0, _('Check All')) scroll = scrollArea(self.optionsBox, spacing=1) c = checkBox(scroll, label=_('Levels'), displayLabel=False, buttons=levels, setChecked=checked) scroll.setWidget(c.controlArea) QObject.connect( c.buttons, SIGNAL('buttonClicked (int)'), lambda val: self.factorCheckBox(val, self.optionsBox)) elif colClass in ['integer', 'numeric']: self.numericLabel.show() self.options = [ _('Equals'), _('Does Not Equal'), _('Greater Than'), _('Greater Than Or Equal To'), _('Less Than'), _('Less Than or Equal To'), 'Between\n(2 numbers comma\nseparated, inclusive)', 'Not Between\n(2 numbers comma\nseparated)' ] for x in self.options: if selectedCol in self.criteriaList and self.criteriaList[ selectedCol]['method'] == _('Numeric ') + x: e = lineEdit(self.optionsBox, label=x, text=self.criteriaList[selectedCol]['value']) else: e = lineEdit(self.optionsBox, label=x) self.connect(e, SIGNAL("textEdited(QString)"), lambda val, col=selectedCol, field=x: self. clearOthers(val, self.optionsBox, field)) elif colClass in ['character']: self.stringLabel.show() self.options = [ _('Equals'), _('Does Not Equal'), _('Begins With'), _('Ends With'), _('Contains'), _('Does Not Contain') ] for x in self.options: if selectedCol in self.criteriaList and self.criteriaList[ selectedCol]['method'] == _('String ') + x: e = lineEdit(self.optionsBox, label=x, text=self.criteriaList[selectedCol]['value']) else: e = lineEdit(self.optionsBox, label=x) self.connect(e, SIGNAL("textEdited(QString)"), lambda val, col=selectedCol, field=x: self. clearOthers(val, self.optionsBox, field)) buttonBox = widgetBox(self.optionsBox, orientation='horizontal') buttonBox.layout().setAlignment(Qt.AlignRight) okButton = button( buttonBox, label=_('OK'), callback=lambda col=selectedCol: self.createCriteriaList( col, self.optionsBox, action=_('OK'))) okButton.setDefault(True) button(buttonBox, label=_('Cancel'), callback=lambda col=selectedCol: self.createCriteriaList( col, self.optionsBox, action='cancel')) self.menu.move(globalPos) self.menu.show()
def setSettings(self,settings, globalSettings = False): redRLog.log(redRLog.REDRCORE, redRLog.DEBUG, 'Loading settings') #settings = self.sqlite.setObject(settingsID) # import pprint # pp = pprint.PrettyPrinter(indent=4) # pp.pprint(settings) for k,v in settings.iteritems(): try: #redRLog.log(redRLog.REDRCORE, redRLog.ERROR, 'Loading %s' % k) if k in ['inputs', 'outputs']: continue if v == None: continue elif 'pythonObject' in v.keys(): #print '|#| Setting pythonObject %s to %s' % (k,unicode(v['pythonObject'])) self.__setattr__(k, v['pythonObject']) elif 'signalsObject' in v.keys(): #print '|#| Setting signalsObject' varClass = self.setSignalClass(v['signalsObject']) self.__setattr__(k, varClass) elif 'sentItemsList' in v.keys(): #print '|#| settingItemsList' # print v['sentItemsList'] #self.setSentItemsList(v['sentItemsList']) for (sentItemName, sentItemDict) in v['sentItemsList']: #print '|#| setting sent items %s to %s' % (sentItemName, unicode(sentItemDict)) #for kk,vv in sentItemDict.items(): var = self.setSignalClass(sentItemDict) ## add compatibility layer for the case that the sent item name is not longer in existance or has changed if sentItemName in self.outputs.outputIDs(): self.send(sentItemName, var) else: signalItemNames = [name for (key, name) in self.outputs.outputNames().items()] if sentItemName in signalItemNames: signalID = self.outputs.getSignalByName(sentItemName) self.send(signalID, var) else: #print 'Error in matching item name' from libraries.base.qtWidgets.dialog import dialog tempDialog = dialog(None) from libraries.base.qtWidgets.widgetLabel import widgetLabel from libraries.base.qtWidgets.listBox import listBox from libraries.base.qtWidgets.button import button widgetLabel(tempDialog, 'Error occured in matching the loaded signal (Name:%s, Value:%s) to the appropriate signal name.\nPlease select the signal that matches the desired output,\n or press cancel to abandon the signal.' % (sentItemName, unicode(var))) #print self.outputs.outputSignals itemListBox = listBox(tempDialog, items = signalItemNames) button(tempDialog, label = 'Done', callback = tempDialog.accept) button(tempDialog, label = 'Cancel', callback = tempDialog.reject) res = tempDialog.exec_() if res != QDialog.rejected: signalName = unicode(itemListBox.selectedItems()[0].text()) signalID = self.outputs.getSignalByName(signalName) self.send(signalID, var) ############################################# elif not hasattr(self,k): continue elif 'redRGUIObject' in v.keys(): #print getattr(self, k) try: getattr(self, k).loadSettings(v['redRGUIObject']) getattr(self, k).setDefaultState(v['redRGUIObject']) except Exception as inst: #print 'Exception occured during loading of settings. These settings may not be the same as when the widget was closed.' redRLog.log(redRLog.REDRCORE, redRLog.ERROR,redRLog.formatException()) elif 'dict' in v.keys(): var = getattr(self, k) #print 'dict',len(var),len(v['dict']) if len(var) != len(v['dict']): continue self.recursiveSetSetting(var,v['dict']) elif 'list' in v.keys(): var = getattr(self, k) # print 'list',len(var),len(v['list']) if len(var) != len(v['list']): continue self.recursiveSetSetting(var,v['list']) except: redRLog.log(redRLog.REDRCORE, redRLog.ERROR, 'Exception occured during loading. The Error will be ignored.') redRLog.log(redRLog.REDRCORE, redRLog.DEBUG, redRLog.formatException())
def __init__(self, parent=None, signalManager=None): #OWWidget.__init__(self, parent, signalManager, "Sample Data") OWRpy.__init__(self, wantGUIDialog=1) self.command = '' self.sendthis = '' self.sendt = {} self.dfselected = None self.setRvariableNames(['rExecutor', 'rExecutor_cm']) self.inputs.addInput('id0', _('R.object'), redRRVariable, self.process) self.outputs.addOutput('id0', _('R Data Frame'), redRRDataFrame) self.outputs.addOutput('id1', _('R List'), redRRList) self.outputs.addOutput('id2', _('R Vector'), redRRVector) self.outputs.addOutput('id3', _('R.object'), 'All') self.outputs.addOutput('id4', _('R Matrix'), redRRMatrix) #self.breakme() #self.help.setHtml('The R Executor widget provides direct access to the R session that runs under RedR. R Executor can recieve any output from an R compatible widget. The recieved data can be shown using the Recieved button. The R history can be shown by pressing the RHistory button and the complete parsing of any recieved data is shown in the Metadata section. More infromation is available on the <a href="http://www.red-r.org/?cat=10">RedR website</a>.') #GUI #GUIDialog self.box = groupBox(self.GUIDialog, _("R Executor Advanced")) self.infob = widgetLabel(self.box, "") self.infoa = widgetLabel(self.box, "") # grid area = widgetBox(self.controlArea, orientation='horizontal') area.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) leftArea = widgetBox(self.box) leftArea.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Expanding) rightArea = widgetBox(area) runbox = groupBox(rightArea, label=_("Command Edit:"), orientation='horizontal') runbox.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Maximum) #self.command = lineEdit(runbox, "", orientation=QHBoxLayout(), callback = self.runR, width = -1) self.command = textEdit(runbox, label=_('Command Edit:')) #self.command.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) processbutton = button(runbox, label=_("&Run"), callback=self.runR, width=100) statusBox = groupBox(rightArea, label=_("Status")) self.sendStatus = widgetLabel(statusBox, _('Nothing Sent')) self.dataBox = groupBox(leftArea, label=_("Input Infromation")) self.mystatus = widgetLabel(self.dataBox, _("No Input")) # self.metadataBox = widgetBox(leftArea, _("Metadata")) # self.infoM = widgetLabel(self.metadataBox, _("No Meta Data")) # self.metadataLB = listBox(self.metadataBox, callback = self.insertMetaDataVar) varbutton = button(leftArea, _("Recieved"), callback=self.putrecieved, width=150) history = button(leftArea, _("RHistory"), callback=self.putRHistory, width=150) button(leftArea, _("Clear Output"), callback=self.clearOutput) self.lsList = listBox(self.box, label=_('Available R Items'), items=self.R('ls()', wantType='list'), callback=self.addlsList) button(self.box, 'Refresh List', callback=self.refreshLsList) self.thistext = textEdit(rightArea, label=_('Output'), displayLabel=False) sendbutton = button( runbox, label=_("&Send"), toolTip=_( 'Send the data in the command line into the Red-R schema.'), callback=self.sendThis, width=100)
def __init__(self, parent=None, signalManager=None): OWRpy.__init__(self) self.setRvariableNames(['heatsubset', 'hclust', 'heatvect']) self.plotOnConnect = 0 self.plotdata = '' self.rowvChoice = None self.colvChoice = None self.listOfColors = ['"red"', '"white"', '"blue"'] self.inputs.addInput('id0', 'Expression Matrix', redRRDataFrame, self.processMatrix) self.inputs.addInput('id1', 'Classes Data', redRRVector, self.processClasses) #self.outputs.addOutput('id0', 'Cluster Subset List', redRRVector) self.outputs.addOutput('id1', 'Cluster Classes', redRRVector) #GUI infobox = groupBox(self.controlArea, label="Options") self.commit = redRCommitButton(self.bottomAreaRight, label="Replot", callback=self.makePlot, width=200, processOnInput=True) button(infobox, label='Identify', callback=self.identify, width=200) self.groupOrHeight = radioButtons(infobox, label='Identify by:', buttons=['Groups', 'Height'], setChecked='Groups', orientation='horizontal') self.groupOrHeightSpin = spinBox(infobox, label='Identify Value:', min=1, value=5) self.startSaturation = spinBox(infobox, label='Starting Saturation:', min=0, max=100) self.endSaturation = spinBox(infobox, label='Ending Saturation:', min=0, max=100) self.endSaturation.setValue(30) redRButton(self.controlArea, label='Reset Colors', callback=self.resetColors) #self.classesDropdown = comboBox(infobox, label = 'Classes:', toolTip = 'If classes data is connected you may select columns in the data to represent classes of your columns in the plotted data') self.rowDendrogram = checkBox( infobox, label='Dendrogram Options', displayLabel=False, buttons=['Plot Row Dendrogram', 'Plot Column Dendrogram'], setChecked=['Plot Row Dendrogram', 'Plot Column Dendrogram']) self.showClasses = checkBox(infobox, label='Show Classes', displayLabel=False, buttons=['Show Classes']) self.showClasses.setEnabled(False) #OWGUI.checkBox(infobox, self, ) self.infoa = widgetLabel(infobox, label="Nothing to report") self.gview1 = graphicsView(self.controlArea, label='Heatmap', displayLabel=False) self.gview1.image = 'heatmap1_' + self.widgetID
def createMenu(self, selectedCol): ''' self.tm.createMenu(selectedCol, sortable = self.sortable, filterable = self.filterable ''' #print selectedCol, pos # print _('in createMenu'), self.criteriaList if not self.sortable and not self.filterable: return globalPos = QCursor.pos() #self.mapToGlobal(pos) self.menu = QDialog(None,Qt.Popup) self.menu.setLayout(QVBoxLayout()) if self.sortable: box = widgetBox(self.menu,orientation='horizontal') box.layout().setAlignment(Qt.AlignLeft) button(box,label='A->Z',callback= lambda: self.sort(selectedCol,Qt.AscendingOrder)) widgetLabel(box,label=_('Ascending Sort')) box = widgetBox(self.menu,orientation='horizontal') box.layout().setAlignment(Qt.AlignLeft) button(box,label='Z->A',callback= lambda: self.sort(selectedCol,Qt.DescendingOrder)) widgetLabel(box,label=_('Descending Sort')) if not self.filterable: self.menu.move(globalPos) self.menu.show() return if self.sortable: hr = QFrame(self.menu) hr.setFrameStyle( QFrame.Sunken + QFrame.HLine ); hr.setFixedHeight( 12 ); self.menu.layout().addWidget(hr) clearButton = button(self.menu,label=_('Clear Filter'), callback=lambda col=selectedCol: self.createCriteriaList(col,self.menu,action='clear')) self.menu.layout().setAlignment(clearButton,Qt.AlignHCenter) clearButton.hide() self.numericLabel = widgetLabel(self.menu,label=_('Enter a value for one of these critera:')) self.numericLabel.hide() self.stringLabel = widgetLabel(self.menu,label=_('Enter a value for one of these critera (case sensitive):')) self.stringLabel.hide() self.factorLabel = widgetLabel(self.menu,label=_('Select Levels:')) self.factorLabel.hide() if selectedCol in self.criteriaList.keys(): clearButton.show() self.optionsBox = widgetBox(self.menu) self.optionsBox.layout().setAlignment(Qt.AlignTop) #### Logic if R variable ### #if self.varType == 0: colClass = self.R('class(%s[,%d])' % (self.Rdata,selectedCol),silent=True) if colClass in ['factor','logical']: self.factorLabel.show() if selectedCol in self.criteriaList.keys(): checked = self.criteriaList[selectedCol]['value'] else: checked = [] if colClass =='logical': levels = ['TRUE','FALSE'] else: levels = self.R('levels(%s[,%d])' % (self.Rdata,selectedCol),wantType='list', silent=True) if len(levels) > 1: levels.insert(0,_('Check All')) scroll = scrollArea(self.optionsBox,spacing=1) c = checkBox(scroll,label=_('Levels'),displayLabel=False, buttons=levels,setChecked = checked) scroll.setWidget(c.controlArea) QObject.connect(c.buttons, SIGNAL('buttonClicked (int)'), lambda val : self.factorCheckBox(val,self.optionsBox)) elif colClass in ['integer','numeric']: self.numericLabel.show() self.options = [_('Equals'), _('Does Not Equal'),_('Greater Than'),_('Greater Than Or Equal To'), _('Less Than'), _('Less Than or Equal To'), 'Between\n(2 numbers comma\nseparated, inclusive)', 'Not Between\n(2 numbers comma\nseparated)'] for x in self.options: if selectedCol in self.criteriaList and self.criteriaList[selectedCol]['method'] == _('Numeric ') + x: e = lineEdit(self.optionsBox,label=x,text=self.criteriaList[selectedCol]['value']) else: e = lineEdit(self.optionsBox,label=x) self.connect(e, SIGNAL("textEdited(QString)"), lambda val, col=selectedCol,field=x : self.clearOthers(val,self.optionsBox,field)) elif colClass in ['character']: self.stringLabel.show() self.options = [_('Equals'), _('Does Not Equal'),_('Begins With'),_('Ends With'), _('Contains'), _('Does Not Contain')] for x in self.options: if selectedCol in self.criteriaList and self.criteriaList[selectedCol]['method'] == _('String ') + x: e = lineEdit(self.optionsBox,label=x,text=self.criteriaList[selectedCol]['value']) else: e = lineEdit(self.optionsBox,label=x) self.connect(e, SIGNAL("textEdited(QString)"), lambda val, col=selectedCol,field=x : self.clearOthers(val,self.optionsBox,field)) buttonBox = widgetBox(self.optionsBox,orientation='horizontal') buttonBox.layout().setAlignment(Qt.AlignRight) okButton = button(buttonBox,label=_('OK'), callback=lambda col=selectedCol: self.createCriteriaList(col,self.optionsBox,action=_('OK'))) okButton.setDefault (True) button(buttonBox,label=_('Cancel'), callback=lambda col=selectedCol: self.createCriteriaList(col,self.optionsBox,action='cancel')) self.menu.move(globalPos) self.menu.show()
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')
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()
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)
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)
def __init__(self,widget,label=None, displayLabel=True, Rdata=None, editable=False, sortable=True, filterable=False, selectionBehavior=QAbstractItemView.SelectRows, selectionMode = QAbstractItemView.ExtendedSelection, showResizeButtons = True, onFilterCallback = None, callback=None, selectionCallback=None,**kwargs): kwargs.setdefault('includeInReports', True) kwargs.setdefault('sizePolicy', QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred)) widgetState.__init__(self,widget,label,**kwargs) if displayLabel: mainBox = groupBox(self.controlArea,label=label, orientation='vertical') else: mainBox = widgetBox(self.controlArea,orientation='vertical') self.label = label QTableView.__init__(self,self.controlArea) mainBox.layout().addWidget(self) box = widgetBox(mainBox,orientation='horizontal') leftBox = widgetBox(box,orientation='horizontal') if filterable: self.clearButton = button(leftBox,label=_('Clear All Filtering'), callback=self.clearFiltering) self.dataInfo = widgetLabel(leftBox,label='',wordWrap=False) box.layout().setAlignment(leftBox, Qt.AlignLeft) if showResizeButtons: resizeColsBox = widgetBox(box, orientation="horizontal") resizeColsBox.layout().setAlignment(Qt.AlignRight) box.layout().setAlignment(resizeColsBox, Qt.AlignRight) widgetLabel(resizeColsBox, label = _("Resize columns: ")) button(resizeColsBox, label = "+", callback=self.increaseColWidth, toolTip = _("Increase the width of the columns"), width=30) button(resizeColsBox, label = "-", callback=self.decreaseColWidth, toolTip = _("Decrease the width of the columns"), width=30) button(resizeColsBox, label = _("Resize To Content"), callback=self.resizeColumnsToContents, toolTip = _("Set width based on content size")) self.R = Rcommand self.Rdata = None self.filteredData = None self.sortIndex = None self.criteriaList = {} self.parent = widget self.tm=None self.sortable=sortable self.editable=editable self.filterable=filterable self.onFilterCallback = onFilterCallback self.selectionCallback = selectionCallback # self.selections = QItemSelection() self.working = False self.setHorizontalHeader(myHeaderView(self)) self.setSelectionBehavior(selectionBehavior) self.setAlternatingRowColors(True) # self.horizontalHeader().setMovable(True) if selectionMode != -1: self.setSelectionMode(selectionMode) if Rdata: self.setRTable(Rdata) if editable: self.horizontalHeader().hide() self.verticalHeader().hide() if sortable: self.horizontalHeader().setSortIndicatorShown(True) self.horizontalHeader().setSortIndicator(-1,0) if filterable or sortable: self.horizontalHeader().setClickable(True) self.horizontalHeader().setContextMenuPolicy(Qt.CustomContextMenu) self.horizontalHeader().customContextMenuRequested.connect(self.headerClicked) if callback: QObject.connect(self, SIGNAL('clicked (QModelIndex)'), callback)
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)