def Run(self): from dataStructures.reporting import Report results.write("Testing data structures\n\n") frame = self.StartGui() results.write("OK\n") results.write(self.data.GetSummary()) results.write("Testing reporting ... ") partList = ["scoreList", "emptyScoringSheet","scoreGraphics","screenSols", "stockSols"] parts = {} for part in partList: #if part == "emptyScoringSheet": if part: parts[part] = 1 else: parts[part] = 0 parts["screenVolumes"] = (10,"ml") path = os.path.abspath(files + "/test.pdf") try: report = Report(self.data,parts, frame.xtal_panel.tray, path) gen = report.compile() os.startfile(path) except: print "Reporting failed" print sys.exc_info() raise results.write("OK\n") frame.Destroy()
def OnReport(self,event): from dataStructures.reporting import Report dir = self.controller.userData.GetValue("LastDir") choiceList = ["Result Sheet", "Scoring Sheet", "Scoring Graphics", "Screen Solutions", "Screen Pipetting Scheme", "Stock Solutions"] partList = ["scoreList", "emptyScoringSheet","scoreGraphics","screenSols", "screenVolumes","stockSols"] parts = {} choiceBox = wx.MultiChoiceDialog(self, "Choose for printing:", "Choicebox",choiceList) if choiceBox.ShowModal() == wx.ID_OK: choices = choiceBox.GetSelections() for i in range(len(partList)): if choices.count(i) > 0: if partList[i] == "screenVolumes": d = wx.GetTextFromUser ("Please enter the volume with unit.\nFor example: \"10 ml\"", "Input Volume",\ "10 ml", self,) if d: screenVolume = d.split(' ') try: screenVolume[0] = float(screenVolume[0]) if len(screenVolume) == 2: parts[partList[i]] = screenVolume else: parts[partList[i]] = 0 except: parts[partList[i]] = 0 print "Screen Volume Input Invalid" else: parts[partList[i]] = 0 else: parts[partList[i]] = 1 else: parts[partList[i]] = 0 dlg = wx.FileDialog( self, message="Save Report to", defaultDir=dir, defaultFile=self.data.GetFilename().split('.')[0], wildcard=pdf_wildcard, style=wx.SAVE | wx.CHANGE_DIR ) # Show the dialog and retrieve the user response. If it is the OK response, # process the data. if dlg.ShowModal() == wx.ID_OK: self.controller.userData.SetValue("LastDir", os.getcwd()) # This returns a Python list of files that were selected. path = dlg.GetPath() if os.access(path, os.F_OK): d = wx.MessageBox("Overwrite existing file?", "Confirm", wx.YES_NO, self) if d == wx.YES: report = Report(self.data,parts, self.xtal_panel.tray, path) gen = report.compile() else: report = Report(self.data,parts, self.xtal_panel.tray, path) gen = report.compile() dlg.Destroy() if gen[0]: #wx.MessageBox(gen[1], "Message", wx.OK) os.startfile(path) else: wx.MessageBox(gen[1], "Message", wx.OK)