本文整理汇总了Python中bpy.app方法的典型用法代码示例。如果您正苦于以下问题:Python bpy.app方法的具体用法?Python bpy.app怎么用?Python bpy.app使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类bpy
的用法示例。
在下文中一共展示了bpy.app方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: updater_run_success_popup_handler
# 需要导入模块: import bpy [as 别名]
# 或者: from bpy import app [as 别名]
def updater_run_success_popup_handler(scene):
global ran_update_sucess_popup
ran_update_sucess_popup = True
# in case of error importing updater
if updater.invalidupdater == True:
return
try:
bpy.app.handlers.scene_update_post.remove(
updater_run_success_popup_handler)
except:
pass
atr = addon_updater_updated_successful.bl_idname.split(".")
getattr(getattr(bpy.ops, atr[0]),atr[1])('INVOKE_DEFAULT')
示例2: background_update_callback
# 需要导入模块: import bpy [as 别名]
# 或者: from bpy import app [as 别名]
def background_update_callback(update_ready):
"""Passed into the updater, background thread updater"""
global ran_autocheck_install_popup
# in case of error importing updater
if updater.invalidupdater == True:
return
if updater.showpopups == False:
return
if update_ready != True:
return
if updater_run_install_popup_handler not in \
bpy.app.handlers.scene_update_post and \
ran_autocheck_install_popup==False:
bpy.app.handlers.scene_update_post.append(
updater_run_install_popup_handler)
ran_autocheck_install_popup = True
示例3: updater_run_success_popup_handler
# 需要导入模块: import bpy [as 别名]
# 或者: from bpy import app [as 别名]
def updater_run_success_popup_handler(scene):
global ran_update_sucess_popup
ran_update_sucess_popup = True
# in case of error importing updater
if updater.invalidupdater == True:
return
try:
if "scene_update_post" in dir(bpy.app.handlers):
bpy.app.handlers.scene_update_post.remove(
updater_run_success_popup_handler)
else:
bpy.app.handlers.depsgraph_update_post.remove(
updater_run_success_popup_handler)
except:
pass
atr = addon_updater_updated_successful.bl_idname.split(".")
getattr(getattr(bpy.ops, atr[0]),atr[1])('INVOKE_DEFAULT')
示例4: bv28
# 需要导入模块: import bpy [as 别名]
# 或者: from bpy import app [as 别名]
def bv28():
"""Check if blender 2.8, for layouts, UI, and properties. """
global BV_IS_28
if not BV_IS_28:
BV_IS_28 = hasattr(bpy.app, "version") and bpy.app.version >= (2, 80)
return BV_IS_28
示例5: make_annotations
# 需要导入模块: import bpy [as 别名]
# 或者: from bpy import app [as 别名]
def make_annotations(cls):
"""Add annotation attribute to class fields to avoid Blender 2.8 warnings"""
if not hasattr(bpy.app, "version") or bpy.app.version < (2, 80):
return cls
bl_props = {k: v for k, v in cls.__dict__.items() if isinstance(v, tuple)}
if bl_props:
if '__annotations__' not in cls.__dict__:
setattr(cls, '__annotations__', {})
annotations = cls.__dict__['__annotations__']
for k, v in bl_props.items():
annotations[k] = v
delattr(cls, k)
return cls
示例6: layout_split
# 需要导入模块: import bpy [as 别名]
# 或者: from bpy import app [as 别名]
def layout_split(layout, factor=0.0, align=False):
"""Intermediate method for pre and post blender 2.8 split UI function"""
if not hasattr(bpy.app, "version") or bpy.app.version < (2, 80):
return layout.split(percentage=factor, align=align)
return layout.split(factor=factor, align=align)
示例7: updater_run_install_popup_handler
# 需要导入模块: import bpy [as 别名]
# 或者: from bpy import app [as 别名]
def updater_run_install_popup_handler(scene):
global ran_autocheck_install_popup
ran_autocheck_install_popup = True
# in case of error importing updater
if updater.invalidupdater == True:
return
try:
bpy.app.handlers.scene_update_post.remove(
updater_run_install_popup_handler)
except:
pass
if "ignore" in updater.json and updater.json["ignore"] == True:
return # don't do popup if ignore pressed
# elif type(updater.update_version) != type((0,0,0)):
# # likely was from master or another branch, shouldn't trigger popup
# updater.json_reset_restore()
# return
elif "version_text" in updater.json and "version" in updater.json["version_text"]:
version = updater.json["version_text"]["version"]
ver_tuple = updater.version_tuple_from_text(version)
if ver_tuple < updater.current_version:
# user probably manually installed to get the up to date addon
# in here. Clear out the update flag using this function
if updater.verbose:
print("{} updater: appears user updated, clearing flag".format(\
updater.addon))
updater.json_reset_restore()
return
atr = addon_updater_install_popup.bl_idname.split(".")
getattr(getattr(bpy.ops, atr[0]),atr[1])('INVOKE_DEFAULT')
示例8: showReloadPopup
# 需要导入模块: import bpy [as 别名]
# 或者: from bpy import app [as 别名]
def showReloadPopup():
"""For use in register only, to show popup after re-enabling the addon
Must be enabled by developer
"""
if updater.invalidupdater == True:
return
saved_state = updater.json
global ran_update_sucess_popup
a = saved_state != None
b = "just_updated" in saved_state
c = saved_state["just_updated"]
if a and b and c:
updater.json_reset_postupdate() # so this only runs once
# no handlers in this case
if updater.auto_reload_post_update == False: return
if updater_run_success_popup_handler not in \
bpy.app.handlers.scene_update_post \
and ran_update_sucess_popup==False:
bpy.app.handlers.scene_update_post.append(
updater_run_success_popup_handler)
ran_update_sucess_popup = True
# -----------------------------------------------------------------------------
# Example UI integrations
# -----------------------------------------------------------------------------
示例9: bv28
# 需要导入模块: import bpy [as 别名]
# 或者: from bpy import app [as 别名]
def bv28():
"""Check if blender 2.8, for layouts, UI, and properties. """
global BV_IS_28
if not BV_IS_28:
BV_IS_28 = hasattr(bpy.app, "version") and bpy.app.version >= (2, 80)
return BV_IS_28
示例10: updater_run_install_popup_handler
# 需要导入模块: import bpy [as 别名]
# 或者: from bpy import app [as 别名]
def updater_run_install_popup_handler(scene):
global ran_autocheck_install_popup
ran_autocheck_install_popup = True
# in case of error importing updater
if updater.invalidupdater == True:
return
try:
if "scene_update_post" in dir(bpy.app.handlers):
bpy.app.handlers.scene_update_post.remove(
updater_run_install_popup_handler)
else:
bpy.app.handlers.depsgraph_update_post.remove(
updater_run_install_popup_handler)
except:
pass
if "ignore" in updater.json and updater.json["ignore"] == True:
return # don't do popup if ignore pressed
# elif type(updater.update_version) != type((0,0,0)):
# # likely was from master or another branch, shouldn't trigger popup
# updater.json_reset_restore()
# return
elif "version_text" in updater.json and "version" in updater.json["version_text"]:
version = updater.json["version_text"]["version"]
ver_tuple = updater.version_tuple_from_text(version)
if ver_tuple < updater.current_version:
# user probably manually installed to get the up to date addon
# in here. Clear out the update flag using this function
if updater.verbose:
print("{} updater: appears user updated, clearing flag".format(\
updater.addon))
updater.json_reset_restore()
return
atr = addon_updater_install_popup.bl_idname.split(".")
getattr(getattr(bpy.ops, atr[0]),atr[1])('INVOKE_DEFAULT')
示例11: background_update_callback
# 需要导入模块: import bpy [as 别名]
# 或者: from bpy import app [as 别名]
def background_update_callback(update_ready):
"""Passed into the updater, background thread updater"""
global ran_autocheck_install_popup
# in case of error importing updater
if updater.invalidupdater == True:
return
if updater.showpopups == False:
return
if update_ready != True:
return
# see if we need add to the update handler to trigger the popup
handlers = []
if "scene_update_post" in dir(bpy.app.handlers): # 2.7x
handlers = bpy.app.handlers.scene_update_post
else: # 2.8x
handlers = bpy.app.handlers.depsgraph_update_post
in_handles = updater_run_install_popup_handler in handlers
if in_handles or ran_autocheck_install_popup:
return
if "scene_update_post" in dir(bpy.app.handlers): # 2.7x
bpy.app.handlers.scene_update_post.append(
updater_run_install_popup_handler)
else: # 2.8x
bpy.app.handlers.depsgraph_update_post.append(
updater_run_install_popup_handler)
ran_autocheck_install_popup = True
示例12: make_annotations
# 需要导入模块: import bpy [as 别名]
# 或者: from bpy import app [as 别名]
def make_annotations(cls):
if not hasattr(bpy.app, "version") or bpy.app.version < (2, 80):
return cls
bl_props = {k: v for k, v in cls.__dict__.items() if isinstance(v, tuple)}
if bl_props:
if '__annotations__' not in cls.__dict__:
setattr(cls, '__annotations__', {})
annotations = cls.__dict__['__annotations__']
for k, v in bl_props.items():
annotations[k] = v
delattr(cls, k)
return cls
示例13: layout_split
# 需要导入模块: import bpy [as 别名]
# 或者: from bpy import app [as 别名]
def layout_split(layout, factor=0.0, align=False):
if not hasattr(bpy.app, "version") or bpy.app.version < (2, 80):
return layout.split(percentage=factor, align=align)
return layout.split(factor=factor, align=align)
示例14: get_update_post
# 需要导入模块: import bpy [as 别名]
# 或者: from bpy import app [as 别名]
def get_update_post():
if hasattr(bpy.app.handlers, 'scene_update_post'):
return bpy.app.handlers.scene_update_post
else:
return bpy.app.handlers.depsgraph_update_post
示例15: execute
# 需要导入模块: import bpy [as 别名]
# 或者: from bpy import app [as 别名]
def execute(self, context):
if Updater.invalidupdater is True:
return {'CANCELLED'}
if Updater.async_checking is True and Updater.error is None:
return {'CANCELLED'}
settings = get_user_preferences(context)
if not settings:
if Updater.verbose:
print("Could not get {} preferences, update check skipped".format(__package__))
return {'CANCELLED'}
Updater.set_check_interval(enable=settings.auto_check_update,
months=settings.updater_intrval_months,
days=settings.updater_intrval_days,
hours=settings.updater_intrval_hours,
minutes=settings.updater_intrval_minutes)
Updater.check_for_update_now(ui_refresh)
try:
import pip
call([bpy.app.binary_path_python, '-m', 'pip', 'install', 'pip', '--user', '--upgrade'], shell=True)
call([bpy.app.binary_path_python, '-m', 'pip', 'install', 'Pillow', '--user', '--upgrade'], shell=True)
except ImportError:
call([bpy.app.binary_path_python, os.path.join(os.path.dirname(os.path.abspath(__file__)), 'operators',
'get-pip.py'), '--user'], shell=True)
call([bpy.app.binary_path_python, '-m', 'pip', 'install', 'Pillow', '--user', '--upgrade'], shell=True)
return {'FINISHED'}