File: textscroll.py

package info (click to toggle)
pivy 0.6.10-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 11,216 kB
  • sloc: python: 36,331; cpp: 787; ansic: 733; makefile: 30; sh: 27; objc: 5
file content (30 lines) | stat: -rw-r--r-- 630 bytes parent folder | download | duplicates (4)
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
from __future__ import print_function
# example that shows a scrolling text using a timer sensor
idx = 0
text = string.getValue().getString()
text_length = len(text)

interval = 0.15

def changeStringSensorCallback(data, sensor):
  global idx
  string.setValue(text[:idx])

  if idx == text_length:
    sensor.setInterval(5.0)
  else:
    sensor.setInterval(interval)

  idx %= text_length
  idx += 1

timersensor = SoTimerSensor(changeStringSensorCallback, None)
timersensor.setInterval(interval)
timersensor.schedule()

wa = SoWriteAction()
wa.apply(self)

string.setValue(text[:idx])

print('== TextScroller script loaded ==')