本文整理汇总了Python中console.hud_alert方法的典型用法代码示例。如果您正苦于以下问题:Python console.hud_alert方法的具体用法?Python console.hud_alert怎么用?Python console.hud_alert使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类console
的用法示例。
在下文中一共展示了console.hud_alert方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: load
# 需要导入模块: import console [as 别名]
# 或者: from console import hud_alert [as 别名]
def load(self):
self.app.activity_indicator.start()
try:
self.categories_dict = self.app.repo.get_categories()
categories_listdatasource = ui.ListDataSource(
{'title': category_name, 'accessory_type': 'disclosure_indicator'}
for category_name in sorted(self.categories_dict.keys())
)
categories_listdatasource.action = self.category_item_tapped
categories_listdatasource.delete_enabled = False
self.view.data_source = categories_listdatasource
self.view.delegate = categories_listdatasource
self.view.reload()
except Exception as e:
console.hud_alert('Failed to load Categories', 'error', 1.0)
finally:
self.app.activity_indicator.stop()
示例2: main
# 需要导入模块: import console [as 别名]
# 或者: from console import hud_alert [as 别名]
def main(args):
if args:
name = args[0]
else:
sel = editor.get_selection() or ""
seltxt = preformat(editor.get_text()[sel[0]:sel[1]])
if sel and sel[0] != sel[1] and is_valid_name(seltxt):
name = seltxt
else:
name = console.input_alert("Find Module")
try:
loc = find_path(name)
except ValueError:
console.hud_alert(name + " is not a valid module name", "error")
return
if loc == "<built-in>":
console.hud_alert(name + " is a built-in module", "error")
elif loc == "<string>":
console.hud_alert("Could not find module " + name, "error")
else:
editor.open_file(os.path.relpath(loc, DOCS))
示例3: _show_results
# 需要导入模块: import console [as 别名]
# 或者: from console import hud_alert [as 别名]
def _show_results(attrib, all_passed=True):
x = {
'errors': 'errored',
'failures': 'failed',
'skips': 'skipped'
}
tests = int(attrib.get('tests', 0))
time = attrib.get('time', '?')
messages = []
for k, v in x.items():
c = int(attrib.get(k, 0))
if c > 0:
tests -= c
messages.append('{} {}'.format(c, v))
messages.append('{} passed'.format(tests))
console.hud_alert(
', '.join(messages) + ' in {} seconds'.format(time),
'success' if all_passed else 'error',
_hud_alert_delay())
示例4: _drop_file
# 需要导入模块: import console [as 别名]
# 或者: from console import hud_alert [as 别名]
def _drop_file(data_ptr, path):
try:
if os.path.exists(path):
console.alert(
'{} exists'.format(os.path.basename(path)),
'Do you want to replace existing file?',
'Replace'
)
data = ObjCInstance(data_ptr)
if not data.writeToFile_atomically_(ns(path), True):
console.hud_alert('Failed to write file', 'error')
return
console.hud_alert('{} dropped'.format(os.path.basename(path)))
except KeyboardInterrupt:
pass
示例5: main
# 需要导入模块: import console [as 别名]
# 或者: from console import hud_alert [as 别名]
def main(mock):
import libfuturize.main
path = editor.get_path()
if not path or not path.endswith('.py'):
console.hud_alert('Not a Python file', 'error')
return
tab.save()
args = ['-1', '-n', '-w', '--all-imports', '--add-suffix', _SUFFIX, path]
result = libfuturize.main.main(args)
if result == 0 and _replace_file_content(path):
console.hud_alert('Futurized')
else:
console.hud_alert('Failed to futurize', 'error')
示例6: tableview_did_select
# 需要导入模块: import console [as 别名]
# 或者: from console import hud_alert [as 别名]
def tableview_did_select(self, tableview, section, row):
try:
if os.path.isdir(self.files[row]):
self.prev_path = os.path.abspath('.')
os.chdir(self.files[row])
self.files= []
self.files.append('..')
for file in os.listdir('.'):
if self.filetypes == '*' or self.is_correct_file_type(file) or os.path.isdir(file):
self.files.append(file)
tableview.reload()
else:
self.cb(path=self.files[row])
except OSError :
console.hud_alert('Not Allowed')
os.chdir(self.prev_path)
self.files= []
self.files.append('..')
for file in os.listdir('.'):
if self.filetypes == '*' or self.is_correct_file_type(file) or os.path.isdir(file):
self.files.append(file)
tableview.reload()
示例7: tableview_did_select
# 需要导入模块: import console [as 别名]
# 或者: from console import hud_alert [as 别名]
def tableview_did_select(self, tableview, section, row):
'@type tableview: ui.TableView'
if section == 0:
dir = os.path.normpath(os.path.join(self.dir, self.data[section][row]))
if os.path.exists(dir):
try:
def setme(value):
# set and bubble up setters
self.sel[0]=value
if self.setter is not None:
self.setter(value)
newv = FileViewer(setter=setme,base_dir=dir)
nav = tableview.superview.navigation_view
nav.push_view(newv)
except StopIteration:
console.hud_alert('Folder not accessible','error')
else:
# print self.dir, self.data[section][row]
self.sel[0] = os.path.join(self.dir, self.data[section][row])
tableview.superview.navigation_view.close()
if self.setter is not None:
self.setter(self.sel[0])
示例8: end_game
# 需要导入模块: import console [as 别名]
# 或者: from console import hud_alert [as 别名]
def end_game(self):
self.game_state = GAME_DEAD
self.player.velocity = Point(0, 0)
death_loc = self.player.frame.center()
death_loc.y = max(death_loc.y, 80)
self.player.die()
del self.player
self.player = None
score = int(self.climb / 10)
if self.high_scores.is_high_score(player_name, score):
self.smoke_special.frame.center(death_loc)
self.smoke_special.configure(frame_count=0, is_done=False)
#console.hud_alert('New high score!') # for debugging purposes
run_in_thread(high_score_sounds)
fmt = 'Congratulations {}:\nYou have a new high score!'
self.high_score_msg = fmt.format(player_name)
else:
self.smoke_normal.frame.center(death_loc)
self.smoke_normal.configure(frame_count=0, is_done=False)
示例9: did_select_repo
# 需要导入模块: import console [as 别名]
# 或者: from console import hud_alert [as 别名]
def did_select_repo(self,sender):
self.g=self._get_repo()
try:
self.g.head
except KeyError:
def fixHEAD(sender):
self._repo().refs.set_symbolic_ref('HEAD', 'refs/heads/'+branch)
self.confirm(fixHEAD,'No HEAD found. set to master?')
if self.g:
r.view['branch'].text=self.g.active_branch
author,author_email=self._get_last_committer()
self.view['user'].text=author
self.view['email'].text=author_email
remote, remote_branch=self.remote_for_head()
if not remote:
remote=self.remotes_iterator().next()
self.view['remote'].text=remote
self.view['remotebranch'].text=remote_branch
else:
console.hud_alert('No repo found at {}. create new repo, or clone'.format(self.view['repo'].text))
r.view['branch'].text=''
self.g=None
self.refresh()
示例10: pull
# 需要导入模块: import console [as 别名]
# 或者: from console import hud_alert [as 别名]
def pull(self):
repo = self._get_repo()
remote=self.view['remote'].text
if remote in self.remotes_iterator():
uri=repo.remotes.get(remote,'')
else:
print remote, 'adding'
uri=remote
#Set the origin
config = repo.repo.get_config()
config.set(('remote','origin'),'url',uri)
config.write_to_path()
repo.pull(origin_uri=uri)
console.hud_alert('pulled from ',remote)
self.refresh()
示例11: category_item_tapped
# 需要导入模块: import console [as 别名]
# 或者: from console import hud_alert [as 别名]
def category_item_tapped(self, sender):
self.app.activity_indicator.start()
try:
category_name = sender.items[sender.selected_row]['title']
category_url = self.categories_dict[category_name]['url']
tools_table = ToolsTable(self.app, category_name, category_url)
self.app.nav_view.push_view(tools_table.view)
except Exception as e:
console.hud_alert('Failed to load tools list', 'error', 1.0)
finally:
self.app.activity_indicator.stop()
示例12: _install
# 需要导入模块: import console [as 别名]
# 或者: from console import hud_alert [as 别名]
def _install(self, btn):
self.activity_indicator.start()
install_path = PythonistaToolsInstaller.get_install_path()
target_folder = PythonistaToolsInstaller.get_target_folder(btn.category_name,
btn.tool_name)
try:
if self.gist_installer.get_gist_id(btn.tool_url):
if not os.path.exists(target_folder):
os.makedirs(target_folder)
self.gist_installer.install(btn.tool_url, target_folder)
elif self.github_installer.get_github_user_repo(btn.tool_url):
if not os.path.exists(target_folder):
os.makedirs(target_folder)
self.github_installer.install(btn.tool_url, target_folder)
else: # any other url types, including iTunes
webbrowser.open(btn.tool_url)
btn.set_state_uninstall()
console.hud_alert('%s installed at %s' % (btn.tool_name, install_path), 'success', 1.0)
except Exception as e:
# clean up the directory
if os.path.exists(target_folder):
shutil.rmtree(target_folder)
btn.set_state_install() # revert the state
# Display some debug messages
etype, evalue, tb = sys.exc_info()
sys.stderr.write('%s\n' % repr(e))
import traceback
traceback.print_exception(etype, evalue, tb)
console.hud_alert('Installation failed', 'error', 1.0)
finally:
self.activity_indicator.stop()
示例13: uninstall
# 需要导入模块: import console [as 别名]
# 或者: from console import hud_alert [as 别名]
def uninstall(self, btn, sender):
target_folder = PythonistaToolsInstaller.get_target_folder(btn.category_name,
btn.tool_name)
if os.path.exists(target_folder):
shutil.rmtree(target_folder)
btn.set_state_install()
console.hud_alert('%s uninstalled' % btn.tool_name, 'success', 1.0)
示例14: _get_event_store
# 需要导入模块: import console [as 别名]
# 或者: from console import hud_alert [as 别名]
def _get_event_store():
global _event_store
if has_access():
if _event_store is None:
_event_store = EKEventStore.alloc().init()
return _event_store
elif authorization_not_yet_determined():
request_access()
return _get_event_store()
elif access_denied():
console.hud_alert('Access to calendar denied. open settings to allow')
else:
return None
示例15: main
# 需要导入模块: import console [as 别名]
# 或者: from console import hud_alert [as 别名]
def main(args):
try:
# Source and destination are passed via runtime args
src, dest = args
except (TypeError, ValueError):
# Get source and destination from user
curfile = os.path.relpath(editor.get_path() or "", DOCUMENTS)
shortsrc = console.input_alert(
"Source Name", # title
"Path is relative to Script Library root", # message
curfile, # input
)
src = os.path.join(DOCUMENTS, shortsrc)
if not os.path.exists(src):
console.hud_alert("Source file does not exist", "error")
sys.exit(1)
dest = os.path.join(DOCUMENTS, console.input_alert(
"Destination Name", # title
"Path is relative to Script Library root", # message
shortsrc, # input
))
else:
# Process source and destination from runtime args
src, dest = os.path.join(DOCUMENTS, src), os.path.join(DOCUMENTS, dest)
if not os.path.exists(src):
console.hud_alert("Source file does not exist", "error")
sys.exit(1)
if os.path.exists(dest):
console.hud_alert("Destination file already exists", "error")
sys.exit(1)
os.rename(src, dest)
sys.exit(0)