Commit dc020517 authored by Yori Fournier's avatar Yori Fournier
Browse files

Merge branch 'add-usage' into 'dev'

add usage to mytool

See merge request !30
parents 0d0583be 29d187e8
......@@ -178,7 +178,7 @@ class MyFig(Figure):
# This overwrites MPL add_axes. It gives a name to the axis added so that it is easier to refer to
def add_axes(self, ax, name) :
if isinstance(name, basestring) and isinstance(ax, MyAxes):
if isinstance(name, str) and isinstance(ax, MyAxes):
ax.name = name
else:
print(SEVR + " there is an error with the input type of add_axes()")
......@@ -202,7 +202,7 @@ class MyFig(Figure):
return ax
#if the name is correct we should never get here.
print(SEVR + "The axes name ",name," was not found")
print(SEVR + "The axes name ", name, " was not found")
return None
......
from .myTool import usage
from .myTool import print2file
from .myTool import print2screen
from .myTool import getCurrentWindowIDs
......
......@@ -45,6 +45,191 @@ from .. import MyWin
from .. import np
# USAGE FUNCTION -------------------------------------------------------
def usage(*args):
functions = ('print2screen',
'print2file',
'printListCurrentWindows',
'getWindow',
'getFigOnWindow',
'giveDataToWindow',
'drawFigOnWindow',
'closeWindow',
'closeAllWindows')
if len(args) > 0:
if args[0] in functions:
if args[0] == 'print2screen':
print('''
USAGE: print2screen(ClassName, rawdata, *args, **kwargs)
ClassName: is an object Class that inherit from MyFig
rawdata: can be of two type
- a single MyData object
- a tuple, list, generator or array of MyData object
*args: will be given to the class as argument
**kwargs: any keywords that can be given to the class
- debug: debugging flag
- fignum: identifier of the figure (same as win ID)
- reformat: set to True if the rawdata need
to be reformatted before plotting
- any keywords of the Axes
FUNCTION:
Creates a window and plot the figure
ClassName on it.
Equivalent to:
MyWin(ClassName(rawdata, *args, **kwargs))
''')
elif args[0] == 'print2file':
print('''
USAGE: print2file(ClassName, rawdata, filename, *args, **kwargs)
ClassName: is an object Class that inherit from MyFig
rawdata: can be of two type
- a single MyData object
- a tuple, list, generator or array of MyData object
filename: the name of the file: [path/]filename[.png/.eps]
*args: will be given to the class as argument
**kwargs: any keywords that can be given to the class
- debug: debug flag
- oformat: output format [.png/.eps]
- opath: path to the file
(can be introduced directly in the filename)
- any keywords of the Axes
FUNCTION:
Creates a figure of type ClassName and save it into
a file.
Equivalent to:
fig = ClassName(rawdata, *args, **kwargs)
fig.print2file(filename, *args, **kwargs)
''')
elif args[0] == 'printListCurrentWindows':
print('''
USAGE: printListCurrentWindows()
FUNCTION:
Prints the list of currently opened windows, with there respective IDs
''')
elif args[0] == 'getWindow':
print('''
USAGE: win = getWindow(ID)
ID: the identifier of the window (the number in the title)
FUNCTION:
Returns the window object with the given ID.
REMARK: It is useful when you create a window
from print2screen and you still want to refresh it.
''')
elif args[0] == 'getFigOnWindow':
print('''
USAGE: fig = getFigOnWindow(ID)
ID: the identifier of the window (the number in the title)
FUNCTION:
Returns the figure object contained in the window
with the given ID.
REMARK: It is useful after creating a figure from print2screen,
but still need to interactively act on the object.
''')
elif args[0] == 'giveDataToWindow':
print('''
USAGE: giveDataToWindow(rawdata, ID)
rawdata: can be of two type
- a single MyData object
- a tuple, list, generator or array of MyData object
ID: the identifier of the window (the number in the title)
FUNCTION:
Switches the data of the figure and refresh the window.
Equivalent to:
fig.update(rawdata=rawdata)
win.refresh()
''')
elif args[0] == 'drawFigOnWindow':
print('''
USAGE: drawFigOnWindow(fig, ID)
fig: a MyFig object (or inheritted) to draw on the window
ID: the identifier of the window (the number in the title)
FUNCTION:
Creates a window with the given figure, or
if the window already exists, switches the figure of the
window of the given ID.
Equivalent to:
win.set_figure(fig)
win.refresh()
REMARK: can be used as an alternative to print2screen
''')
elif args[0] == 'closeWindow':
print('''
USAGE: closeWindow(ID)
ID: the identifier of the window (the number in the title)
FUNCTION:
Closes the window with the given ID.
''')
elif args[0] == 'closeAllWindows':
print('''
USAGE: closeAllWindows()
FUNCTION:
Closes all current window.
''')
else:
print(SEVR + 'the function does not exists... sorry')
else:
print(SEVR + 'the function does not exists... sorry')
else:
print('''
USAGE:
for more info about a function type: >$ usage(<fct-name>)
AVAILABLE FUNCTIONS:
print2screen(ClassName, rawdata[, keywords ...])
print2file(ClassName, rawdata, filename[, keywords ...])
printListCurrentWindows()
getWindow(ID) -> MyWin object
getFigOnWindow(ID) -> MyFig object
giveDataToWindow(rawdata, ID)
drawFigOnWindow(fig, ID)
closeWindow(ID)
closeAllWindows()
''')
return(True)
# TOOL FUNCTION FOR READING EXISTING DATA ------------------------------
def setCurrentData(name):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment