X-Git-Url: https://git.ucc.asn.au/?p=uccvend-vendserver.git;a=blobdiff_plain;f=codesnippets%2Fhorizscroll.py;fp=codesnippets%2Fhorizscroll.py;h=0000000000000000000000000000000000000000;hp=5dca5299c3c6468dbbef78a80a69bbfd9b4cb089;hb=9ac8ba25e1fabd0edd0c90850bf8fa7532048224;hpb=8796ba14bcff4d89b76d32d28146527fd6f329f1;ds=sidebyside diff --git a/codesnippets/horizscroll.py b/codesnippets/horizscroll.py deleted file mode 100644 index 5dca529..0000000 --- a/codesnippets/horizscroll.py +++ /dev/null @@ -1,41 +0,0 @@ -#!/usr/bin/env python - -import string -import sys -import time - -class HorizScroll: - def __init__(self, text): - self.text = text - pass - - def expand(self, padding=None, paddingchar=" ", dir=None): - if len(self.text) <= 10: - return [text] - - if not padding: - padding = len(self.text) / 2 - - format = "%-" + str(padding) + "." + str(padding) + "s" - pad = string.replace(format % " "," ",paddingchar) - padtext = self.text + pad - expansion = [] - - for x in range(0,len(padtext)): - expansion.append(padtext[x:] + padtext[:x]) - - if dir == -1: - expansion.reverse() - - return expansion - -if __name__ == '__main__': - h = HorizScroll("hello cruel world") - eh = h.expand() - while 1: - for x in eh: - sys.stdout.write("\r") - print "%-10.10s" % x, - sys.stdout.flush() - time.sleep(0.1) -