Answer the question
In order to leave comments, you need to log in
Why does Sublime Text 3 crash when calling sublime.message_dialog?
I master writing plug-ins for ST3. I took a ready-made example and try to display a MessageBox when selecting a symbol. Here is the code:
import os
import sublime
import sublime_plugin
class UnicodeCharacterInsertCommand(sublime_plugin.TextCommand):
def run(self, edit):
content = self.get_popup_content()
self.view.show_popup(content, flags=sublime.HTML, location=-1, max_width=400, on_navigate=self.on_choice_symbol)
def get_characters_html(self):
resources = sublime.find_resources('unicode-characters.html')
content = sublime.load_resource(resources[0])
return content
def on_choice_symbol(self, symbol):
self.view.run_command("insert", {"characters": symbol})
self.view.hide_popup()
sublime.message_dialog("message_dialog check: %s" % symbol) # вот тут саблайм падает
def get_popup_content(self):
tpl_path = os.path.dirname(os.path.realpath(__file__)) + '/unicode-characters.html'
content = open(tpl_path, 'r').read()
return content
Answer the question
In order to leave comments, you need to log in
Found the answer by clicking. It was necessary to show the window in the asynchronous call of the set_timeout_async method :
sublime.set_timeout_async(lambda: sublime.message_dialog("message_dialog check: %s" % symbol), 0)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question