Skip to content

Instantly share code, notes, and snippets.

@sambler
Created January 15, 2016 16:58
Show Gist options
  • Save sambler/85a1af9daec2c6a76996 to your computer and use it in GitHub Desktop.
Save sambler/85a1af9daec2c6a76996 to your computer and use it in GitHub Desktop.
# made in response to
# http://blender.stackexchange.com/q/44983/935
bl_info = {
"version": (1, 0),
"blender": (2, 75, 0),
"name": "testing play pause",
"description": """testing addon""" ,
"category": "test",
}
import bpy
class playStuff(bpy.types.Operator):
"""Play/Pause sound"""
bl_idname = "scene.play"
bl_label = "Play stuff"
def execute(self, context):
context.scene.is_playing = not context.scene.is_playing
return {'FINISHED'}
def play_panel_draw(context, layout):
scn = context.scene
row = layout.row()
row.operator("scene.play", text="", icon='PLAY' if not scn.is_playing else 'PAUSE')
class playPausePanel(bpy.types.Panel):
bl_label = "Play/Pause"
bl_idname = "SCENE_PT_play"
bl_space_type = 'VIEW_3D'
bl_region_type = 'UI'
def draw(self, context):
play_panel_draw(context, self.layout)
def register():
bpy.types.Scene.is_playing = bpy.props.BoolProperty()
bpy.utils.register_class(playStuff)
bpy.utils.register_class(playPausePanel)
def unregister():
bpy.utils.unregister_class(playPausePanel)
bpy.utils.unregister_class(playStuff)
del bpy.types.Scene.is_playing
if __name__ == "__main__":
register()
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following disclaimer
# in the documentation and/or other materials provided with the
# distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment