本文整理汇总了Python中sublime.message_dialog函数的典型用法代码示例。如果您正苦于以下问题:Python message_dialog函数的具体用法?Python message_dialog怎么用?Python message_dialog使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了message_dialog函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run
def run(self, edit):
sels = self.view.sel()
if self.isRegionEmpty(sels[0]):
sublime.message_dialog("Please select list by pressing ctrl+A")
else:
if self.convertListTocsv(sels,edit) =="true":
sublime.status_message("Conversion Done")
示例2: popup_error_list
def popup_error_list(self):
""" Display a popup list of the errors found """
view_id = self.view.id()
if not view_id in PYLINTER_ERRORS:
return
# No errors were found
if len(PYLINTER_ERRORS[view_id]) == 1:
sublime.message_dialog("No Pylint errors found")
return
errors = [(key + 1, value)
for key, value in PYLINTER_ERRORS[view_id].items()
if key != 'visible']
line_nums, panel_items = zip(*sorted(errors,
key=lambda error: error[1]))
def on_done(selected_item):
""" Jump to the line of the item that was selected from the list """
if selected_item == -1:
return
self.view.run_command("goto_line",
{"line": line_nums[selected_item]})
self.view.window().show_quick_panel(list(panel_items), on_done)
示例3: handler
def handler(self, name, data):
if name == 'create_user':
del data['name']
try:
floorc = BASE_FLOORC + '\n'.join(['%s %s' % (k, v) for k, v in data.items()]) + '\n'
with open(G.FLOORC_PATH, 'wb') as floorc_fd:
floorc_fd.write(floorc.encode('utf-8'))
utils.reload_settings()
if False in [bool(x) for x in (G.USERNAME, G.API_KEY, G.SECRET)]:
sublime.message_dialog('Something went wrong. You will need to sign up for an account to use Floobits.')
api.send_error({'message': 'No username or secret'})
else:
p = os.path.join(G.BASE_DIR, 'welcome.md')
with open(p, 'wb') as fd:
text = welcome_text % (G.USERNAME, self.host)
fd.write(text.encode('utf-8'))
d = utils.get_persistent_data()
d['auto_generated_account'] = True
utils.update_persistent_data(d)
G.AUTO_GENERATED_ACCOUNT = True
sublime.active_window().open_file(p)
except Exception as e:
msg.error(e)
try:
d = utils.get_persistent_data()
d['disable_account_creation'] = True
utils.update_persistent_data(d)
finally:
self.stop()
示例4: extract
def extract(self):
sep = os.sep
if self.NODE_JS_TAR_EXTENSION != ".zip" :
with tarfile.open(self.NODE_JS_BINARY_TARFILE_FULL_PATH, "r:gz") as tar :
for member in tar.getmembers() :
member.name = sep.join(member.name.split(sep)[1:])
tar.extract(member, node_variables.NODE_JS_BINARIES_FOLDER_PLATFORM)
else :
if node_variables.NODE_JS_OS == "win" :
import string
from ctypes import windll, c_int, c_wchar_p
UNUSUED_DRIVE_LETTER = ""
for letter in string.ascii_uppercase:
if not os.path.exists(letter+":") :
UNUSUED_DRIVE_LETTER = letter+":"
break
if not UNUSUED_DRIVE_LETTER :
sublime.message_dialog("Can't install node.js and npm! UNUSUED_DRIVE_LETTER not found.")
return
DefineDosDevice = windll.kernel32.DefineDosDeviceW
DefineDosDevice.argtypes = [ c_int, c_wchar_p, c_wchar_p ]
DefineDosDevice(0, UNUSUED_DRIVE_LETTER, node_variables.NODE_JS_BINARIES_FOLDER_PLATFORM)
try:
with zipfile.ZipFile(self.NODE_JS_BINARY_TARFILE_FULL_PATH, "r") as zip_file :
for member in zip_file.namelist() :
if not member.endswith("/") :
with zip_file.open(member) as node_file:
with open(UNUSUED_DRIVE_LETTER + "\\"+ member.replace("node-"+self.NODE_JS_VERSION+"-"+node_variables.NODE_JS_OS+"-"+node_variables.NODE_JS_ARCHITECTURE+"/", ""), "wb+") as target :
shutil.copyfileobj(node_file, target)
elif not member.endswith("node-"+self.NODE_JS_VERSION+"-"+node_variables.NODE_JS_OS+"-"+node_variables.NODE_JS_ARCHITECTURE+"/"):
os.mkdir(UNUSUED_DRIVE_LETTER + "\\"+ member.replace("node-"+self.NODE_JS_VERSION+"-"+node_variables.NODE_JS_OS+"-"+node_variables.NODE_JS_ARCHITECTURE+"/", ""))
except Exception as e:
print("Error: "+traceback.format_exc())
finally:
DefineDosDevice(2, UNUSUED_DRIVE_LETTER, node_variables.NODE_JS_BINARIES_FOLDER_PLATFORM)
示例5: getPackageData
def getPackageData(self):
window = self.window
view = window.active_view()
selText = view.sel()[0]
xt = str(window.active_view().file_name())
scope = (view.scope_name(0).split(" ")[0].split(".")[1])
selected = view.substr(selText)
try:
if scope == "java":
sublime.status_message("LangDocs: Looking up package definition")
doc = getJavaPackDoc(selected)[0]
url = getJavaPackDoc(selected)[1]
if len(doc) > 2:
try:
doc = "<h1>%s documentation</h1><br>%s ... <br><br>Read more at: \"<a href=\"%s\">%s</a>\"" % (selected, doc, url, url)
view.show_popup("<style>%s</style>%s" % (css, doc), max_width=700,
on_navigate=lambda x:(webbrowser.open(url)))
except:
doc = "%s documentation\n\n%s ... \n\nRead more at: \"%s\"" % (selected, doc, url)
sublime.message_dialog(doc)
else:
sublime.status_message("LangDocs: Can't find documentation")
except:
sublime.status_message("LangDocs: Can't find documentation")
示例6: on_post_save
def on_post_save(self, view):
if not self.is_enabled(view):
return
compile_on_save = settings_get('compileOnSave', True)
if compile_on_save is True:
print("Compiling on save...")
view.run_command("compile")
show_compile_output_on_save = settings_get('showOutputOnSave', True)
if show_compile_output_on_save is True and isCoffee() is True and RunScriptCommand.PANEL_IS_OPEN is True:
print("Updating output panel...")
view.run_command("compile_output")
watch_save = settings_get('watchOnSave', True)
if watch_save:
viewID = view.id()
if viewID in watchers:
watchers[viewID].refresh()
if settings_get("checkSyntaxOnSave", True):
args = ['-b', '-p']
if isLitCoffee(view):
args = ['-l'] + args
res = brew(args, Text.get(view))
if res["okay"] is True:
sublime.status_message("Syntax is valid.")
else:
status = res["err"].split("\n")[0]
sublime.message_dialog('Syntax error: %s' % status)
if settings_get("lintOnSave", True):
view.run_command("lint")
示例7: run_async
def run_async(self):
short_hash = self.get_selected_short_hash()
if not short_hash:
return
if self.interface.entries[-1].short_hash == short_hash:
sublime.status_message("Unable to move last commit down.")
return
move_idx, to_move, entry_before_move = self.get_idx_entry_and_prev(short_hash)
commit_chain = [
self.ChangeTemplate(orig_hash=entry.long_hash,
move=entry.short_hash == short_hash,
do_commit=True,
msg=entry.raw_body,
datetime=entry.datetime,
author="{} <{}>".format(entry.author, entry.email))
for entry in self.interface.entries[move_idx:]
]
# Take the change to move and swap it with the one following.
commit_chain[0], commit_chain[1] = commit_chain[1], commit_chain[0]
try:
self.make_changes(commit_chain, "moved " + short_hash + " down", entry_before_move.long_hash)
move_cursor(self.view, 2)
except:
sublime.message_dialog("Unable to move commit, most likely due to a conflict.")
示例8: wrapper
def wrapper(self):
try:
return func(self, self.repository)
except (NotAGitRepositoryError, NotAGithubRepositoryError):
sublime.message_dialog("Github repository not found.")
except (NoFileOpenError):
sublime.message_dialog("Please open a file first.")
示例9: do_create
def do_create(self):
if len(self.w.folders()) == 0:
message = "Ensime project cannot be created, because you either don't have a Sublime project "
message += "or don't have any folders associated with your Sublime project."
message += "\n\n"
message += "To use Ensime you need to have an active non-empty project. "
message += "Sublime will now try to initialize a project for you. "
message += "\n\n"
message += "You will be shown a dialog that will let you select a root folder for the project. "
message += "After the root folder is selected, Sublime will create a configuration file in it. "
message += "Do you wish to proceed?"
if sublime.ok_cancel_dialog(message):
self.w.run_command("prompt_add_folder")
# if you don't do set_timeout, self.w.folders() won't be updated
sublime.set_timeout(self.post_prompt_add_folder, 0)
return
if len(self.w.folders()) > 1:
message = "A .ensime configuration file needs to be created in one of your project's folders."
message += "\n\n"
message += "Since you have multiple folders in the project, pick an appropriate folder in the dialog that will follow."
sublime.message_dialog(message)
if (len(self.w.folders())) == 1:
self.folder_selected(0)
else:
self.w.show_quick_panel(self.w.folders(), self.folder_selected)
示例10: run
def run(self, edit):
super(RubocopAutoCorrectCommand, self).run(edit)
cancel_op = self.user_wants_to_cancel()
if cancel_op:
return
view = self.view
path = view.file_name()
quoted_file_path = FileTools.quote(path)
if view.is_read_only():
sublime.message_dialog('RuboCop: Unable to run auto correction on a read only buffer.')
return
# Inform user about unsaved contents of current buffer
if view.is_dirty():
warn_msg = 'RuboCop: The curent buffer is modified. Save the file and continue?'
cancel_op = not sublime.ok_cancel_dialog(warn_msg)
if cancel_op:
return
else:
view.run_command('save')
RubocopEventListener.instance().clear_marks(view)
quoted_file_path = FileTools.quote(path)
# Run rubocop with auto-correction
self.runner.run(quoted_file_path, '-a')
sublime.status_message('RuboCop: Auto correction done.')
示例11: __init__
def __init__(self, subl_args, curdir, sdk_path, private_key):
super(CommandBuilder, self).__init__()
self.curdir = curdir
self.sdk_path = sdk_path
self.private_key = private_key
self.args = subl_args
self.flags = subl_args["flags"] if "flags" in subl_args else []
self.device = subl_args["device"] if "device" in subl_args and subl_args["device"] != "prompt" else False
self.do = subl_args["do"] if "do" in subl_args else "build"
if "sdk" in subl_args:
target_sdks = SDK(sdk_path).targetSDKs()
match = [x for x in target_sdks if subl_args["sdk"].replace(".x","") == ".".join(x.split(".")[:2])]
if len(match):
self.sdk = match[0]
else:
self.sdk = False
sublime.message_dialog("unsupported SDK target: {}".format(subl_args["sdk"],))
else:
self.sdk = False
# apps compile with monkeyc, barrels(modules) with barrelbuild
# so we need to know which we are dealing with
self.build_for = self.detect_app_vs_barrel()
示例12: run
def run(self, edit, action='compact'):
# Format all the code
if re.match(r'.*\.css$', self.view.file_name()) :
regx = '\}[ \t]*(?=[^\n]\S)|\}\s+(?=\n)'
rules1 = self.view.find_all(regx)
for x in rules1:
self.view.replace(edit, self.view.find(regx, x.a), "}\n")
# Format all the code End
rule_starts = self.view.find_all('\{')
rule_ends = self.view.find_all('\}')
if len(rule_starts) != len(rule_ends):
sublime.message_dialog("value not match!")
return
area = Ele.getArea(rule_starts, rule_ends)
rules_regions = list()
regions_to_process = list()
selections = self.view.sel()
if len(selections) == 1 and selections[0].empty():
selections = [sublime.Region(0, self.view.size())]
for i in range(len(area)):
rule_region = area[i]
rules_regions.append(rule_region)
for sel in selections:
if sel.intersects(rule_region):
regions_to_process.append(rule_region)
break
regions_to_process.reverse()
self.process_rules_regions(regions_to_process, action, edit)
示例13: run
def run(self):
listitems = []
self.nodes = []
labels = []
label_ids = []
regexs = [r"\$LOCALIZE\[([0-9].*?)\]", r"\$ADDON\[.*?([0-9].*?)\]", r"(?:label|property|altlabel|label2)>([0-9].*?)<"]
view = self.window.active_view()
path = view.file_name()
for po_file in INFOS.po_files:
labels += [s.msgid for s in po_file]
label_ids += [s.msgctxt for s in po_file]
# view.substr(sublime.Region(0, view.size()))
with open(path, encoding="utf8") as f:
for i, line in enumerate(f.readlines()):
for regex in regexs:
for match in re.finditer(regex, line):
label_id = "#" + match.group(1)
if label_id in label_ids:
index = label_ids.index(label_id)
listitems.append("%s (%s)" % (labels[index], label_id))
node = {"file": path,
"line": i + 1}
self.nodes.append(node)
if listitems:
self.window.show_quick_panel(listitems, lambda s: self.on_done(s), selected_index=0, on_highlight=lambda s: self.show_preview(s))
else:
sublime.message_dialog("No references found")
示例14: delayed_settings_restore
def delayed_settings_restore():
if type == 'upgrade' and package in self.old_syntaxes:
for view_syntax in self.old_syntaxes[package]:
view, syntax = view_syntax
view.settings().set('syntax', syntax)
if type == 'upgrade' and package in self.old_color_schemes:
for view_scheme in self.old_color_schemes[package]:
view, scheme = view_scheme
view.settings().set('color_scheme', scheme)
if type == 'upgrade' and self.old_theme_package == package:
settings.set('theme', self.old_theme)
sublime.message_dialog(text.format(
u'''
Package Control
Your active theme was just upgraded. You may see some
graphical corruption until you restart Sublime Text.
'''
))
if type == 'upgrade' and self.old_color_scheme_package == package:
settings.set('color_scheme', self.old_color_scheme)
sublime.save_settings(preferences_filename())
示例15: show_results
def show_results(self, search_value=''):
# TODO: paging?
if search_value:
search_result = self.do_search(search_value)
if search_result:
text = ''
while True:
try:
hit = search_result.next()
if hit:
text += self.get_block(hit)
except StopIteration:
break
if text:
self.view = sublime.active_window().new_file()
# TODO: view set attrs in utils..
syntax_file = mw.get_setting('syntax')
self.view.set_syntax_file(syntax_file)
self.view.set_name('Wiki search results: %s' % search_value)
self.view.run_command(mw.cmd('insert_text'), {'position': 0, 'text': text})
elif search_value:
sublime.message_dialog('No results for: %s' % search_value)