Home Download Buy Blog Forum Support

Show an ok_cancel dialog

Show an ok_cancel dialog

Postby guillermo-carrasco on Mon Jun 11, 2012 9:28 am

Hello everybody,

I'm writing my first plugin for sublime and I need some help. I want to show some kind of ok_cancel dialog to prevent the user for overwriting a configuration file, and I don't know how to do that. The ok_cancel_dialog function is not available on the build 2181. Any suggestions?

Thank you very much!
guillermo-carrasco
 
Posts: 3
Joined: Mon Jun 11, 2012 9:21 am

Re: Show an ok_cancel dialog

Postby jbjornson on Mon Jun 11, 2012 9:49 am

Why not just upgrade to 2187 or higher where the ok_cancel_dialog function is available?
jbjornson
 
Posts: 350
Joined: Tue Oct 27, 2009 4:25 pm
Location: Zurich, Switzerland

Re: Show an ok_cancel dialog

Postby guillermo-carrasco on Mon Jun 11, 2012 9:56 am

Hi jbjornson ,

Well, just because these are development versions if I'm not wrong. I want to work with the latest stable.

Thanks!
guillermo-carrasco
 
Posts: 3
Joined: Mon Jun 11, 2012 9:21 am

Re: Show an ok_cancel dialog

Postby jbjornson on Mon Jun 11, 2012 10:14 am

Fair enough. Maybe you could display an input panel on the view that expects a yes/no value?

Code: Select all
import sublime, sublime_plugin

class ExampleCommand(sublime_plugin.WindowCommand):
    def run(self):
        self.window.show_input_panel('Do you really want to overwrite the configuration file (yes/no):', 'No', lambda s: self.handle_response(s), None, None)

    def handle_response(self, answer):
        if answer.upper() in ['Y', 'YES']:
            print 'About to overwrite the configuration file'
        else:
            print 'Abort configuration file overwrite'
jbjornson
 
Posts: 350
Joined: Tue Oct 27, 2009 4:25 pm
Location: Zurich, Switzerland

Re: Show an ok_cancel dialog

Postby guillermo-carrasco on Mon Jun 11, 2012 10:28 am

Hm... it's a good approach by the moment, and it works fine. Thak you very much!
guillermo-carrasco
 
Posts: 3
Joined: Mon Jun 11, 2012 9:21 am


Return to Plugin Development

Who is online

Users browsing this forum: No registered users and 10 guests