本文整理汇总了Python中console.alert方法的典型用法代码示例。如果您正苦于以下问题:Python console.alert方法的具体用法?Python console.alert怎么用?Python console.alert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类console
的用法示例。
在下文中一共展示了console.alert方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: update_youtubedl
# 需要导入模块: import console [as 别名]
# 或者: from console import alert [as 别名]
def update_youtubedl(sender):
if os.path.exists(youtubedl_location+youtubedl_dir):
msg = 'Are you sure you want to update youtubedl exists in site-packages and will be overwritten'
if not console.alert('Continue',msg,'OK'):
return
console.show_activity('Downloading')
file = downloadfile(youtubedl_downloadurl)
console.show_activity('Extracting')
process_file(file)
console.show_activity('Moving')
if os.path.exists(youtubedl_location+youtubedl_dir):
shutil.rmtree(youtubedl_location+youtubedl_dir)
shutil.move(youtubedl_unarchive_location+youtubedl_dir, youtubedl_location+youtubedl_dir)
console.show_activity('Cleaning Up Download Files')
shutil.rmtree(youtubedl_unarchive_location)
os.remove(file)
console.show_activity('Making youtube-dl friendly')
process_youtubedl_for_pythonista()
console.hide_activity()
示例2: main
# 需要导入模块: import console [as 别名]
# 或者: from console import alert [as 别名]
def main():
if os.path.exists(NAME + ".py"):
console.alert("Failed to Extract", NAME + ".py already exists.")
return
if os.path.exists(NAME + ".pyui"):
console.alert("Failed to Extract", NAME + ".pyui already exists.")
return
with open(NAME + ".py", "w") as f:
f.write(fix_quotes_out(PYFILE))
with open(NAME + ".pyui", "w") as f:
f.write(fix_quotes_out(PYUIFILE))
msg = NAME + ".py and " + NAME + ".pyui were successfully extracted!"
console.alert("Extraction Successful", msg, "OK", hide_cancel_button=True)
示例3: main
# 需要导入模块: import console [as 别名]
# 或者: from console import alert [as 别名]
def main():
import sys
if len(sys.argv) > 1: # pack files specified via argv
arg = ' '.join(sys.argv[1:])
try:
pack(arg)
except IOError as err:
print("Failed to pack program: " + err.message)
else: # display prompt for file
import console
msg = "Enter path (relative to current directory) of the application to be packaged, without .py or .pyui suffixes."
arg = console.input_alert("Package UI Application", msg)
try:
pack(arg)
except IOError as err:
console.alert("Failed to pack", err.message)
return
msg = "Application was successfully packaged into {}.uipack.py!".format(arg)
console.alert("Packaging Successful", msg, "OK", hide_cancel_button=True)
示例4: show_messages
# 需要导入模块: import console [as 别名]
# 或者: from console import alert [as 别名]
def show_messages(self):
"""shows some warnings and tips."""
console.alert(
"Info",
"If StaSh does not launch anymore after you changed the config, run the 'launch_stash.py' script with \n'--no-cfgfile'.",
"Ok",
hide_cancel_button=True,
)
while True:
self.wait_modal()
if not self.subview_open:
break
console.alert(
"Info",
"Some changes may only be visible after restarting StaSh and/or Pythonista.",
"Ok",
hide_cancel_button=True,
)
# data source and delegate functions. see docs
示例5: tableview_did_select
# 需要导入模块: import console [as 别名]
# 或者: from console import alert [as 别名]
def tableview_did_select(self, tv, section, row):
# deselect row
tv.selected_row = (-1, -1)
sn = SECTIONS[section]
info = OPTIONS[sn][row]
otype = info["type"]
if otype == TYPE_LABEL:
# show content
console.alert(info.get("display_name", ""), info.get("value", ""), "Ok", hide_cancel_button=True)
else:
# show description
console.alert(
info.get("display_name",
""),
info.get("description",
"No description available."),
"Ok",
hide_cancel_button=True
)
示例6: more
# 需要导入模块: import console [as 别名]
# 或者: from console import alert [as 别名]
def more(filenames, pagesize=10, clear=False, fmt='{line}'):
'''Display content of filenames pagesize lines at a time (cleared if specified) with format fmt for each output line'''
fileinput.close() # in case still open
try:
pageno = 1
if clear:
clear_screen()
for line in fileinput.input(filenames, openhook=fileinput.hook_encoded("utf-8")):
lineno, filename, filelineno = fileinput.lineno(), fileinput.filename(), fileinput.filelineno()
print(fmt.format(**locals()), end='')
if pagesize and lineno % pagesize == 0:
console.alert('Abort or continue', filename, 'Next page') # TODO: use less intrusive mechanism than alert
pageno += 1
if clear:
clear_screen()
finally:
fileinput.close()
# --- main
示例7: _drop_file
# 需要导入模块: import console [as 别名]
# 或者: from console import 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
示例8: _install
# 需要导入模块: import console [as 别名]
# 或者: from console import alert [as 别名]
def _install(prerelease=False):
release = _get_latest_release(prerelease)
if not release:
_error('Unable to find latest release')
return
_local_installation_exists(release)
path = _download_release_zip(release)
extracted_zip_dir = _extract_release(release, path)
_move_to_site_packages(extracted_zip_dir)
_save_release_info(release)
_cleanup()
_info('Black Mamba {} installed'.format(_get_version(release)))
console.alert(
'Black Mamba {} Installed'.format(_get_version(release)),
'Pythonista RESTART is required for changes to take effect.',
'Got it!', hide_cancel_button=True
)
示例9: run
# 需要导入模块: import console [as 别名]
# 或者: from console import alert [as 别名]
def run(self, input=''):
np = self.get_param_by_name('VariableName')
name = np.value or console.input_alert('Please enter Variable name')
rv = self.get_param_by_name('fm:runtime_variables')
if not name in rv.value:
rv.value[name] = None
if rv.value[name] == None:
rv.value[name] = copy.deepcopy(input)
else:
if input.type == rv.value[name].type:
if not isinstance(rv.value[name].value,list):
t = copy.deepcopy(rv.value[name].value)
rv.value[name].value = []
rv.value[name].value.append(copy.deepcopy(t))
if input.isList:
for i in input.value:
rv.value[name].value.append(copy.deepcopy(i))
else:
rv.value[name].value.append(copy.deepcopy(input.value))
else:
console.alert('Error','Incorrect type to append to variable',button1='Ok',hide_cancel_button=True)
self.status = 'complete'
示例10: run
# 需要导入模块: import console [as 别名]
# 或者: from console import alert [as 别名]
def run(self, input=''):
mapmodeparam = self.get_param_by_name('mapmode')
viewsparam = self.get_param_by_name('viewmode')
zoomparam = self.get_param_by_name('zoom')
queryparam = self.get_param_by_name('query')
url = 'comgooglemaps://?center={latitude},{longitude}'.format(**input.value)
if mapmodeparam.value:
url += '&mapmode='+ mapmodeparam.value
if viewsparam.value:
url += '&views=' + viewsparam.value
if zoomparam.value:
url += '&zoom=' + zoomparam.value
if queryparam.value:
url += '&q=' + queryparam.value
uia = ObjCClass('UIApplication').sharedApplication()
if not uia.openURL_(nsurl(url)):
console.alert(title='Error oppening App',message='Is Google Maps app installed?',button1='Ok',hide_cancel_button=True)
self.status = 'complete'
示例11: restore_youtubedl_backup
# 需要导入模块: import console [as 别名]
# 或者: from console import alert [as 别名]
def restore_youtubedl_backup(sender):
if not os.path.isdir(backup_location) or not os.listdir(backup_location):
console.alert('Nothing to do', 'No backups found to restore')
else:
folders = os.listdir(backup_location)
folder = folders[len(folders)-1]
shutil.move(backup_location+folder,youtubedl_location+youtubedl_dir)
console.alert('Success','Successfully restored '+folder)
示例12: toggle
# 需要导入模块: import console [as 别名]
# 或者: from console import alert [as 别名]
def toggle():
try:
if os.path.islink(_ROOT_FOLDER):
console.alert('Black Mamba',
'Switch to installer version?',
'OK')
switch_to_installer()
else:
console.alert('Black Mamba',
'Switch to Working Copy version?',
'OK')
switch_to_working_copy()
except Exception:
pass
示例13: _drop_folder
# 需要导入模块: import console [as 别名]
# 或者: from console import alert [as 别名]
def _drop_folder(data_ptr, path):
try:
if os.path.exists(path):
console.alert(
'{} exists'.format(os.path.basename(path)),
'Do you want to replace existing {}?'.format(
'folder' if os.path.isdir(path) else 'file'
),
'Replace'
)
if os.path.isfile(path):
os.remove(path)
else:
shutil.rmtree(path)
data = ObjCInstance(data_ptr)
zip_data = io.BytesIO(ctypes.string_at(data.bytes(), data.length()))
zf = zipfile.ZipFile(zip_data)
corrupted_file = zf.testzip()
if corrupted_file:
console.hud_alert('Corrupted ZIP file', 'error')
zf.extractall(os.path.dirname(path))
_datasource.reload_path(os.path.dirname(path))
console.hud_alert('{} dropped'.format(os.path.basename(path)))
except KeyboardInterrupt:
pass
示例14: _local_installation_exists
# 需要导入模块: import console [as 别名]
# 或者: from console import alert [as 别名]
def _local_installation_exists(release):
_info('Checking Black Mamba installation...')
if os.path.islink(_TARGET_DIR):
_terminate('Skipping, Black Mamba symlinked to site-packages-3')
local_version = None
try:
import blackmamba
local_version = blackmamba.__version__
_info('Black Mamba {} installed'.format(local_version))
except ImportError:
_info('Black Mamba not installed')
if local_version is not None:
remote_version = _get_version(release)
try:
if remote_version == local_version:
console.alert(
'Black Mamba Installer',
'Black Mamba {} installed. Do you want to replace it with {}?'.format(local_version, remote_version),
'Replace'
)
else:
console.alert(
'Black Mamba Installer',
'Black Mamba {} installed. Do you want to update it to {}?'.format(local_version, remote_version),
'Update'
)
except KeyboardInterrupt:
_terminate('Cancelling installation on user request')
示例15: saveflow
# 需要导入模块: import console [as 别名]
# 或者: from console import alert [as 别名]
def saveflow(self,sender):
if self.flow_creation_view.data_source.title == '':
console.alert(title='Error',message='Please enter a title',button1='Ok',hide_cancel_button=True)
else:
self.selectedFlowType = self.flow_creation_view.data_source.flowType
self.flow_manager.save_flow(self.flow_creation_view.data_source.title, self.selectedElements, self.selectedFlowType)
console.alert(title='Success',message='Flow has been saved',button1='Ok',hide_cancel_button=True)
self.get_flows(appex.is_running_extension())
self.flow_view.data_source.flows = self.flows
self.flow_view.reload_data()