def __init__(self,parent, schema): self.schema = schema QWizard.__init__(self, parent) self.setWindowTitle(_('Generate Report')) self.selectElements = QWizardPage() self.selectElements.setLayout(QVBoxLayout()) self.selectElements.setTitle(_('Create A Report')) self.selectElements.setSubTitle(_('Select the widgets to include in this report.')) #mainWidgetBox = redRWidgetBox(self.selectElements) self.topWidgetBox = redRWidgetBox(self.selectElements) #redRwidgetLabel(topWidgetBox,label='Select the widgets to include in the report.') self.widgetList = redRtreeWidget(self.topWidgetBox, label=_('Widget List'), displayLabel=False) self.widgetList.setHeaderLabels([_('Element'), _('Parameters')]) self.widgetList.setSelectionMode(QAbstractItemView.NoSelection) buttonWidgetBox = redRWidgetBox(self.topWidgetBox,orientation='horizontal') acceptButton = redRbutton(buttonWidgetBox, _('Expand/Collapse'),callback=self.expandCollapse) self.expandState=False #acceptButton = redRbutton(buttonWidgetBox, _('Expand'),toggleButton=True) # QObject.connect(acceptButton, SIGNAL("clicked()"), self.accept) QObject.connect(self.widgetList, SIGNAL(" itemClicked (QTreeWidgetItem *,int)"), self.widgetListItemClicked) QObject.connect(self.widgetList, SIGNAL(" itemChanged (QTreeWidgetItem *,int)"), self.widgetListStateChange) self.addPage(self.selectElements)
def __init__(self, widget, label = None, displayLabel = True, startColor = '#000000', callback = None, width = 15, height = 15,**kwargs): """Constructor, typically called with label, startColor, callback, and toolTip """ kwargs.setdefault('includeInReports', True) kwargs.setdefault('sizePolicy', QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred)) widgetState.__init__(self,widget, label, **kwargs) QToolButton.__init__(self, self.controlArea) if label and displayLabel: self.hb = redRWidgetBox(self.controlArea,orientation='horizontal') lb = widgetLabel(self.hb, label) self.hb.layout().addWidget(self) self.hasLabel = True self.hb.layout().setAlignment(lb,Qt.AlignRight) lb.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred) else: self.controlArea.layout().addWidget(self) self.hasLabel = False self.label = label self.w = width self.h = height self.setMinimumSize(width, height) self.callback = callback self.color = startColor self.setMaximumSize(self.w + 5, self.h + 5) self.connect(self, SIGNAL("clicked()"), self.showColorDialog) self.updateColor()
def __init__(self,widget,label = '', wordWrap=True,**kwargs): kwargs.setdefault('includeInReports', False) kwargs.setdefault('sizePolicy', QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred)) widgetState.__init__(self, widget, 'statusLabel',**kwargs) QLabel.__init__(self,self.controlArea) box = redRWidgetBox(self.controlArea,orientation='horizontal') self.controlArea.layout().addWidget(box) box.layout().addWidget(self) #self.statusIndicator = redRwidgetLabel(box,label='aaaaa ') #widget.layout().addWidget(self.statusIndicator) self.status = 0 self.setText(label) self.setWordWrap(wordWrap)
def __init__(self, widget, label='', wordWrap=True): widgetState.__init__(self, widget, 'statusLabel', includeInReports=False) QLabel.__init__(self, self.controlArea) # if icon: # icon = QIcon(icon) # box = redRWidgetBox(widget,orientation='horizontal') # box.layout().addWidget(icon) # box.layout().addWidget(self) # else: #widget.layout().addWidget(self) box = redRWidgetBox(self.controlArea, orientation='horizontal') self.controlArea.layout().addWidget(box) box.layout().addWidget(self) #self.statusIndicator = redRwidgetLabel(box,label='aaaaa ') #widget.layout().addWidget(self.statusIndicator) self.status = 0 self.setText(label) self.setWordWrap(wordWrap)
def createReportsMenu(self,schemaImage=True): qname = QFileDialog.getSaveFileName(self, _("Write Report to File"), redREnviron.directoryNames['documentsDir'] + "/Report-"+unicode(datetime.date.today())+".odt", "Open Office Text (*.odt);; HTML (*.html);; LaTeX (*.tex)") if qname.isEmpty(): return qname = unicode(qname) name = unicode(qname) # this is the file name of the Report # name = os.path.join(redREnviron.directoryNames['redRDir'],'restr.odt') if os.path.splitext(name)[1].lower() not in [".odt", ".html", ".tex"]: name = name + '.odt' fileDir = os.path.split(name)[0] try: fileDir2 = os.path.join(fileDir, os.path.splitext("Data-"+os.path.split(name)[1])[0]) fileDir2 = fileDir2.replace('\\', '/') fd3 = [] for p in fileDir2.split('/'): if len(p) > 8 and ' ' in p: fd3.append(p.replace(' ', '')[:6]+'~1') else: fd3.append(p) fileDir2 = '/'.join(fd3) if os.path.isdir(fileDir2): shutil.rmtree(fileDir2) # makes a file to place the temp data into. #This will be deleted once the odt file is made. os.mkdir(fileDir2) except Exception as inst: redRLog.log(redRLog.REDRCORE, redRLog.ERROR,redRLog.formatException()) # show the report list and allow the user to select widgets to include in the report. ## get the report info for the included widgets. # reportData = self.getReportData(fileDir2,name) import redRObjects done = self.createReport(fileDir2,name,redRObjects.instances(),schemaImage) if not done: return if os.name =='nt': #os.startfile doneDialog = redRdialog(self.schema,title=_("Report Generated")) redRwidgetLabel(doneDialog,label=_('Your report is ready to view.')) buttonBox = redRWidgetBox(doneDialog,orientation='horizontal') acceptButton = redRbutton(buttonBox,_('View Report')) QObject.connect(acceptButton, SIGNAL("clicked()"), doneDialog.accept) acceptButton = redRbutton(buttonBox,_('Done')) QObject.connect(acceptButton, SIGNAL("clicked()"), doneDialog.reject) if doneDialog.exec_() == QDialog.Accepted: try: os.startfile(name,'open') except: redRLog.log(redRLog.REDRCORE, redRLog.ERROR, redRLog.formatException()) mb = QMessageBox(_("Cannot Open File"), _("Red-R cannot open the reports file. Please open the file manually.\nThis is not a problem with Red-R, it is a problem with your document viewer."), QMessageBox.Information, QMessageBox.Ok | QMessageBox.Default, QMessageBox.NoButton, QMessageBox.NoButton,self) mb.exec_() else: QMessageBox.information(self, _("Red-R Canvas"), _("Your report is ready to view."), QMessageBox.Ok + QMessageBox.Default )
def createWidgetBox(self, orientation = 'vertical'): """Creates and returns a new widgetBox in the stack with orientation orientation""" newBox = redRWidgetBox(self, orientation = orientation) print self.addWidget(newBox) return newBox
def __init__(self, **kwargs): OWRpy.__init__(self, **kwargs) self.require_librarys(["ggplot2"]) self.RFunctionParam_y = '' self.RFunctionParam_x = '' self.setRvariableNames(["lineplot"]) self.inputs.addInput('id0', 'Data Table', redRDataFrame, self.processy) self.colours = [(0, _('Two Color Gradient')), (1, _('Three Color Gradient')), (2, _('Sequential Brewer Colors')), (3, _('Diverging Brewer Colors')), (4, _('Qualitative Brewer Colors')), (5, _('No Color'))] self.colourScaleWidgets = [] topBox = redRWidgetBox(self.controlArea, orientation = 'horizontal') aestheticsBox = redRGroupBox(topBox, label = _('Aesthetics'), orientation = 'horizontal') aestheticsBox.setSizePolicy(QSizePolicy(QSizePolicy.Maximum, QSizePolicy.Maximum)) self.xGroup = comboBox(aestheticsBox, label = _('X Values')) self.yData = comboBox(aestheticsBox, label = _('Y Values')) self.fillData = comboBox(aestheticsBox, label = _('Fill Data'), callback = self.fillDataChanged) self.linetypeCombo = comboBox(aestheticsBox, label = _('Line Type')) self.colourScale = comboBox(aestheticsBox, label = _('Color Scale'), items = self.colours, callback = self.colourScaleChanged) ## make the scale selector self.colourSelectorStack = stackedWidget(aestheticsBox) ## vlaue stack 0; gradient selector gradientBox = self.colourSelectorStack.createWidgetBox() self.colourScaleWidgets.append(gradientBox) self.gradientFrom = colorButton(gradientBox, label = _('From'), startColor = '#000000') self.gradientTo = colorButton(gradientBox, label = _('To'), startColor = '#FFFFFF') ## value stack 1; gradient2 selector gradient2Box = self.colourSelectorStack.createWidgetBox() self.colourScaleWidgets.append(gradient2Box) self.gradient2From = colorButton(gradient2Box, label = _('From'), startColor = '#FF0000') self.gradient2To = colorButton(gradient2Box, label = _('To'), startColor = '#00FF00') self.gradient2Via = colorButton(gradient2Box, label = _('Via'), startColor = '#FFFFFF') ## value stack 2; sequential brewer colors sequentialBox = self.colourSelectorStack.createWidgetBox() self.colourScaleWidgets.append(sequentialBox) self.sequentialPalettes = comboBox(sequentialBox, label = _('Palette'), items = [('Blues', _('Blues')), ('BuGn', _('Blue Green')), ('BuPu', _('Blue Purple')), ('GnBu', _('Green Blue')), ('Greens', _('Greens')), ('Greys', _('Greys')), ('Oranges', _('Oranges')), ('OrRd', _('Orange Red')), ('PuBu', _('Purple Blue')), ('PuBuGn', _('Purple Blue Green')), ('PuRd', _('Purple Red')), ('Purples', _('Purples')), ('RdPu', _('Red Purple')), ('Reds', _('Reds')), ('YlGn', _('Yellow Green')), ('YlGnBu', _('Yellow Green Blue')), ('YlOrBr', _('Yellow Orange Brown')), ('YlOrRd', _('Yellow Orange Red'))]) self.sequentialVariations = spinBox(sequentialBox, label = _('Variations'), decimals = 0, min = 3, max = 9, value = 5) ## value stack 3; diverging brewer colors divergingBox = self.colourSelectorStack.createWidgetBox() self.colourScaleWidgets.append(divergingBox) paletteItems = [('BrBG', _('Brown Blue Green')), ('PiYG', _('Pink Yellow Green')), ('PRGn', _('Pink Red Green')), ('PuOr', _('Purple Orange')), ('RdBu', _('Red Blue')), ('RdGy', _('Red Grey')), ('RdYlBu', _('Red Yellow Blue')), ('RdYlGn', _('Red Yellow Green')), ('Spectral', _('Spectral'))] self.divergingPalettes = comboBox(divergingBox, label = _('Palette'), items = paletteItems) self.divergingVariations = spinBox(divergingBox, label = _('Variations'), decimals = 0, min = 3, max = 11, value = 5) ## value stack 4; qualitative brewer colors qualitativeBox = self.colourSelectorStack.createWidgetBox() self.colourScaleWidgets.append(qualitativeBox) self.qualitativePalettes = comboBox(qualitativeBox, label = _('Palette'), items = [('Accent', _('Accent')), ('Dark2', _('Dark2')), ('Paired', _('Paired')), ('Pastel1', _('Pastel1')), ('Pastel2', _('Pastel2')), ('Set1', _('Set1')), ('Set2', _('Set2')), ('Set3', _('Set3'))]) self.qualitativeVariations = spinBox(qualitativeBox, label = _('Variations'), decimals = 0, min = 3, max = 8, value = 5) ## value stack 5; no color noColorBox = self.colourSelectorStack.createWidgetBox() self.colourScaleWidgets.append(noColorBox) ## error bars errorBox = redRGroupBox(self.controlArea, label = _('Error Bar Options'), orientation = 'horizontal') self.errorBarData = comboBox(errorBox, label = _('Error Bar Data')) self.colourSelectorStack.setCurrentIndex(0) self.graphicsView = redRGGPlot(self.controlArea,label='Box Plot',displayLabel=False, name = self.captionTitle) self.commit = redRCommitButton(self.bottomAreaRight, _("Commit"), callback = self.commitFunction, processOnInput=True) self.colourScaleChanged()