当前位置: 首页>>代码示例>>Python>>正文


Python api.confirm函数代码示例

本文整理汇总了Python中pyface.api.confirm函数的典型用法代码示例。如果您正苦于以下问题:Python confirm函数的具体用法?Python confirm怎么用?Python confirm使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了confirm函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: tno_confirm_delete

 def tno_confirm_delete ( self, node = None ):
     """ Confirms that a specified object can be deleted or not.
     """
     return (confirm( self.handler.parent,
            "Delete '%s' from the file space?\n\nNote: No files will be "
            "deleted." % self.root.name,
            'Delete File Space Root' ) == YES)
开发者ID:enthought,项目名称:etsdevtools,代码行数:7,代码来源:file_space.py

示例2: _inner

 def _inner(self, info, *args, **kw):
     if self.object_modified(info):
         mesg = 'This record has been modified. '
         mesg += 'Are you sure you wish to discard the changes?'
         if confirm(info.ui.control, mesg) == NO:
             return False
     return func(self, info, *args, **kw)
开发者ID:bburan,项目名称:NeuroBehavior,代码行数:7,代码来源:file_handler.py

示例3: _save_as_fired

    def _save_as_fired(self):
        # create raw
        try:
            raw = self.model.get_raw()
        except Exception as err:
            error(None, str(err), "Error Creating KIT Raw")
            raise

        # find default path
        stem, _ = os.path.splitext(self.sqd_file)
        if not stem.endswith('raw'):
            stem += '-raw'
        default_path = stem + '.fif'

        # save as dialog
        dlg = FileDialog(action="save as",
                         wildcard="fiff raw file (*.fif)|*.fif",
                         default_path=default_path)
        dlg.open()
        if dlg.return_code != OK:
            return

        fname = dlg.path
        if not fname.endswith('.fif'):
            fname += '.fif'
            if os.path.exists(fname):
                answer = confirm(None, "The file %r already exists. Should it "
                                 "be replaced?", "Overwrite File?")
                if answer != YES:
                    return

        self.queue.put((raw, fname))
        self.queue_len += 1
开发者ID:Anevar,项目名称:mne-python,代码行数:33,代码来源:_kit2fiff_gui.py

示例4: read_cache

    def read_cache(self):
        """Read the user cache from persistent storage.  Returns False if
        there was no cache to read."""

        try:
            f = open(self._cache_file, 'r')

            try:
                if confirm(None, "It was not possible to connect to the "
                        "permissions server. Instead you can use the settings "
                        "used when you last logged in from this system. If "
                        "you do this then any changes made to settings "
                        "normally held on the permissions server will be lost "
                        "when you next login successfully.\n\nDo you want to "
                        "use the saved settings?") != YES:
                    raise Exception("")

                try:
                    self.cache = pickle.load(f)
                except:
                    raise Exception("Unable to read %s." % self._cache_file)
            finally:
                f.close()
        except IOError, e:
            if e.errno == errno.ENOENT:
                # There is no cache file.
                return False

            raise Exception("Unable to open %s: %s." % (self._cache_file, e))
开发者ID:archcidburnziso,项目名称:apptools,代码行数:29,代码来源:proxy_server.py

示例5: display_confirm

def display_confirm(message, title=None, cancel=False):
    answer = pyface.confirm(None, message, title=title, cancel=cancel)
    if answer == pyface.YES:
        return True
    if answer == pyface.NO:
        return False
    if answer == pyface.CANCEL:
        return None
开发者ID:mrkwjc,项目名称:ffnetui,代码行数:8,代码来源:messages.py

示例6: close

 def close(self, info, isok):
     # Return True to indicate that it is OK to close the window.
     if not info.object.saved:
         response = confirm(info.ui.control,
                            "Value is not saved.  Are you sure you want to exit?")
         return response == YES
     else:
         return True
开发者ID:akeshavan,项目名称:BrainImagingPipelines,代码行数:8,代码来源:base.py

示例7: _decompress_fired

 def _decompress_fired(self):
     ask_again = True
     delete = confirm(None, 'Delete zip-file after decompression was selected.\nDo you want to delete it for all selected tasks?')
     if delete == YES:
         ask_again = False
     for task in self.task_selector.evaluated_tasks:
         task_dir = os.path.join(self.project_info.project_dir, task)
         # results_dir = os.path.join(task_dir, 'results')
         zip_file = os.path.join(task_dir, 'results.zip')
         zf = zipfile.ZipFile(zip_file, 'r')
         zf.extractall(task_dir)
         zf.close()
         if delete and ask_again:
             if confirm(None, 'Delete zip-file after decompression was selected.\nDo you want to delete it?') == YES:
                 os.remove(zip_file)
         elif delete:
             os.remove(zip_file)
     print 'Results decompressed'
开发者ID:kelidas,项目名称:scratch,代码行数:18,代码来源:atena_python.py

示例8: object__delete_changed

 def object__delete_changed(self, info):
     if not info.initialized:
         return
     if info.object._selected is not None:
         selected = info.object._selected
         mesg = 'Are you sure you want to delete animal %s?'
         if confirm(info.ui.control, mesg % selected) == YES:
             info.object.animals.remove(selected)
             info.object._selected = None
开发者ID:bburan,项目名称:NeuroBehavior,代码行数:9,代码来源:cohort.py

示例9: _editor_closing_changed_for_window

    def _editor_closing_changed_for_window(self, editor):
        """ Handle the editor being closed.
        """
        if (editor is self) and self.dirty:
            retval = confirm(self.window.control, title="Save Resource",
                message="'%s' has been modified. Save changes?" %
                self.name[1:])

            if retval == YES:
                self.save()
开发者ID:robmcmullen,项目名称:puddle,代码行数:10,代码来源:resource_editor.py

示例10: _generate_fired

 def _generate_fired(self):
     if confirm(None, 'All results will be deleted!') == YES:
         for task_num, task in zip(self.task_num_lst, self.task_name_lst):
             task_dir = os.path.join(self.project_info.project_dir, task)
             prepare_dir(task_dir)
             outfile = open(os.path.join(task_dir, task + '.inp'), 'w')
             if self.n_var_input > 0:
                 self.__insert_vars_to_inp(outfile, self.freet_data[task_num - 1, :])
             outfile.close()
             print 'TASK ' + task + ' created'
开发者ID:kelidas,项目名称:scratch,代码行数:10,代码来源:atena_python.py

示例11: _save_fired

    def _save_fired(self):
        if self.n_scale_params:
            subjects_dir = self.model.mri.subjects_dir
            subject_from = self.model.mri.subject
            subject_to = self.model.raw_subject or self.model.mri.subject
        else:
            subject_to = self.model.mri.subject

        # ask for target subject
        if self.n_scale_params:
            mridlg = NewMriDialog(subjects_dir=subjects_dir, subject_from=subject_from, subject_to=subject_to)
            ui = mridlg.edit_traits(kind="modal")
            if ui.result != True:
                return
            subject_to = mridlg.subject_to

        # find bem file to run mne_prepare_bem_model
        if self.can_prepare_bem_model and self.prepare_bem_model:
            bem_job = self.model.get_prepare_bem_model_job(subject_to)
        else:
            bem_job = None

        # find trans file destination
        raw_dir = os.path.dirname(self.model.hsp.file)
        trans_file = trans_fname.format(raw_dir=raw_dir, subject=subject_to)
        dlg = FileDialog(action="save as", wildcard=trans_wildcard, default_path=trans_file)
        dlg.open()
        if dlg.return_code != OK:
            return
        trans_file = dlg.path
        if not trans_file.endswith(".fif"):
            trans_file = trans_file + ".fif"
            if os.path.exists(trans_file):
                answer = confirm(None, "The file %r already exists. Should it " "be replaced?", "Overwrite File?")
                if answer != YES:
                    return

        # save the trans file
        try:
            self.model.save_trans(trans_file)
        except Exception as e:
            error(None, str(e), "Error Saving Trans File")
            return

        # save the scaled MRI
        if self.n_scale_params:
            job = self.model.get_scaling_job(subject_to)
            self.queue.put(job)
            self.queue_len += 1

            if bem_job is not None:
                self.queue.put(bem_job)
                self.queue_len += 1
开发者ID:NeedlessToSay,项目名称:mne-python,代码行数:53,代码来源:_coreg_gui.py

示例12: _compress_fired

 def _compress_fired(self):
     ask_again = True
     delete = confirm(None, 'Delete directory "results" after compression  was selected.\nDo you want to delete it for all selected tasks?')
     if delete == YES:
         ask_again = False
     for task in self.task_selector.evaluated_tasks:
         task_dir = os.path.join(self.project_info.project_dir, task)
         results_dir = os.path.join(task_dir, 'results')
         zip_file = os.path.join(task_dir, 'results.zip')
         zf = zipfile.ZipFile(zip_file, 'w', zipfile.ZIP_DEFLATED)
         for dirname, subdirs, files in os.walk(results_dir):
             for filename in files:
                 zf.write(os.path.join(dirname, filename),
                          os.path.join('results', filename))
         zf.close()
         if delete and ask_again:
             if confirm(None, 'Delete directory "results" after compression was selected.\nDo you want to delete it?') == YES:
                 shutil.rmtree(results_dir)
         elif delete:
             shutil.rmtree(results_dir)
     print 'Results compressed'
开发者ID:kelidas,项目名称:scratch,代码行数:21,代码来源:atena_python.py

示例13: _on_exit

    def _on_exit(self):
        """ Called when the exit action is invoked. """

        parent = self.control

        information(parent, 'Going...')
        warning(parent, 'Going......')
        error(parent, 'Gone!')

        if confirm(parent, 'Should I exit?') == YES:
            self.close()

        return
开发者ID:OspreyX,项目名称:pyface,代码行数:13,代码来源:dialog.py

示例14: _on_exit

    def _on_exit(self):
        """ Called when the exit action is invoked. """

        parent = self.control

        print(choose_one(parent, "Make a choice", ['one', 'two', 'three']))

        information(parent, 'Going...')
        warning(parent, 'Going......')
        error(parent, 'Gone!')

        if confirm(parent, 'Should I exit?') == YES:
            self.close()
开发者ID:bergtholdt,项目名称:pyface,代码行数:13,代码来源:dialog.py

示例15: promptForSave

 def promptForSave(self, info, cancel=True):
     """ Prompts the user to save the object, if appropriate. Returns whether
         the user canceled the action that invoked this prompt.
     """
     if self.saveObject.dirty:
         code = confirm(info.ui.control, self.savePromptMessage,
                        title="Save now?", cancel=cancel)
         if code == CANCEL:
             return False
         elif code == YES:
             if not self.save(info):
                 return self.promptForSave(info, cancel)
     return True
开发者ID:bergtholdt,项目名称:traitsui,代码行数:13,代码来源:saving.py


注:本文中的pyface.api.confirm函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。