Пример #1
0
    def close_page(self, ensure=True):
        """
		Close the current page.
		If the notebook becomes empty, and ensure is true,
		call new page upon exit to ensure that at least one page exists.
		@param ensure boolean
		"""
        if not self.page_to_be_closed: self.page_to_be_closed = self.get_page()
        #show the page if it has an executing flow graph or is unsaved
        if self.page_to_be_closed.get_proc(
        ) or not self.page_to_be_closed.get_saved():
            self._set_page(self.page_to_be_closed)
        #unsaved? ask the user
        if not self.page_to_be_closed.get_saved() and self._save_changes():
            Actions.FLOW_GRAPH_SAVE()  #try to save
            if not self.page_to_be_closed.get_saved():  #still unsaved?
                self.page_to_be_closed = None  #set the page to be closed back to None
                return
        #stop the flow graph if executing
        if self.page_to_be_closed.get_proc(): Actions.FLOW_GRAPH_KILL()
        #remove the page
        self.notebook.remove_page(
            self.notebook.page_num(self.page_to_be_closed))
        if ensure and self.notebook.get_n_pages() == 0:
            self.new_page()  #no pages, make a new one
        self.page_to_be_closed = None  #set the page to be closed back to None