1
2
3 """
4 The Blender.Text submodule.
5
6 Text Objects
7 ============
8
9 This module provides access to B{Text} objects in Blender.
10
11 Example::
12 import Blender
13 from Blender import Text
14 #
15 txt = Text.New("MyText") # create a new Text object
16 print Text.Get() # current list of Texts in Blender
17 txt.write("Appending some ") # appending text
18 txt.write("text to my\\n") # '\\n' inserts new-line markers
19 txt.write("text buffer.")
20 print txt.asLines() # retrieving the buffer as a list of lines
21 Text.unlink(txt) # removing a Text object
22 """
23
24 -def New (name = None, follow_cursor = 0):
25 """
26 Create a new Text object.
27 @type name: string
28 @param name: The Text name.
29 @type follow_cursor: int
30 @param follow_cursor: The text follow flag: if 1, the text display always
31 follows the cursor.
32 @rtype: Blender Text
33 @return: The created Text Data object.
34 """
35
36 -def Get (name = None):
37 """
38 Get the Text object(s) from Blender.
39 @type name: string
40 @param name: The name of the Text object.
41 @rtype: Blender Text or a list of Blender Texts
42 @return: It depends on the 'name' parameter:
43 - (name): The Text object with the given name;
44 - (): A list with all Text objects in the current scene.
45 """
46
48 """
49 Load a file into a Blender Text object.
50 @type filename: string
51 @param filename: The name of the file to load.
52 @rtype: Blender Text
53 @return: A Text object with the contents of the loaded file.
54 """
55
57 """
58 Unlink (remove) the given Text object from Blender.
59 @type textobj: Blender Text
60 @param textobj: The Text object to be deleted.
61 """
62
64 """
65 The Text object
66 ===============
67 This object gives access to Texts in Blender.
68 @ivar filename: The filename of the file loaded into this Text.
69 @ivar mode: The follow_mode flag: if 1 it is 'on'; if 0, 'off'.
70 @ivar nlines: The number of lines in this Text.
71 """
72
74 """
75 Get the name of this Text object.
76 @rtype: string
77 """
78
80 """
81 Set the name of this Text object.
82 @type name: string
83 @param name: The new name.
84 """
85
87 """
88 Get the filename of the file loaded into this Text object.
89 @rtype: string
90 """
91
93 """
94 Get the number of lines in this Text buffer.
95 @rtype: int
96 """
97
99 """
100 Clear this Text object: its buffer becomes empty.
101 """
102
103 - def set(attribute, value):
104 """
105 Set this Text's attributes.
106 @type attribute: string
107 @param attribute: The attribute to change:
108 currently, 'follow_cursor' is the only one available. It can be
109 turned 'on' with value = 1 and 'off' with value = 0.
110 @type value: int
111 @param value: The new attribute value.
112 """
113
115 """
116 Append a string to this Text buffer.
117 @type data: string
118 @param data: The string to append to the text buffer.
119 """
120
122 """
123 Retrieve the contents of this Text buffer as a list of strings.
124 @rtype: list of strings
125 @return: A list of strings, one for each line in the buffer
126 """
127
128 import id_generics
129 Text.__doc__ += id_generics.attributes
130