def on_export_pdf(self, event=None): # Determine the currently selected tab and ask it to export as PDF # TODO: Guard for welcome page selected_project = self.notebook.get_selected_project() selected_page = self.notebook.get_selected_project_panel( ).get_selected_page() if isinstance(selected_page, Experiment.ExperimentDataPanel): selected_page.export_pdf( input_filename=selected_project.filename.value) elif isinstance(selected_page, Project.CompoundsDataPanel): selected_page.export_pdf( input_filename=selected_project.filename.value) elif hasattr(selected_page, "export_pdf"): filename = file_dialog_wildcard( self, title="Export PDF", wildcard="PDF Files (*.pdf)|*.pdf;*.PDF", defaultDir=str(internal_config.last_export)) if filename: internal_config.last_export = filename[0] selected_page.export_pdf( input_filename=selected_project.filename.value, output_filename=filename[0]) time.sleep(1) webbrowser.open(filename[0]) else: wx.MessageBox( "The current page does not support exporting to PDF.", "Unsupported")
def export_pdf(self, input_filename): selected_page = self.get_selected_page() exportable_pages = {self.experiment_peaks, self.ident_panel} if (selected_page in exportable_pages) or hasattr( selected_page, "export_pdf"): filename = file_dialog_wildcard( self, title="Export PDF", wildcard="PDF Files (*.pdf)|*.pdf;*.PDF", defaultDir=str(internal_config.last_export)) if filename: internal_config.last_export = filename[0] if selected_page == self.experiment_peaks: self.export_peak_list_pdf(input_filename, output_filename=filename[0]) if selected_page == self.ident_panel: self.export_compounds_pdf(input_filename, output_filename=filename[0]) elif hasattr(selected_page, "export_pdf"): selected_page.export_pdf(input_filename, output_filename=filename[0]) time.sleep(1) webbrowser.open(filename[0]) else: wx.MessageBox( "The current page does not support exporting to PDF.", "Unsupported")
def OnPopupSave(self, event): print("OnPopupSave") image = self.GetSelectedItem()._original_image save_location = file_dialog_wildcard( self, "Save Image", ammo_images.images_wildcard.wildcard, style=wx.FD_SAVE | wx.FD_OVERWRITE_PROMPT ) if not save_location: return image.save(save_location[0]) event.Skip()
def OnPopupAddImage(self, event): print("OnPopupAddImage") new_image = file_dialog_wildcard( self, "Choose an Image", ammo_images.images_wildcard.wildcard, style=wx.FD_OPEN | wx.FD_FILE_MUST_EXIST ) if not new_image: return filename = new_image[0] self.AppendImage(Image.open(filename), os.path.split(filename)[-1]) event.Skip()
def on_export_ammo_details(self, event=None): # Determine the currently selected tab and ask it to export as PDF selected_page = self.notebook.get_selected_project_panel() if hasattr(selected_page, "export_ammo_details"): filename = file_dialog_wildcard( self, title="Export Ammo Details", wildcard="ammo Files (*.ammo)|*.ammo;*.AMMO", defaultDir=str(internal_config.last_export)) if filename: internal_config.last_export = filename[0] selected_page.export_ammo_details(output_filename=filename[0]) else: wx.MessageBox( "The Ammo Details cannot be exported for the current page.", "Unsupported")
def on_export_method(self, event=None): # Determine the currently selected tab and ask it to export as PDF selected_page = self.notebook.get_selected_page() if hasattr(selected_page, "export_method"): filename = file_dialog_wildcard( self, title="Export Method", wildcard="Method Files (*.method)|*.method;*.METHOD", defaultDir=str(internal_config.last_export)) if filename: internal_config.last_export = filename[0] selected_page.export_method(output_filename=filename[0]) else: wx.MessageBox( "The Method cannot be exported for the current page.", "Unsupported")
def on_export_project_report(self, event=None): # Determine the currently selected tab and ask it to export as PDF selected_project_panel = self.notebook.get_selected_project_panel() if selected_project_panel: filename = file_dialog_wildcard( self, title="Export Project Report", wildcard="PDF Files (*.pdf)|*.pdf;*.PDF", defaultDir=str(internal_config.last_export)) if filename: internal_config.last_export = filename[0] selected_project_panel.export_project_report( output_filename=filename[0]) time.sleep(1) webbrowser.open(filename[0]) else: wx.MessageBox( "The current page does not support exporting to PDF.", "Unsupported")
def export_pdf(self, input_filename): selected_page = self.get_selected_page() if hasattr(selected_page, "export_pdf"): filename = file_dialog_wildcard( self, title="Export PDF", wildcard="PDF Files (*.pdf)|*.pdf;*.PDF", defaultDir=str(internal_config.last_export)) if filename: internal_config.last_export = filename[0] selected_page.export_pdf(input_filename, output_filename=filename[0]) time.sleep(1) webbrowser.open(filename[0]) else: wx.MessageBox( "The current page does not support exporting to PDF.", "Unsupported")