-
Notifications
You must be signed in to change notification settings - Fork 248
/
Copy pathlorem.py
48 lines (39 loc) · 1.07 KB
/
lorem.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!python2
# coding: utf-8
import ui
from faker import Faker
import clipboard
import console
import editor
import random
import platform
view = None
fake = Faker()
seed = random.randint(0, 9999)
def slider_changed(sender):
fake.seed(seed)
value1 = int(sender.superview['slider1'].value * 10) + 1
value2 = int(sender.superview['slider2'].value * 10) + 1
textview = sender.superview['textview1']
paragraphs = []
for i in xrange(value2):
p = fake.paragraph(nb_sentences=value1, variable_nb_sentences=True)
paragraphs.append(p)
text = '\n\n'.join(paragraphs)
textview.text = text
def copy_action(sender):
clipboard.set(sender.superview['textview1'].text)
console.hud_alert('Copied')
def insert_action(sender):
text = sender.superview['textview1'].text
start, end = editor.get_selection()
editor.replace_text(start, end, text)
if not platform.machine().startswith('iPad'):
view.close()
def randomize_action(sender):
global seed
seed = random.randint(0, 9999)
slider_changed(sender)
view = ui.load_view('lorem')
view.present('popover')
slider_changed(view['slider1'])