Text Snippet Guide

Text Snippets allow you to create, format and finally upload text to a snip lab book.

from snip.snippets import TextSnip

text = TextSnip("Hello, World!")
text
../_images/4f2fdcaeb22a60e50d2d8a23e035d0f6317e057b19af8a34b99409390e9c8721.png

As with any snippet you may change the position of the snippet by modifying the x and y attributes.

text.x = 400
text.y = 1000
text.rotation = 45
text
../_images/12237432c4a93fa06efc87755da8a03069a4e70fd1cd5ec1ad5f7eaee8420bb7.png

You may also get the width and height of the snippet, but you may not change them. Similarly, you may get the bounding box of the snippet.

bounds = text.bounding_box
print(f"Height: {text.height}, Width: {text.width}")
print(f"Bounds: {bounds}")
Height: 138.63712328638758, Width: 138.63712328638752
Bounds: (411.08768835680627, 948.3064383568062, 549.7248116431938, 1086.9435616431938)

Text Styling

You may apply styles to text snippets by using the available attributes of the TextSnip class or the _style attribute. For instance to change to font size of a text snippet you may use the font_size attribute.

text.font_size = 50
text
../_images/7f20336768b1ff20632e73091a08cc5d798352d086a7c8ad76da9ffd3f8e350c.png

By default lines wrap automatically at 400 pixels, you may change this by setting the line_wrap attribute. You may disable text wrap by setting the line_wrap attribute to -1!

text.font_size = 30
text.line_height = 1.5
text.text = "I should wrap once the text reaches 400 pixels!"
text
../_images/2c83f0721132c594f1a44f9e91c02f0b895702c84366e32922d4973af0d76f47.png

Again you may upload the snippet by calling the upload method which should be inherited by all snippets.

text.upload(book_id=1)