def new_clicked(self, widget): """Method used to create a new blank measurement. """ message = cleandoc("""The measurement you are editing is about to be destroyed to create a new one. Press OK to confirm, or Cancel to go back to editing and get a chance to save it.""") result = question(widget, 'Old measurement suppression', textwrap.fill(message.replace('\n', ' '),80), ) if result is not None and result.action == 'accept': widget.meas.root_task = RootTask()
def delete_instr_clicked(self, view): """ Open confirmation dialog when the user asks to delete a profile """ manager = view.manager message = cleandoc(u"""Are you sure want to delete this instrument connection informations ?""") result = question(parent = view, text = fill(message, 80), title = 'Deletion confirmation' ) if result is not None and result.action == 'accept': instr_file = manager.instrs[manager.selected_instr_name] path = os.path.abspath(manager.instr_folder) fullpath = os.path.join(path, instr_file) os.remove(fullpath)
def new_clicked(self, widget): """Method used to create a new blank measurement. """ message = cleandoc("""The measurement you are editing is about to be destroyed to create a new one. Press OK to confirm, or Cancel to go back to editing and get a chance to save it.""") result = question( widget, 'Old measurement suppression', textwrap.fill(message.replace('\n', ' '), 80), ) if result is not None and result.action == 'accept': widget.meas.root_task = RootTask()
def new_measure(self): """ """ message = cleandoc("""The measurement you are editing is about to be destroyed to create a new one. Press OK to confirm, or Cancel to go back to editing and get a chance to save it.""") result = question(self.content, 'Old measurement suppression', fill(message.replace('\n', ' '), 79), ) if result is not None and result.action == 'accept': self._new_measure()
def save_template_clicked(self, widget): """Method used to save the whole measurement as a template. """ message = cleandoc("""You are going to save the whole measurement you are editing as a template. If you want to save only a part of it, use the contextual menu.""") result = question(widget, 'Saving measurement', textwrap.fill(message.replace('\n', ' '),80), ) if result is not None and result.action == 'accept': save_task(widget.meas.root_task, mode = 'template')
def save_measure(self, measure, mode): """ Save a measure in a file. Parameters ---------- measure : Measure Measure to save. mode : str file: The user is asked to choose a file in which to save the measure. template: Save the whole measure as a template. """ if mode == 'file': get_file = FileDialogEx.get_save_file_name path = measure.path \ if measure.path else self.plugin.paths.get('measure', '') full_path = get_file(parent=self.content, current_path=path, name_filters=[u'*.ini']) if not full_path: return elif not full_path.endswith('.ini'): full_path += '.ini' measure.save_measure(full_path) self.plugin.edited_measure_path = full_path self.plugin.paths['measure'] = os.path.dirname(full_path) elif mode == 'template': message = cleandoc("""You are going to save the whole measurement you are editing as a template. If you want to save only a part of it, use the contextual menu.""") result = question(self.content, 'Saving measurement', fill(message.replace('\n', ' '), 79), ) if result is not None and result.action == 'accept': core = self.workbench.get_plugin(u'enaml.workbnch.core') cmd = u'hqc_meas.task_manager.save_task' core.invoke_command(cmd, {'obj': measure.root_task, 'mode': 'template'}, self)
def save_template_clicked(self, widget): """Method used to save the whole measurement as a template. """ message = cleandoc("""You are going to save the whole measurement you are editing as a template. If you want to save only a part of it, use the contextual menu.""") result = question( widget, 'Saving measurement', textwrap.fill(message.replace('\n', ' '), 80), ) if result is not None and result.action == 'accept': save_task(widget.meas.root_task, mode='template')
def new_sequence(self): """ Create a brand new empty sequence. """ message = cleandoc("""Make sure you saved your modification to the sequence you are editing before creating a new one. Press Yes to confirm, or No to go back to editing and get a chance to save it.""") result = question(self.content, 'Currently edited sequence replacement', fill(message.replace('\n', ' '), 79), ) if result is not None and result.action == 'accept': self.state.sequence = RootSequence() logger = logging.getLogger(__name__) logger.info('New sequence created')
def new_sequence(self): """ Create a brand new empty sequence. """ message = cleandoc("""Make sure you saved your modification to the sequence you are editing before creating a new one. Press Yes to confirm, or No to go back to editing and get a chance to save it.""") result = question( self.content, 'Currently edited sequence replacement', fill(message.replace('\n', ' '), 79), ) if result is not None and result.action == 'accept': self.state.sequence = RootSequence() logger = logging.getLogger(__name__) logger.info('New sequence created')
def ask_yes_no(title, message, parent=None): button = question(parent, title, message) return button.text == 'Yes'