added ‘emph’ method.
additional background message animations.
This commit is contained in:
parent
1171dc4344
commit
681b7f0831
|
@ -1,10 +1,15 @@
|
||||||
# -*- coding: UTF-8 no BOM -*-
|
# -*- coding: UTF-8 no BOM -*-
|
||||||
|
|
||||||
# damask utility functions
|
# damask utility functions
|
||||||
import threading
|
import sys,time,random,threading
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from optparse import OptionParser, Option
|
from optparse import OptionParser, Option
|
||||||
|
|
||||||
|
# -----------------------------
|
||||||
|
def emph(what):
|
||||||
|
# -----------------------------
|
||||||
|
return '\033[1m'+str(what)+'\033[0m'
|
||||||
|
|
||||||
# -----------------------------
|
# -----------------------------
|
||||||
# Matlab like trigonometric functions that take and return angles in degrees.
|
# Matlab like trigonometric functions that take and return angles in degrees.
|
||||||
# -----------------------------
|
# -----------------------------
|
||||||
|
@ -51,39 +56,56 @@ class extendableOption(Option):
|
||||||
# -----------------------------
|
# -----------------------------
|
||||||
class backgroundMessage(threading.Thread):
|
class backgroundMessage(threading.Thread):
|
||||||
# -----------------------------
|
# -----------------------------
|
||||||
|
choices = {'bounce':['_','o','O','°','¯','¯','°','O','o',],
|
||||||
def __init__(self):
|
'circle': [u'\u25f4',u'\u25f5',u'\u25f6',u'\u25f7'],
|
||||||
threading.Thread.__init__(self)
|
'hexagon': [u'\u2b22',u'\u2b23'],
|
||||||
self.message = ''
|
'pentagon': [u'\u2b20',u'\u2b54'],
|
||||||
self.new_message = ''
|
'square': [u'\u2596',u'\u2598',u'\u259d',u'\u2597'],
|
||||||
self.counter = 0
|
'triangle': [u'\u140a',u'\u140a',u'\u1403',u'\u1405',u'\u1405',u'\u1403'],
|
||||||
self.symbols = ['- ', '\ ', '| ', '/ ']
|
'amoeba': [u'\u2596',u'\u258f',u'\u2598',u'\u2594',u'\u259d',u'\u2595',u'\u2597',u'\u2582'],
|
||||||
self.waittime = 0.5
|
'beat': [u'\u2581',u'\u2582',u'\u2583',u'\u2584',u'\u2585',u'\u2586',u'\u2587',u'\u2588',u'\u2587',u'\u2586',u'\u2585',u'\u2584',u'\u2583',u'\u2582',],
|
||||||
|
'prison': [u'\u168b',u'\u168c',u'\u168d',u'\u168f',u'\u168e',u'\u168d',u'\u168c',u'\u168b',],
|
||||||
def __quit__(self):
|
'breath': [u'\u1690',u'\u1691',u'\u1692',u'\u1693',u'\u1694',u'\u1693',u'\u1692',u'\u1691',u'\u1690'],
|
||||||
length = len(self.message) + len(self.symbols[self.counter])
|
'pulse': ['·','•',u'\u25cf',u'\u25cf','•',],
|
||||||
sys.stderr.write(chr(8)*length + ' '*length + chr(8)*length)
|
'ant': [u'\u2801',u'\u2802',u'\u2810',u'\u2820',u'\u2804',u'\u2840',u'\u2880',u'\u2820',u'\u2804',u'\u2802',u'\u2810',u'\u2808'],
|
||||||
sys.stderr.write('')
|
'classic':['-', '\\', '|', '/',],
|
||||||
|
}
|
||||||
def run(self):
|
|
||||||
while not threading.enumerate()[0]._Thread__stopped:
|
|
||||||
time.sleep(self.waittime)
|
|
||||||
self.update_message()
|
|
||||||
self.__quit__()
|
|
||||||
|
|
||||||
def set_message(self, new_message):
|
def __init__(self,
|
||||||
self.new_message = new_message
|
symbol,
|
||||||
self.print_message()
|
wait = 0.1):
|
||||||
|
threading.Thread.__init__(self)
|
||||||
def print_message(self):
|
self.message = ''
|
||||||
length = len(self.message) + len(self.symbols[self.counter])
|
self.new_message = ''
|
||||||
sys.stderr.write(chr(8)*length + ' '*length + chr(8)*length) # delete former message
|
self.counter = 0
|
||||||
sys.stderr.write(self.symbols[self.counter] + self.new_message) # print new message
|
self.gap = ' '
|
||||||
self.message = self.new_message
|
self.symbols = self.choices[symbol if symbol in self.choices else random.choice(self.choices.keys())]
|
||||||
|
self.waittime = wait
|
||||||
def update_message(self):
|
|
||||||
self.counter = (self.counter + 1)%len(self.symbols)
|
def __quit__(self):
|
||||||
self.print_message()
|
length = len(self.symbols[self.counter] + self.gap + self.message)
|
||||||
|
sys.stderr.write(chr(8)*length + ' '*length + chr(8)*length)
|
||||||
|
sys.stderr.write('')
|
||||||
|
|
||||||
|
def run(self):
|
||||||
|
while not threading.enumerate()[0]._Thread__stopped:
|
||||||
|
time.sleep(self.waittime)
|
||||||
|
self.update_message()
|
||||||
|
self.__quit__()
|
||||||
|
|
||||||
|
def set_message(self, new_message):
|
||||||
|
self.new_message = new_message
|
||||||
|
self.print_message()
|
||||||
|
|
||||||
|
def print_message(self):
|
||||||
|
length = len(self.symbols[self.counter] + self.gap + self.message)
|
||||||
|
sys.stderr.write(chr(8)*length + ' '*length + chr(8)*length) # delete former message
|
||||||
|
sys.stderr.write(self.symbols[self.counter] + self.gap + self.new_message) # print new message
|
||||||
|
self.message = self.new_message
|
||||||
|
|
||||||
|
def update_message(self):
|
||||||
|
self.counter = (self.counter + 1)%len(self.symbols)
|
||||||
|
self.print_message()
|
||||||
|
|
||||||
'''
|
'''
|
||||||
Non-linear least square fitting (Levenberg-Marquardt method) with
|
Non-linear least square fitting (Levenberg-Marquardt method) with
|
||||||
|
|
Loading…
Reference in New Issue