Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 9th, 2012  |  syntax: None  |  size: 0.94 KB  |  hits: 15  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. import bpy
  2.  
  3.  
  4. class SetTextPreferences(bpy.types.Operator):
  5.     bl_label = ""
  6.     bl_idname = "txt.set_text_prefs"
  7.    
  8.     def execute(self, context):
  9.         st = context.space_data
  10.         st.show_line_numbers = True
  11.         st.show_word_wrap = True
  12.         st.show_syntax_highlight = True
  13.         st.show_margin = True
  14.         return {'FINISHED'}
  15.  
  16.  
  17. class TextHeaderAddition(bpy.types.Header):
  18.     # bl_label = "Hello World Panel"
  19.     # bl_idname = "OBJECT_PT_hello"
  20.     bl_space_type = "TEXT_EDITOR"
  21.     bl_region_type = "HEADER"
  22.    
  23.     def draw(self, context):
  24.  
  25.         layout = self.layout
  26.         row = layout.row()
  27.         row.operator("txt.set_text_prefs", icon='COLOR')
  28.  
  29.  
  30. def register():
  31.     bpy.utils.register_class(TextHeaderAddition)
  32.     bpy.utils.register_class(SetTextPreferences)
  33.  
  34. def unregister():
  35.     bpy.utils.unregister_class(TextHeaderAddition)
  36.     bpy.utils.unregister_class(SetTextPreferences)
  37.  
  38. if __name__ == "__main__":
  39.     register()