def on_new_project(self, _): # TODO: do this like the new_experiment dialog, where it is not modal, including the guard code # TODO@ guard code could perhaps be a decorator with Project.NewProjectDialog(self, wx.ID_ANY) as dlg: if dlg.ShowModal() == wx.ID_OK: if dlg.filename: self.open_project(dlg.filename)
def OnCreateProject(self, event): # wxGlade: _WelcomeDialog.<event_handler> with Project.NewProjectDialog(self, wx.ID_ANY) as dlg: if dlg.ShowModal() == wx.ID_OK: if dlg.filename: self.OpenProject(dlg.filename) event.Skip()
def open_project(self, filename): print(f"Opening project: {filename}") project = Project.load(filename) if project.name in self.opened_projects: wx.MessageBox( """That Project, or a Project with the same name, is already open. Please choose a different project.""", "Project Already Open", wx.ICON_ERROR | wx.OK, parent=self) return page = self.notebook.add_project(project) self.opened_projects[project.name] = page self.project_navigator.add_project(project) internal_config.last_project = filename internal_config.add_recent_project(project.name, filename) self.setup_recent_menu() self._mgr.Update() self.notebook.update_titles() current_project_idx = self.notebook.GetSelection() current_project_panel = self.notebook.GetPage(current_project_idx) print( f"Unsaved Changes: {current_project_panel.project.unsaved_changes}" )
def add_project(self, project): # TODO?: Check if project already in notebook page = Project.ProjectDataPanel(self, project) # self.notebook.AddPage(page, "Eley Contact Propellant") self.AddPage(page, project.name) self.select_last_page() return page
def create_alignment_page(self): """ Create the page for the Alignment data """ if not self.project.alignment_performed: raise ValueError("Alignment must be performed first") self.alignment_page = Project.AlignmentDataPanel( self.notebook, self.project) self.notebook.AddPage(self.alignment_page, "Alignment Data", select=True)
def __init__(self, parent, project, id=wx.ID_ANY, pos=wx.DefaultPosition, size=wx.DefaultSize, style=0, name="AlignmentDataPanel"): """ TODO: Does this need to be a sorter panel or would a simple listctrl suffice? :param parent: The parent window. :type parent: wx.Window :param project: :type project: :param id: An identifier for the panel. ID_ANY is taken to mean a default. :type id: wx.WindowID, optional :param pos: The panel position. The value wx.DefaultPosition indicates a default position, chosen by either the windowing system or wxWidgets, depending on platform. :type pos: wx.Point, optional :param size: The panel size. The value wx.DefaultSize indicates a default size, chosen by either the windowing system or wxWidgets, depending on platform. :type size: wx.Size, optional :param style: The window style. See wx.Panel. :type style: int, optional :param name: Window name :type name: str, optional """ args = (parent, id) kwds = dict(pos=pos, size=size, style=style, name=name) self.parent = parent self.project = project # begin wxGlade: AlignmentDataPanel.__init__ kwds["style"] = kwds.get("style", 0) | wx.TAB_TRAVERSAL wx.Panel.__init__(self, *args, **kwds) self.filter_button = wx.BitmapButton(self, wx.ID_ANY, get_icon("data-filter", 32)) self.alignment_table = SorterPanels.SorterPanel(self, wx.ID_ANY) self.__set_properties() self.__do_layout() self.Bind(wx.EVT_BUTTON, self.on_filter_peaks, self.filter_button) # end wxGlade self.alignment_table.AppendColumn("Peak No.", format=wx.LIST_FORMAT_LEFT, width=80) for experiment in self.project.experiment_name_list: self.alignment_table.AppendColumn(experiment, format=wx.LIST_FORMAT_RIGHT, width=120) self.Bind(SorterPanels.myEVT_SORTER_PANEL_DCLICK, self.on_item_dclick) self.Bind(SorterPanels.myEVT_SORTER_PANEL_RCLICK, self.on_right_click) self.Bind(wx.EVT_BUTTON, self.apply_filter, id=wx.ID_APPLY) self.Bind(wx.EVT_BUTTON, self.apply_filter, id=wx.ID_OK) self.default_filter_settings() self._populate_table() self.filter_dialog = Project.AlignmentFilterDialog(self)
def export_pdf(self, input_filename, output_filename): Project.AlignmentPDFExporter( self, input_filename=input_filename, output_filename=output_filename, )
def export_project_report(self, output_filename): Project.ProjectReportPDFExporter(self, output_filename)
def __init__(self, parent, project, id=wx.ID_ANY, pos=wx.DefaultPosition, size=wx.DefaultSize, style=0, name="ProjectDataPanel"): """ :param parent: The parent window. :type parent: wx.Window :param project: :type project: :param id: An identifier for the panel. wx.ID_ANY is taken to mean a default. :type id: wx.WindowID, optional :param pos: The panel position. The value wx.DefaultPosition indicates a default position, chosen by either the windowing system or wxWidgets, depending on platform. :type pos: wx.Point, optional :param size: The panel size. The value wx.DefaultSize indicates a default size, chosen by either the windowing system or wxWidgets, depending on platform. :type size: wx.Size, optional :param style: The window style. See wxPanel. :type style: int, optional :param name: Window name. :type name: str, optional """ self.project = project ProjExprPanelBase.__init__(self, parent, id=id, pos=pos, size=size, style=style | wx.TAB_TRAVERSAL, name=name) self.project_info = Project.ProjectInfoPanel(self, self.project, self.notebook, wx.ID_ANY) self.notebook.AddPage(self.project_info, "Project Info") # Make tabs self.method_tab = None self.make_method_tab() self.project_ammo = None self.make_ammo_tab() self.experiment_pages = {} # Add Experiments for experiment in self.project.experiment_objects: experiment_page = Experiment.ExperimentDataPanel( experiment, self.notebook, wx.ID_ANY) self.notebook.AddPage(experiment_page, experiment.name) self.experiment_pages[experiment.name] = experiment_page self.alignment_page = None if self.project.alignment_performed: self.create_alignment_page() # self.ident_panel = None # if any(experiment.identification_performed for experiment in self.project.experiment_objects): # self.add_ident_tab() self.compounds_tab = Project.CompoundsDataPanel(self) self.notebook.AddPage(self.compounds_tab, "Compounds") # self.consolidate_panel = None # if self.project.consolidate_performed: # self.add_consolidate_tab() for page_idx in range(self.notebook.PageCount): if self.notebook.GetPageText(page_idx) == "Project Info": self.notebook.SetSelection(page_idx) break else: self.notebook.SetSelection(0) self._bind_events() self.project._unsaved_changes = False self.project.ammo_details_unsaved = False self.project.method_unsaved = False