Skip to content

Instantly share code, notes, and snippets.

@p2or
Forked from sambler/playPausePanel.py
Created January 15, 2016 17:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save p2or/d8e026e7d76aa7414100 to your computer and use it in GitHub Desktop.
Save p2or/d8e026e7d76aa7414100 to your computer and use it in GitHub Desktop.
PlayPause panel #Blender
# 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.
#
@p2or
Copy link
Author

p2or commented Feb 5, 2021

context.scene.is_playing ^=True

Hi @1C0D. Yeah, does the same thing, just personal preference (readability). Or do you have any question regarding to that? Cheers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment