Skip to content

Instantly share code, notes, and snippets.

@zeffii
Created August 10, 2011 11:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zeffii/1136610 to your computer and use it in GitHub Desktop.
Save zeffii/1136610 to your computer and use it in GitHub Desktop.
prepending a button to a header
import bpy
class SetTextPreferences(bpy.types.Operator):
bl_label = ""
bl_idname = "txt.set_text_prefs"
def execute(self, context):
st = context.space_data
st.show_line_numbers = True
st.show_word_wrap = True
st.show_syntax_highlight = True
st.show_margin = True
return {'FINISHED'}
class TextHeaderAddition(bpy.types.Header):
# bl_label = "Hello World Panel"
# bl_idname = "OBJECT_PT_hello"
bl_space_type = "TEXT_EDITOR"
bl_region_type = "HEADER"
def draw(self, context):
layout = self.layout
row = layout.row()
row.operator("txt.set_text_prefs", icon='COLOR')
def register():
bpy.utils.register_class(TextHeaderAddition)
bpy.utils.register_class(SetTextPreferences)
def unregister():
bpy.utils.unregister_class(TextHeaderAddition)
bpy.utils.unregister_class(SetTextPreferences)
if __name__ == "__main__":
register()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment