From 033cb92dc47d6f71de40e3451aab12a6c2e2141c Mon Sep 17 00:00:00 2001 From: Daniel Weschke Date: Mon, 13 Jan 2020 10:25:33 +0100 Subject: [PATCH] add tui module and example, add contex manager cd and the method run_file in helper import vendor modules only once during import change text color for the method cad_wireframe in geometry_plot_pylab and add hide key --- docs/build/html/_modules/index.html | 1 + .../_modules/pylib/geometry_plot_pylab.html | 58 ++- docs/build/html/_modules/pylib/helper.html | 41 ++ .../html/_modules/pylib/mathematics.html | 4 +- docs/build/html/_modules/pylib/tui.html | 463 ++++++++++++++++++ docs/build/html/_sources/index.rst.txt | 33 +- docs/build/html/_sources/pylib.rst.txt | 1 + docs/build/html/_sources/pylib.tui.rst.txt | 7 + docs/build/html/genindex.html | 78 ++- docs/build/html/index.html | 38 +- docs/build/html/modules.html | 1 + docs/build/html/objects.inv | Bin 2402 -> 2595 bytes docs/build/html/py-modindex.html | 10 + docs/build/html/pylib.helper.html | 35 ++ docs/build/html/pylib.html | 1 + docs/build/html/pylib.mathematics.html | 6 +- docs/build/html/pylib.tui.html | 328 +++++++++++++ docs/build/html/searchindex.js | 2 +- docs/source/index.rst | 33 +- docs/source/pylib.rst | 1 + docs/source/pylib.tui.rst | 7 + examples/function_b_spline.py | 206 ++++---- examples/tui.py | 193 ++++++++ pylib/__init__.py | 3 +- pylib/geometry_plot_pylab.py | 58 ++- pylib/helper.py | 41 ++ pylib/mathematics.py | 4 +- pylib/tui.py | 360 ++++++++++++++ 28 files changed, 1848 insertions(+), 165 deletions(-) create mode 100644 docs/build/html/_modules/pylib/tui.html create mode 100644 docs/build/html/_sources/pylib.tui.rst.txt create mode 100644 docs/build/html/pylib.tui.html create mode 100644 docs/source/pylib.tui.rst create mode 100755 examples/tui.py create mode 100644 pylib/tui.py diff --git a/docs/build/html/_modules/index.html b/docs/build/html/_modules/index.html index d872c66..5faf05f 100644 --- a/docs/build/html/_modules/index.html +++ b/docs/build/html/_modules/index.html @@ -50,6 +50,7 @@
  • pylib.numerical.ode
  • pylib.numerical.ode_model
  • pylib.time_of_day
  • +
  • pylib.tui
  • diff --git a/docs/build/html/_modules/pylib/geometry_plot_pylab.html b/docs/build/html/_modules/pylib/geometry_plot_pylab.html index db0fd80..7b8928a 100644 --- a/docs/build/html/_modules/pylib/geometry_plot_pylab.html +++ b/docs/build/html/_modules/pylib/geometry_plot_pylab.html @@ -180,7 +180,37 @@ plot_post(ax) - def press(event, world, lps): + # 'rotate: ←left, right, up, down, ctrl+left, ctrl+right\n' + + # 'pan: shift+left, shift+right, shift+up, shift+down\n' + + # 'zoom: ctrl+up, ctrl+down\n' + + # 'view: f (front), l (left), r (right), t (top), b (bottom)\n' + + # ' i (isometric), d (dimetric)', + h_open = pylab.text( + 0+.01, 1-.015, + 'rotate: [←], [→], [↑], [↓], [Ctrl][←], [Ctrl][→]\n' + + 'pan: [Shift][←], [Shift][→], [Shift][↑], [Shift][↓]\n' + + 'zoom: [Ctrl][↑], [Ctrl][↓]\n' + + 'view: [f]ront, [l]eft, [r]ight, [t]op, [b]ottom\n' + + ' [i]sometric, [d]imetric', + color='#2280c0', + horizontalalignment='left', + verticalalignment='top', + transform=fig.transFigure, + bbox=dict(facecolor='black', edgecolor='#196090', alpha=0.5), + family='monospace' + ) + h_close = pylab.text( + 0+.01, 1-.015, '[h]elp', + color='#2280c0', + horizontalalignment='left', + verticalalignment='top', + transform=fig.transFigure, + bbox=dict(facecolor='black', edgecolor='#196090', alpha=0.5), + family='monospace', + visible=False + ) + + def press(event, world, lps, h_open, h_close): #print('key pressed:', event.key) #sys.stdout.flush() if event.key in [ @@ -250,6 +280,10 @@ world.scale(0.9) for i, j in zip(lps, world.wireframes_xy()): i.set_data(j) + if event.key == 'h': + visible = h_open.get_visible() + h_open.set_visible(not visible) + h_close.set_visible(visible) fig.canvas.draw() def onresize(event, w): @@ -258,28 +292,10 @@ pylab.ylim((-r, r)) fig.canvas.mpl_connect('key_press_event', - lambda event: press(event, world, lps)) + lambda event: press(event, world, lps, + h_open, h_close)) fig.canvas.mpl_connect('resize_event', lambda event: onresize(event, world)) - - # 'rotate: ←left, right, up, down, ctrl+left, ctrl+right\n' + - # 'pan: shift+left, shift+right, shift+up, shift+down\n' + - # 'zoom: ctrl+up, ctrl+down\n' + - # 'view: f (front), l (left), r (right), t (top), b (bottom)\n' + - # ' i (isometric), d (dimetric)', - pylab.text( - 0+.01, 1-.015, - 'rotate: [←], [→], [↑], [↓], [Ctrl][←], [Ctrl][→]\n' + - 'pan: [Shift][←], [Shift][→], [Shift][↑], [Shift][↓]\n' + - 'zoom: [Ctrl][↑], [Ctrl][↓]\n' + - 'view: [f]ront, [l]eft, [r]ight, [t]op, [b]ottom\n' + - ' [i]sometric, [d]imetric', - horizontalalignment='left', - verticalalignment='top', - transform=fig.transFigure, - bbox=dict(facecolor='black', alpha=0.5), - family='monospace' - ) pylab.show() diff --git a/docs/build/html/_modules/pylib/helper.html b/docs/build/html/_modules/pylib/helper.html index 3f9bc32..cf376b3 100644 --- a/docs/build/html/_modules/pylib/helper.html +++ b/docs/build/html/_modules/pylib/helper.html @@ -45,6 +45,7 @@ .. moduleauthor:: Daniel Weschke <daniel.weschke@directbox.de> """ +import os import time from contextlib import ContextDecorator @@ -81,6 +82,46 @@ elapsed_time_ms = (time.time() - self.start_time) * 1000 print('{:s} took {:.3f} ms'.format(self.description, elapsed_time_ms)) return False + +
    [docs]class cd: + """Context manager for changing the current working directory + + :param new_path: the directory to change into + :type new_path: string + + :Example: + + :: + + # enter the directory and run some code: + with cd("~/tmp"): + # we are now in ~/tmp + # code + # outside the context manager we are back where we started. + """ + def __init__(self, new_path): + self.new_path = os.path.expanduser(new_path) + + def __enter__(self): + self.saved_path = os.getcwd() + os.chdir(self.new_path) + + def __exit__(self, etype, value, traceback): + os.chdir(self.saved_path)
    + +
    [docs]def run_file(file_name): + """Run a file. + + Inside a pythin interpreter it changes to the directory of the + file and after excuting the file it changes back to the working + directory before. + + :param file_name: the file to execute + :type file_name: string + """ + workdir = os.path.dirname(os.path.abspath(file_name)) + with cd(workdir): + exec(open(file_name).read())
    diff --git a/docs/build/html/_modules/pylib/mathematics.html b/docs/build/html/_modules/pylib/mathematics.html index 8e78a6a..3b10655 100644 --- a/docs/build/html/_modules/pylib/mathematics.html +++ b/docs/build/html/_modules/pylib/mathematics.html @@ -668,7 +668,7 @@ """
    [docs] def __getitem__(self, index): - """ + r""" For index return value, for range return new vector object. :Example: @@ -825,7 +825,7 @@ :Example: >>> m = matrix.zeros(3, 3) - >>> print(m)\ + >>> print(m) [[0.0, 0.0, 0.0], [0.0, 0.0, 0.0], [0.0, 0.0, 0.0]] """ return matrix([[0. for i in range(n)] for j in range(m)])
    diff --git a/docs/build/html/_modules/pylib/tui.html b/docs/build/html/_modules/pylib/tui.html new file mode 100644 index 0000000..2c64980 --- /dev/null +++ b/docs/build/html/_modules/pylib/tui.html @@ -0,0 +1,463 @@ + + + + + + + pylib.tui — pylib 2019.12.21 documentation + + + + + + + + + + + + + + + + + + + + +
    +
    +
    + + +
    + +

    Source code for pylib.tui

    +#!/usr/bin/env python
    +# -*- coding: utf-8 -*-
    +"""TUI module.
    +
    +:Date: 2020-01-10
    +
    +.. module:: tui
    +  :platform: *nix, Windows
    +  :synopsis: TUI module.
    +
    +.. moduleauthor:: Daniel Weschke <daniel.weschke@directbox.de>
    +"""
    +# TODO: two classes to distinguish between curses (main tui) and
    +#       window (to handle sub windows)?
    +# TODO: width resizing, min width now 6 because of text and border
    +# TODO: height resizing, min height
    +import sys
    +import curses
    +
    +
    +
    [docs]def newwin(height, width, y, x): + win = Window() + win.window = curses.newwin(height, width, y, x) + return win
    + + +
    [docs]class StdOutWrapper: + """Send print to stdout (print to the standard console). + + usage: + + :: + + # catch all prints into StdOutWrapper + mystdout = StdOutWrapper() + sys.stdout = mystdout + sys.stderr = mystdout + + # begin curses (curses.initscr()) + + # do your stuff here + # print("foo") + # you can also output mystdout.get_text() in a ncurses widget in + # runtime + + # end curses (curses.endwin()) + + # go back to normal state and print all catched prints to stdout + sys.stdout = sys.__stdout__ + sys.stderr = sys.__stderr__ + sys.stdout.write(mystdout.get_text()) + + source: + https://stackoverflow.com/a/14010948 + """ + text = "" +
    [docs] def write(self, txt): + self.text += txt + self.text = '\n'.join(self.text.split('\n')[-30:])
    +
    [docs] def get_text(self): + return '\n'.join(self.text.split('\n'))
    + #def get_text(self,beg,end): + # return '\n'.join(self.text.split('\n')[beg:end]) + + +
    [docs]class TUI: + """TUI text-based user interface + + initscr is the encapsulation window object of the stdscr + stdsc is the curses.initscr + """ + + def __init__(self, delay=5): + """ + :param delay: sets the curses.halfdelay, value between 1 and 255. + :param type: int + """ + if not isinstance(delay, int): + try: + delay = int(delay) + except ValueError: + print("TUI(delay)") + print("Could not convert the argument to an integer.") + + # catch all prints into StdOutWrapper + self.stdout = StdOutWrapper() + sys.stdout = self.stdout + sys.stderr = self.stdout + + # Define the appearance of some interface elements + hotkey_attr = curses.A_BOLD | curses.A_UNDERLINE + menu_attr = curses.A_NORMAL + + self.initscr = Window() + self.initscr.initscr() + self.stdscr = self.initscr.window + #print(type(self.stdscr)) + #print(type(self.initscr)) + + try: + curses.cbreak() + curses.halfdelay(delay) # How many tenths of a second are waited, from 1 to 255 + #stdscr.nodelay(1) + curses.noecho() + self.cursor_visibility = 0 # Set the cursor state. visibility can be set to 0, 1, or 2, for invisible, normal, or very visible. + curses.curs_set(self.cursor_visibility) + self.stdscr.keypad(1) + curses.mousemask(1) # activate mouse events + + # init colors + if curses.has_colors(): + curses.start_color() # initializes 8 basic colors. 0:black, 1:red, 2:green, 3:yellow, 4:blue, 5:magenta, 6:cyan, and 7:white. + curses.use_default_colors() + for i in range(0, curses.COLORS): + curses.init_pair(i + 1, i, -1) # Color pair 0 is hard-wired to white on black, and cannot be changed. + except: pass + + self.last_pressed_ch = 0 # getch() Note that the integer returned does not have to be in ASCII range: function keys, keypad keys and so on return numbers higher than 256. + self.last_pressed_mouse_ch = 0 + +
    [docs] def refresh(self): + self.initscr.refresh() # update the screen
    + +
    [docs] def getch(self): + # keep last key value + last_pressed_ch_current = self.initscr.getch() + if last_pressed_ch_current != curses.ERR: + # keep last key while window resizing + if last_pressed_ch_current == curses.KEY_MOUSE: + self.last_pressed_mouse_ch = last_pressed_ch_current + if last_pressed_ch_current in [curses.KEY_MOUSE, curses.KEY_RESIZE]: + pass + else: + self.last_pressed_ch = last_pressed_ch_current
    + +
    [docs] def color_table(self, window=None): + """Print all available colors with default background. + Check if curses.has_colors() is True. + """ + # TODO: position + # FIXME: use own text method? + # FIXME: build full str first and then print? + if not curses.has_colors(): + return + if window is None: + window = self.stdscr + + window.addstr(2, 1, '{0} colors available'.format(curses.COLORS)) + if curses.can_change_color(): + window.addstr(' (can change color: {0})'.format(curses.can_change_color())) + _, maxx = window.getmaxyx() + step_size = 4 + maxx = maxx - maxx % step_size + x = 0 + y = 3 + try: + for i in range(0, curses.COLORS): + window.addstr(y, x, '{0:{1}}'.format(i, step_size), curses.color_pair(i)) + x = (x + step_size) % maxx + if x == 0: + y += 1 + except: + # End of screen reached + pass
    + +
    [docs] def color_def(self): + if curses.can_change_color(): # if True curses.init_color(color_number, r, g, b) can be used + pass
    + # changes colors for the terminal also after closing the program. + #curses.color_content(0) + #tmp = curses.color_content(1) + #print(curses.color_content(1)) + #curses.init_color(0, 1000, 0, 0) # color_number = init_pair number - 1 (maybe because init_pair number 0 is hard-wired and not changeable) + #curses.init_color(1, 1000, 500, 1000) + #print(curses.color_content(1)) + #curses.init_color(1, *tmp) + #print(curses.color_content(1)) + +
    [docs] def clear(self): + self.stdscr.clear()
    + +
    [docs] def end(self): + """clean up""" + self.stdscr.clear() + curses.nocbreak() + self.stdscr.keypad(0) + curses.echo() + curses.endwin() + + # go back to normal state and print all catched prints to stdout + sys.stdout = sys.__stdout__ + sys.stderr = sys.__stderr__ + sys.stdout.write(self.stdout.get_text())
    + + +
    [docs]class Window: + """Window + """ + def __init__(self): + self.window = None + +
    [docs] def initscr(self): + self.window = curses.initscr()
    + +
    [docs] def derwin(self, height, width, y, x): + win = Window() + win.window = self.window.derwin(height, width, y, x) + return win
    + +
    [docs] def clear(self): + return self.window.clear()
    + +
    [docs] def getmaxyx(self): + return self.window.getmaxyx()
    + +
    [docs] def getch(self): + return self.window.getch()
    + +
    [docs] def instr(self, y, x, n): + return self.window.instr(y, x, n).decode()
    + +
    [docs] def text(self, string, padding_left=0, padding_top=0, attribute=0, color_pair=0): + r"""Test to screen. If multiline than keep the x position for + each new line. + + :Example: + + :: + + text(stdscr, 2, 1, "1 - Show test page") + text(stdscr, 3, 1, "h - Show help page") + text(stdscr, 4, 1, "q - Exit") + + text(stdscr, 2, 1, + "1 - Show test page\\n" + + "h - Show help page\\n" + + "q - Exit") + + .. note:: + Writing in the last char of the window (last row bottom and + last column right) is suppressed + """ + win_height, win_width = self.window.getmaxyx() + if win_width-padding_left < 2: # unicode can have 2 char width + return + yi = padding_top + #for row in string.split("\n"): + # window.addnstr(yi, x, row, win_width-x-1, curses.color_pair(9)) # 5 + # yi += 1 + for row in string.split("\n"): # TODO: os.linesep? + xi = padding_left + for char in row: + # write only inside the window + if not yi >= win_height and not xi >= win_width: + # do not write in the last char of window (last row bottom and last column right) + # unicodes may use multiple chars, this will raise an error for the last char in the window + if yi == win_height-1 and xi >= win_width-1: + break + #if yi == win_height-1 and xi >= win_width-1: + # try: + # char.encode("ascii") + # except UnicodeEncodeError: + # break + + # dont add str if empty braille char or simple space character + if char != chr(0x2800) and char != " " and xi < win_width and yi < win_height: + self.window.addstr(yi, xi, char, attribute|curses.color_pair(color_pair)) + xi += 1 + yi += 1
    + +
    [docs] def border(self, title="", footer_left="", footer_right="", style="horizontal"): + """Set border around the window with optional title and footer + labels. + + :param window: the window to draw a border + :type window: curses.window + :param title: the title for the window (default = "") + :type title: str + :param footer_left: the footer label (default = ""). If footer_left + is a list than every element of the list will be printed sperated + by one column. This is useful to not overwright the border with a + space character. + :type footer_left: str or list + """ + win_height, win_width = self.window.getmaxyx() + if win_width < 3: + return + + if isinstance(style, str): + if style == "horizontal": + self.window.border( + ' ', + ' ', + curses.ACS_HLINE, + curses.ACS_HLINE, + curses.ACS_HLINE, + curses.ACS_HLINE, + curses.ACS_HLINE, + curses.ACS_HLINE, + ) + elif style == "full": + self.window.border(0, 0, 0, 0, 0, 0, 0, 0, ) + else: # list + self.window.border(*style) + + if title: + self.text(title, 1) + + if footer_left: + last_win_row = win_height - 1 + if isinstance(footer_left, str): + self.text(footer_left, 1, last_win_row) + else: # list + pos = 1 + for footer_left_i in footer_left: + self.text(footer_left_i, pos, win_height-1) + pos += len(footer_left_i)+1 + + if footer_right: + self.text(footer_right, win_width - 1 - len(footer_right), last_win_row)
    + +
    [docs] def textbox(self, height, width, y, x, borders=False): + """Add sub window. + + :param parent_window: the parent window + :type parent_window: curses.window + :param height: the height of the sub window. The reference point of + the sub window is the top left corner. + :type height: int + :param width: the width of the sub window. The reference point of + the sub window is the top left corner. + :type width: int + :param y: the y coordinate (position) of the sub window. Start from + the top. + :type y: int + :param x: the x coordinate (position) of the sub window. Start from + the left. + :returns: the sub window content and decoration + :rtype: (curses.window, curses.window) + """ + # TODO: not to work with two window object but one with the + # possibility to access the derwin(s). Either self.derwins + # or another DoubleWindow class for border and text or do it + # in this class? + screen_height, screen_width = self.window.getmaxyx() + newwin_width = screen_width-x if x+width > screen_width else width + newwin_height = screen_height-y if y+height > screen_height else height + if newwin_width > 0 and newwin_height > 0: + win = self.derwin(newwin_height, newwin_width, y, x) + if borders: + win.border(style="full") + if newwin_width-2 > 0 and newwin_height-1 > 0: + subwin = win.derwin(newwin_height-1, newwin_width-2, 1, 1) + return subwin, win # text and border + return newwin(1, 1, 0, 0), win # only border, no text (top left 1 char) + return win, newwin(1, 1, 0, 0) # only text, no border (top left 1 char) + return newwin(1, 1, 0, 0), newwin(1, 1, 0, 0) # no border and no text (top left 1 char)
    + +
    [docs] def refresh(self): + self.window.refresh()
    +
    + +
    + +
    +
    + +
    +
    + + + + + + + \ No newline at end of file diff --git a/docs/build/html/_sources/index.rst.txt b/docs/build/html/_sources/index.rst.txt index e0ae45b..08341a4 100644 --- a/docs/build/html/_sources/index.rst.txt +++ b/docs/build/html/_sources/index.rst.txt @@ -15,8 +15,39 @@ Welcome to pylib's documentation! Indices and tables -================== +------------------ * :ref:`genindex` * :ref:`modindex` * :ref:`search` + + + +tui +--- + +pylib/tui.py is the main module for tui 'terminal user interface' programs. + +* curses package (for Windows install windows-curses) is the underlying main + package to build terminal programs. The curses package can also be used + directly. + + * Windows (Anaconda): + + * ``C:\PathToAnaconda3\condabin\conda.bat activate base`` + * ``python -m pip install windows-curses`` + * https://github.com/zephyrproject-rtos/windows-curses + +* drawille package is used to draw with braille characters (dottet and quasi- + line charts). Make sure you use a font with Unicode Braille characters. For + Windows e. g.: NSimSun, MS Gothic. + + * Install: ``python -m pip install drawille`` + * Windows (Anaconda): + + * ``C:\PathToAnaconda3\condabin\conda.bat activate base`` + * ``python -m pip install drawille`` + +* drawblock.py is used to draw with block characters (histogram). + +example/tui.py is an example script to build a terminal program. diff --git a/docs/build/html/_sources/pylib.rst.txt b/docs/build/html/_sources/pylib.rst.txt index 524f6f0..4275b18 100644 --- a/docs/build/html/_sources/pylib.rst.txt +++ b/docs/build/html/_sources/pylib.rst.txt @@ -32,3 +32,4 @@ Submodules pylib.helper pylib.mathematics pylib.time_of_day + pylib.tui diff --git a/docs/build/html/_sources/pylib.tui.rst.txt b/docs/build/html/_sources/pylib.tui.rst.txt new file mode 100644 index 0000000..b61f490 --- /dev/null +++ b/docs/build/html/_sources/pylib.tui.rst.txt @@ -0,0 +1,7 @@ +pylib.tui module +================ + +.. automodule:: pylib.tui + :members: + :undoc-members: + :show-inheritance: diff --git a/docs/build/html/genindex.html b/docs/build/html/genindex.html index 127b7ed..16355b1 100644 --- a/docs/build/html/genindex.html +++ b/docs/build/html/genindex.html @@ -186,15 +186,17 @@
  • b_spline_curve_with_knots() (in module pylib.function)
  • - - + - + - + - + @@ -417,9 +445,13 @@
  • in_seconds() (in module pylib.time_of_day)
  • init_xyz() (CS class method) +
  • +
  • initscr() (Window method)
  • @@ -602,6 +638,12 @@
  • rectangle() (in module pylib.geometry2d)
  • +
  • refresh() (TUI method) + +
  • REPRESENTATION_ITEM (class in pylib.data_step_std)
  • rotate() (in module pylib.geometry2d) @@ -642,6 +684,8 @@
  • (World method)
  • +
  • run_file() (in module pylib.helper) +
  • rx() (matrix static method)
  • ry() (matrix static method) @@ -695,6 +739,8 @@
  • space_diagonal() (World method)
  • square() (in module pylib.geometry2d) +
  • +
  • StdOutWrapper (class in pylib.tui)
  • step (class in pylib.data_step)
  • @@ -715,6 +761,12 @@
    @@ -788,6 +844,8 @@

    W

    diff --git a/docs/build/html/index.html b/docs/build/html/index.html index 3654d3c..1bbe66b 100644 --- a/docs/build/html/index.html +++ b/docs/build/html/index.html @@ -44,14 +44,48 @@ -
    -

    Indices and tables

    +

    Indices and tables

    +
    +
    +

    tui

    +

    pylib/tui.py is the main module for tui ‘terminal user interface’ programs.

    + +

    example/tui.py is an example script to build a terminal program.

    +
    diff --git a/docs/build/html/modules.html b/docs/build/html/modules.html index 62be430..bcb2010 100644 --- a/docs/build/html/modules.html +++ b/docs/build/html/modules.html @@ -61,6 +61,7 @@
  • pylib.helper module
  • pylib.mathematics module
  • pylib.time_of_day module
  • +
  • pylib.tui module
  • diff --git a/docs/build/html/objects.inv b/docs/build/html/objects.inv index 4bb359df5515718e4a457e2357960a9fd896d8a9..05cf00858a6de80c2529c6d2db2857cc5ff8c0b4 100644 GIT binary patch delta 2504 zcmV;(2{-oQ5~CE5b$`op<2DwC_x%)}%4}PeIJ24T+_I)y71>f*>NqTnK_-jql>~FQFg_r*}V^zd74Zhl~I|Nx+x61rO`jlz7O-=10+P0PWxPRp$c(V!0u$F4aw8cJ3 zLMmB+`NV{`HAxg`CL)Wl3~FiiRD@K^vqe(|b!zTOkLsTE=upgs?iFViorGKZ0cvCv zczcVHTeV0B%3~@m;yj>b&mv9t5_eQiRjW0-79+&^K+QiaP!>ilw51e;_Qq<$Z5m{L zQhrOBTeb9=rGKq}Y<5|18`|G%K|2-^#Ieen!lm{9)KXu|1UE9~D%(?y7;)1urRX0C zjRNYX;{rRz6id^1JaQ$eYfPyE1%fAGq}-IIEF1+|Na`w)XiN2x(#Tz?g+~b{5i?bc zXhc}F_mXN3Vf*R3=+9DNm7Eu%= z@;gOGrVr>X5?X=D*xm?U1p3?%`3c>peYY6V^^W*FhO~1bUHiIP$tyhcr^K5h! zdYx~+pkJStn>C0!eR$c-)^k&KtL6N8GbU?-P}+!5*8ZqI2;v2uzf2dflAA7{=TjH~ zTzil6m)UePUp|82Z}_>*a;a@?uLkI zq-h|!_Z8YQuYKxPxM^}?FL7v(x5=phK7U)+SHYJZfh|_d-a?wFKF0N~0uTpafWtW!FoMEi%qcoxzC$AJ*b#K5pssz)+ay?Z z7{_bID^IP&kxD(ubjQR|)mAIHeXYZbbRQAoEo4mE)`6Sda9huI*bL4XG zc96?KjUY!H&9JmHt2)0a$7}go(y{O|9mr3X1aJSA127@};;l%sqXB3uPJjNCAYIT) zfZn$W7IJ`AY|}9s0D!pl2H^}Qy!#WpdvPI;aX=Aa*vwck_ve7TL5>)~8`K!+bRG%g zRXKz92yRhak3zN#aJ28(<+-L<O$EkuCv&4SyncS5Q5yNtAB;?2k}?Bv=Bn(QtM^1SBKA2cGR#*~#R* z&kkv6HS`T8nC5pdyYt|+=ke@r%K#H}88Uh^+T!@);IDbXN$H|uY4IJ?*)JU9&?nmL6jy?(pI=84mW0eqaK2ULz?Fby> zgW!z(TQ?X(!Wmur+Kv=Mqw5EjA_D&U}Tyvfl5Op4MYOq{*b z@kj)W5)p;hxtZz^0k1L%FB$l{qX{~X1$qaAfRpWlGQw23Ab)wxN-v+^_kNmh-<)V% zAmMz$gw1A;6J_5rw6J<1s7R78XpBo1`fN?5$MpS13R`d+)#pM6n+^TxMrtmgPQpEy z@DC_q7c(e=feRv{#}LamGnGAR5t*7ksE$*zP$&w?8xRb?nZs&Hm>Q6>I=14ad#vf_ z8O65_SLv#Sc7LR&Zejkjdz2QYTaVJw9RfLsL@F= zko2C}r&v1S&9aRPi3r{K$aHyW%71Vnjfk7T)L3wElccZZsB#d! zGP7x z>7O4eGk+q2)Tn0hN_ikcdYA21n27%O=fBmRF*CEENM}>~zkM*tv&0miKb8SG>M74% z9%r5*9pUkxwjgy2| z&+LqQ(oMN1HqJfiBIW0EdT`YN9ea=+d;{AFy@f1J0ri7xhf}(Pn~@YJSK6JdIuX)% z(p1+^h_n#b8#nF8O<1*?(?T^jbM9KZKMgm~+}Y`2m3t_*fR3a!wpM!3*P9=G23=95 zdqE>TQItz#TR;!8STXm5Yb)FC;ASNC;jab19{t*nuV7|GY(t6xvHDqxl$nW{=}}_< S%Ae(ebsoM-+sI#%l!NZqde2(` delta 2309 zcmV+g3HtV<6yg$)b$`v4;x-n?_x%*iNw!@lsbn+R(G=6o2~}`_PG_ehECK40Ek}|Y zs8wDgt31rS$vjD98?cQfgLO5FuCB7~|EF*1>cb{j<3W1-B^D&(bnt`uowM}=F^?a1 zI_BS%0q?&bynmNJL`u`tAt=J!D)WPMDf4ifn%YIQZ7cD9&3{GoY7?BpTB;4x7W*WN zsbmr64<@{=$&yGjkywQ1pq6G!MNG9kS~TY%r{UTTCLf&7%|p6YJRXtSs1m@mQoPf8LJ7mX^{Do z@>|N%s--V1ZGQ!1vnzVrz5Trwv|$NB9IK)!Tw4E+E%miba3f=VWm~EdBmFc?Df&l7 zlZf`yae;frluFZhJaQ#z-2ICCM|VYS0+-m{$clIebu{*&x=IF=ELn175oMfG{dnt~e9hFT+)a+XjO zW%3(Ed!~2jH4$2Y$;EF`OjO<)ia!X8G>Dc15GC7lY7IC@DhqB6hW0{o@_#_q5)Yy) zTIfI}TGTqU_{!0;$Q2hN^~IcfL}Vr*)lXOqHl~>&EVs%telOqEW;6VKvV27I>2NfD z9>1*6<9|~}t}5!ixSwFS53|{HJbcLuY%K)uF06ZSpI@HFPiXXc@!J@dFtnUcCokjR zDD-8r`hS(xFjh7QscJtZfWfhY3fKc9uQPKXW-U;Fboh(LESjmlMFOw0B z0It2K$znWOO=d43%J}Ky7z_x|77NUDHk-pJ(|_q?zJ#UZ<9PNwUM(ggv>4A9;r*4ItCMUKM$M$%eoC@Hxb$@*oeAy9LW5w((q>1WcT<E=PXse;*@DA%&6$tG`$Jf9a8}#C>*Dpq8;WNBvQwYU~dX??PK01!K%Xy zyk@@g)JmMFd?dM?Lfp;pIU~9X9?Iy$vgiw=yk~te9qZR~pJ-0yO`;t&y7Y_UIgv$ZQ zn^4U9{JiY)r5uhxxnD6z<7`RIsLupjiBBGMarPvnvTy#}2Y-J`lrQKd zK=0cGPjY}(tn)b<0DuhZ4Z;yjc=IQC_u`X0#Suk>VdJr2?#}^@1|=fEXi#II!!Z!X zt8(tzBe+HBdlj-}fRn9bm*<*dl}Fi{ML;oy9oK^NtuegX`>yL zvFm=*U9hur@2>`wMZN?CHh+k6xPt0oP2xOkAN>*Pj|@vdHX4H+5CO@E?}cZ(RdF-9 z?6dc@v>N&b6HN2FnC-lH?Rh=hZ5d&LE>lKlMqB)DaQUn2yu}l$s76?&G`~G)Isy;L zzLdgG#24H57JMU6vzRi=#!p>aiTp3Ww=H;NKb&e&>~iy;WQTUbdw4r)e5&@&$s1$(8`c~}ed5^`V+>8u(tso;q#UUgJXG;TNz=LPS(m^mRR1xto zMa08o%lr+T@hVgxPJcqTK{%$P2jM_{iwYE~gn<4)#mUwIIA#ojGs+jxUJS01 zG6^pk_`0JBI)(zhfk8lL`$P%gDxXLmUg_nX_|Es`?VA&guYWr9{_2CxW{Wdr-^a7C zIw9zkBwtX7FCTQ-no3XU+l>^q;5MqyR}ySC^v4^ixqzI6M=;@MC}EQ_D1w0tBBA>j z%U9#d?zKovP4ATB>M9h9V)6_jFN7ywQN%ddbN@05Vj60;=JGz0>ip#Zr#A;3ww+*7|F;@`}p zjI0MrlV3Pqo4)(reG`656P6HqXj-427IuS4{_DHSjEE>Vs#$!YJQ6V-6fU=k=zo9y zr3S{#bmc@B^V7fHndDhwN{{c)0VV3W%w-v8nI%<^^?&rJG%g}LeUqnVQ+<+WaQa>k zj$ZMW*1yWrGQWHtr1tkIw${f&tm5jM2GxWIur8&1KjRtr1tjV~%jL~8=?x    pylib.time_of_day + + +     + pylib.tui +   t @@ -269,6 +274,11 @@ time_of_day (*nix, Windows) Calculate time. + + + + tui (*nix, Windows) + TUI module. diff --git a/docs/build/html/pylib.helper.html b/docs/build/html/pylib.helper.html index d8288b7..27d29ea 100644 --- a/docs/build/html/pylib.helper.html +++ b/docs/build/html/pylib.helper.html @@ -43,6 +43,41 @@
    +
    +class cd(new_path)[source]
    +

    Bases: object

    +

    Context manager for changing the current working directory

    +
    +
    Parameters
    +

    new_path (string) – the directory to change into

    +
    +
    Example
    +

    +
    +
    # enter the directory and run some code:
    +with cd("~/tmp"):
    +  # we are now in ~/tmp
    +  # code
    +# outside the context manager we are back where we started.
    +
    +
    +
    + +
    +
    +run_file(file_name)[source]
    +

    Run a file.

    +

    Inside a pythin interpreter it changes to the directory of the +file and after excuting the file it changes back to the working +directory before.

    +
    +
    Parameters
    +

    file_name (string) – the file to execute

    +
    +
    +
    + +
    class timeit(description=None)[source]

    Bases: contextlib.ContextDecorator

    diff --git a/docs/build/html/pylib.html b/docs/build/html/pylib.html index 173e730..58e32d3 100644 --- a/docs/build/html/pylib.html +++ b/docs/build/html/pylib.html @@ -71,6 +71,7 @@
  • pylib.helper module
  • pylib.mathematics module
  • pylib.time_of_day module
  • +
  • pylib.tui module
  • diff --git a/docs/build/html/pylib.mathematics.html b/docs/build/html/pylib.mathematics.html index fc837ab..a2097a9 100644 --- a/docs/build/html/pylib.mathematics.html +++ b/docs/build/html/pylib.mathematics.html @@ -61,7 +61,8 @@
    Example

    -
    >>> m = matrix([[1, 2, 3, 0], [4, 5, 6, 0], [7, 8, 9, 0],                     [0, 0, 0, 0]])
    +
    >>> m = matrix([[1, 2, 3, 0], [4, 5, 6, 0], [7, 8, 9, 0], \
    +                [0, 0, 0, 0]])
     >>> print(m[:])
     [[1, 2, 3, 0], [4, 5, 6, 0], [7, 8, 9, 0], [0, 0, 0, 0]]
     >>> print(m[2])
    @@ -442,7 +443,8 @@ filled with zeros.

    >>> m = matrix.zeros(3, 3)
    ->>> print(m)    [[0.0, 0.0, 0.0], [0.0, 0.0, 0.0], [0.0, 0.0, 0.0]]
    +>>> print(m)
    +[[0.0, 0.0, 0.0], [0.0, 0.0, 0.0], [0.0, 0.0, 0.0]]
     
    diff --git a/docs/build/html/pylib.tui.html b/docs/build/html/pylib.tui.html new file mode 100644 index 0000000..69461be --- /dev/null +++ b/docs/build/html/pylib.tui.html @@ -0,0 +1,328 @@ + + + + + + + pylib.tui module — pylib 2019.12.21 documentation + + + + + + + + + + + + + + + + + + + + + +
    +
    +
    + + +
    + +
    +

    pylib.tui module

    +

    TUI module.

    +
    +
    Date
    +

    2020-01-10

    +
    +
    +
    +
    +class StdOutWrapper[source]
    +

    Bases: object

    +

    Send print to stdout (print to the standard console).

    +

    usage:

    +
    # catch all prints into StdOutWrapper
    +mystdout = StdOutWrapper()
    +sys.stdout = mystdout
    +sys.stderr = mystdout
    +
    +# begin curses (curses.initscr())
    +
    +# do your stuff here
    +# print("foo")
    +# you can also output mystdout.get_text() in a ncurses widget in
    +# runtime
    +
    +# end curses (curses.endwin())
    +
    +# go back to normal state and print all catched prints to stdout
    +sys.stdout = sys.__stdout__
    +sys.stderr = sys.__stderr__
    +sys.stdout.write(mystdout.get_text())
    +
    +
    +
    +
    source:

    https://stackoverflow.com/a/14010948

    +
    +
    +
    +
    +get_text()[source]
    +
    + +
    +
    +text = ''
    +
    + +
    +
    +write(txt)[source]
    +
    + +
    + +
    +
    +class TUI(delay=5)[source]
    +

    Bases: object

    +

    TUI text-based user interface

    +

    initscr is the encapsulation window object of the stdscr +stdsc is the curses.initscr

    +
    +
    +clear()[source]
    +
    + +
    +
    +color_def()[source]
    +
    + +
    +
    +color_table(window=None)[source]
    +

    Print all available colors with default background. +Check if curses.has_colors() is True.

    +
    + +
    +
    +end()[source]
    +

    clean up

    +
    + +
    +
    +getch()[source]
    +
    + +
    +
    +refresh()[source]
    +
    + +
    + +
    +
    +class Window[source]
    +

    Bases: object

    +
    +
    +border(title='', footer_left='', footer_right='', style='horizontal')[source]
    +

    Set border around the window with optional title and footer +labels.

    +
    +
    Parameters
    +
      +
    • window (curses.window) – the window to draw a border

    • +
    • title (str) – the title for the window (default = “”)

    • +
    • footer_left (str or list) – the footer label (default = “”). If footer_left +is a list than every element of the list will be printed sperated +by one column. This is useful to not overwright the border with a +space character.

    • +
    +
    +
    +
    + +
    +
    +clear()[source]
    +
    + +
    +
    +derwin(height, width, y, x)[source]
    +
    + +
    +
    +getch()[source]
    +
    + +
    +
    +getmaxyx()[source]
    +
    + +
    +
    +initscr()[source]
    +
    + +
    +
    +instr(y, x, n)[source]
    +
    + +
    +
    +refresh()[source]
    +
    + +
    +
    +text(string, padding_left=0, padding_top=0, attribute=0, color_pair=0)[source]
    +

    Test to screen. If multiline than keep the x position for +each new line.

    +
    +
    Example
    +

    +
    +
    text(stdscr, 2, 1, "1 - Show test page")
    +text(stdscr, 3, 1, "h - Show help page")
    +text(stdscr, 4, 1, "q - Exit")
    +
    +text(stdscr, 2, 1,
    +     "1 - Show test page\\n" +
    +     "h - Show help page\\n" +
    +     "q - Exit")
    +
    +
    +
    +

    Note

    +

    Writing in the last char of the window (last row bottom and +last column right) is suppressed

    +
    +
    + +
    +
    +textbox(height, width, y, x, borders=False)[source]
    +

    Add sub window.

    +
    +
    Parameters
    +
      +
    • parent_window (curses.window) – the parent window

    • +
    • height (int) – the height of the sub window. The reference point of +the sub window is the top left corner.

    • +
    • width (int) – the width of the sub window. The reference point of +the sub window is the top left corner.

    • +
    • y (int) – the y coordinate (position) of the sub window. Start from +the top.

    • +
    • x – the x coordinate (position) of the sub window. Start from +the left.

    • +
    +
    +
    Returns
    +

    the sub window content and decoration

    +
    +
    Return type
    +

    (curses.window, curses.window)

    +
    +
    +
    + +
    + +
    +
    +newwin(height, width, y, x)[source]
    +
    + +
    + + +
    + +
    +
    + +
    +
    + + + + + + + \ No newline at end of file diff --git a/docs/build/html/searchindex.js b/docs/build/html/searchindex.js index 91eb401..70c380c 100644 --- a/docs/build/html/searchindex.js +++ b/docs/build/html/searchindex.js @@ -1 +1 @@ -Search.setIndex({docnames:["index","modules","pylib","pylib.data","pylib.data_step","pylib.data_step_std","pylib.date","pylib.drawblock","pylib.function","pylib.geometry","pylib.geometry2d","pylib.geometry2d_plot","pylib.geometry_plot","pylib.geometry_plot_pylab","pylib.helper","pylib.mathematics","pylib.numerical","pylib.numerical.fit","pylib.numerical.integration","pylib.numerical.ode","pylib.numerical.ode_model","pylib.time_of_day"],envversion:{"sphinx.domains.c":1,"sphinx.domains.changeset":1,"sphinx.domains.citation":1,"sphinx.domains.cpp":1,"sphinx.domains.javascript":1,"sphinx.domains.math":2,"sphinx.domains.python":1,"sphinx.domains.rst":1,"sphinx.domains.std":1,"sphinx.ext.viewcode":1,sphinx:56},filenames:["index.rst","modules.rst","pylib.rst","pylib.data.rst","pylib.data_step.rst","pylib.data_step_std.rst","pylib.date.rst","pylib.drawblock.rst","pylib.function.rst","pylib.geometry.rst","pylib.geometry2d.rst","pylib.geometry2d_plot.rst","pylib.geometry_plot.rst","pylib.geometry_plot_pylab.rst","pylib.helper.rst","pylib.mathematics.rst","pylib.numerical.rst","pylib.numerical.fit.rst","pylib.numerical.integration.rst","pylib.numerical.ode.rst","pylib.numerical.ode_model.rst","pylib.time_of_day.rst"],objects:{"":{"function":[8,0,0,"-"],data:[3,0,0,"-"],data_step:[4,0,0,"-"],data_step_std:[5,0,0,"-"],date:[6,0,0,"-"],drawblock:[7,0,0,"-"],fit:[17,0,0,"-"],geometry2d:[10,0,0,"-"],geometry2d_plot:[11,0,0,"-"],geometry:[9,0,0,"-"],geometry_plot:[12,0,0,"-"],geometry_plot_pylab:[13,0,0,"-"],helper:[14,0,0,"-"],integration:[18,0,0,"-"],mathematics:[15,0,0,"-"],ode:[19,0,0,"-"],ode_model:[20,0,0,"-"],pylib:[2,0,0,"-"],time_of_day:[21,0,0,"-"]},"pylib.data":{find_last:[3,1,1,""],fold_list:[3,1,1,""],get_id:[3,1,1,""],issequence:[3,1,1,""],load:[3,1,1,""],print_list:[3,1,1,""],read:[3,1,1,""],read_columns:[3,1,1,""],seq:[3,1,1,""],store:[3,1,1,""],str_between:[3,1,1,""],str_to_list:[3,1,1,""],unique_ending:[3,1,1,""],unique_list:[3,1,1,""],unique_list_hashable:[3,1,1,""],write:[3,1,1,""]},"pylib.data_step":{arc_circle_geometry:[4,1,1,""],b_spline_curve_with_knots_geometry:[4,1,1,""],data_cmds_to_data_dict:[4,1,1,""],data_dict_edge_curve_to_geometry:[4,1,1,""],data_dict_to_geometry_world:[4,1,1,""],data_dict_to_geometry_world_edge_curve:[4,1,1,""],data_section_dict:[4,1,1,""],line_geometry:[4,1,1,""],print_edge_loop:[4,1,1,""],step:[4,2,1,""],str_to_cmd_args:[4,1,1,""]},"pylib.data_step_std":{AXIS2_PLACEMENT_2D:[5,2,1,""],AXIS2_PLACEMENT_3D:[5,2,1,""],BOOLEAN_to_bool:[5,1,1,""],BOUNDED_CURVE:[5,2,1,""],B_SPLINE_CURVE:[5,2,1,""],B_SPLINE_CURVE_WITH_KNOTS:[5,2,1,""],CARTESIAN_POINT:[5,2,1,""],CIRCLE:[5,2,1,""],CONIC:[5,2,1,""],CURVE:[5,2,1,""],DIRECTION:[5,2,1,""],EDGE:[5,2,1,""],EDGE_CURVE:[5,2,1,""],EDGE_LOOP:[5,2,1,""],ELLIPSE:[5,2,1,""],GEOMETRIC_REPRESENTATION_ITEM:[5,2,1,""],LINE:[5,2,1,""],LOOP:[5,2,1,""],ORIENTED_EDGE:[5,2,1,""],PATH:[5,2,1,""],PLACEMENT:[5,2,1,""],POINT:[5,2,1,""],REPRESENTATION_ITEM:[5,2,1,""],SEAM_CURVE:[5,2,1,""],SURFACE_CURVE:[5,2,1,""],TOPOLOGICAL_REPRESENTATION_ITEM:[5,2,1,""],VECTOR:[5,2,1,""],VERTEX:[5,2,1,""],VERTEX_POINT:[5,2,1,""],boolean_choose:[5,1,1,""],dimension_of:[5,1,1,""],list_to_array:[5,1,1,""],path_head_to_tail:[5,1,1,""]},"pylib.data_step_std.CARTESIAN_POINT":{__str__:[5,3,1,""]},"pylib.data_step_std.REPRESENTATION_ITEM":{idn:[5,4,1,""]},"pylib.data_step_std.VERTEX_POINT":{__str__:[5,3,1,""]},"pylib.date":{"gau\u00dfsche_osterformel":[6,1,1,""],ascension_of_jesus:[6,1,1,""],easter_friday:[6,1,1,""],easter_monday:[6,1,1,""],easter_sunday:[6,1,1,""],pentecost:[6,1,1,""]},"pylib.drawblock":{histogram:[7,1,1,""]},"pylib.function":{b_spline_basis:[8,1,1,""],b_spline_curve_with_knots:[8,1,1,""],b_spline_knots:[8,1,1,""],circle:[8,1,1,""],cosine_wave:[8,1,1,""],ellipse:[8,1,1,""],epitrochoid:[8,1,1,""],hypotrochoid:[8,1,1,""],sample_half_open:[8,1,1,""],sample_half_open_seq:[8,1,1,""],sine_wave:[8,1,1,""],to_str:[8,1,1,""],transformation:[8,1,1,""]},"pylib.geometry":{ArcBSplineCurveWithKnots:[9,2,1,""],ArcCircle:[9,2,1,""],ArcEllipse:[9,2,1,""],B_spline_curve_with_knots:[9,2,1,""],CS:[9,2,1,""],Circle:[9,2,1,""],Direction:[9,2,1,""],Ellipse:[9,2,1,""],Hexahedron:[9,2,1,""],Line:[9,2,1,""],Point:[9,2,1,""],Polygon:[9,2,1,""],Polyline:[9,2,1,""],Properties:[9,2,1,""],Solid:[9,2,1,""],World:[9,2,1,""],sample_half_open:[9,1,1,""]},"pylib.geometry.CS":{get_coordinates:[9,3,1,""],init_xyz:[9,3,1,""],x90:[9,3,1,""],xm90:[9,3,1,""],y90:[9,3,1,""],ym90:[9,3,1,""]},"pylib.geometry.Direction":{cross:[9,3,1,""]},"pylib.geometry.Point":{projection:[9,3,1,""]},"pylib.geometry.Polyline":{__iter__:[9,3,1,""],__repr__:[9,3,1,""],__str__:[9,3,1,""],ch_cs:[9,3,1,""],points:[9,3,1,""],rotate_x:[9,3,1,""],rotate_y:[9,3,1,""],rotate_z:[9,3,1,""],scale:[9,3,1,""],translate:[9,3,1,""],xy:[9,3,1,""],xyz:[9,3,1,""]},"pylib.geometry.Properties":{circle_sectors:[9,4,1,""]},"pylib.geometry.Solid":{ch_cs:[9,3,1,""],scale:[9,3,1,""],translate:[9,3,1,""],wireframes:[9,3,1,""]},"pylib.geometry.World":{__iter__:[9,3,1,""],__str__:[9,3,1,""],add:[9,3,1,""],bounding_box:[9,3,1,""],center:[9,3,1,""],ch_cs:[9,3,1,""],cs:[9,3,1,""],objects:[9,3,1,""],rotate_x:[9,3,1,""],rotate_y:[9,3,1,""],rotate_z:[9,3,1,""],scale:[9,3,1,""],space_diagonal:[9,3,1,""],translate:[9,3,1,""],wireframes:[9,3,1,""],wireframes_xy:[9,3,1,""],wireframes_xyz:[9,3,1,""]},"pylib.geometry2d":{angle:[10,1,1,""],cubic:[10,1,1,""],cubic_deg:[10,1,1,""],cubics:[10,1,1,""],distance:[10,1,1,""],interpolate_hermite:[10,1,1,""],line:[10,1,1,""],lines:[10,1,1,""],rectangle:[10,1,1,""],rotate:[10,1,1,""],rotate_deg:[10,1,1,""],rotate_xy:[10,1,1,""],square:[10,1,1,""],translate:[10,1,1,""],translate_xy:[10,1,1,""]},"pylib.geometry2d_plot":{plot_cubic_lines:[11,1,1,""],plot_lines:[11,1,1,""]},"pylib.geometry_plot_pylab":{cad_wireframe:[13,1,1,""],plot_post:[13,1,1,""],set_aspect_equal:[13,1,1,""],wireframe3d:[13,1,1,""]},"pylib.helper":{timeit:[14,2,1,""]},"pylib.mathematics":{lcm:[15,1,1,""],matrix:[15,2,1,""],vector:[15,2,1,""]},"pylib.mathematics.matrix":{__getitem__:[15,3,1,""],__mul__:[15,3,1,""],__repr__:[15,3,1,""],__rmul__:[15,3,1,""],__setitem__:[15,3,1,""],__str__:[15,3,1,""],rotate_x:[15,3,1,""],rotate_y:[15,3,1,""],rotate_z:[15,3,1,""],rx:[15,3,1,""],ry:[15,3,1,""],rz:[15,3,1,""],s:[15,3,1,""],scale:[15,3,1,""],t:[15,3,1,""],translate:[15,3,1,""],transpose:[15,3,1,""],transposed:[15,3,1,""],zeros:[15,3,1,""]},"pylib.mathematics.vector":{__abs__:[15,3,1,""],__add__:[15,3,1,""],__ge__:[15,3,1,""],__getitem__:[15,3,1,""],__gt__:[15,3,1,""],__iadd__:[15,3,1,""],__le__:[15,3,1,""],__lt__:[15,3,1,""],__matmul__:[15,3,1,""],__mul__:[15,3,1,""],__neg__:[15,3,1,""],__pos__:[15,3,1,""],__repr__:[15,3,1,""],__rmul__:[15,3,1,""],__str__:[15,3,1,""],__sub__:[15,3,1,""],abs:[15,3,1,""],ang:[15,3,1,""],arg:[15,3,1,""],ch_cs:[15,3,1,""],conjugate:[15,3,1,""],cross:[15,3,1,""],full:[15,3,1,""],im:[15,3,1,""],isclose:[15,3,1,""],iscloseto:[15,3,1,""],normalize:[15,3,1,""],normalized:[15,3,1,""],ones:[15,3,1,""],random:[15,3,1,""],re:[15,3,1,""],rotate_x:[15,3,1,""],rotate_y:[15,3,1,""],rotate_z:[15,3,1,""],scale:[15,3,1,""],translate:[15,3,1,""],zeros:[15,3,1,""]},"pylib.numerical":{fit:[17,0,0,"-"],integration:[18,0,0,"-"],ode:[19,0,0,"-"],ode_model:[20,0,0,"-"]},"pylib.numerical.fit":{gauss:[17,1,1,""],gauss_fit:[17,1,1,""]},"pylib.numerical.integration":{trapez:[18,1,1,""]},"pylib.numerical.ode":{e1:[19,1,1,""],e2:[19,1,1,""],e4:[19,1,1,""],fpi:[19,1,1,""],i1:[19,1,1,""],newmark_newtonraphson:[19,1,1,""],newmark_newtonraphson_mdk:[19,1,1,""]},"pylib.numerical.ode_model":{disk:[20,1,1,""]},"pylib.time_of_day":{days:[21,1,1,""],days_norm:[21,1,1,""],hours:[21,1,1,""],hours_norm:[21,1,1,""],in_seconds:[21,1,1,""],minutes:[21,1,1,""],minutes_norm:[21,1,1,""],seconds:[21,1,1,""],seconds_norm:[21,1,1,""],transform:[21,1,1,""]},pylib:{"function":[8,0,0,"-"],data:[3,0,0,"-"],data_step:[4,0,0,"-"],data_step_std:[5,0,0,"-"],date:[6,0,0,"-"],drawblock:[7,0,0,"-"],geometry2d:[10,0,0,"-"],geometry2d_plot:[11,0,0,"-"],geometry:[9,0,0,"-"],geometry_plot:[12,0,0,"-"],geometry_plot_pylab:[13,0,0,"-"],helper:[14,0,0,"-"],mathematics:[15,0,0,"-"],numerical:[16,0,0,"-"],time_of_day:[21,0,0,"-"]}},objnames:{"0":["py","module","Python module"],"1":["py","function","Python function"],"2":["py","class","Python class"],"3":["py","method","Python method"],"4":["py","attribute","Python attribute"]},objtypes:{"0":"py:module","1":"py:function","2":"py:class","3":"py:method","4":"py:attribute"},terms:{"14t14":[3,4],"1st":[4,19],"259f":8,"28ff":8,"2\u03c0f":8,"2nd":[4,19],"3x2":20,"4th":19,"9fsche_osterformel":6,"\u03bb":8,"\u03bd":8,"\u03c0":8,"\u03c6":8,"\u03c9":8,"b\u00e9zier":8,"boolean":[5,8],"case":[8,18],"char":[3,8],"class":[4,5,9,14,15],"default":[3,8,10,17,18,19,20,21],"enum":5,"f\u00fcr":6,"float":[3,5,8,10,17,18,19,20,21],"fr\u00fchling":6,"function":[1,2,3,5,9,14,15,17,18,19,20],"gau\u00dfsch":6,"gau\u00dfsche_osterformel":6,"int":[3,5,6,8,10,15,17,18,19],"korrekturgr\u00f6\u00df":6,"m\u00e4rz":6,"m\u00e4rzdatum":6,"new":[4,15,21],"return":[3,5,6,8,9,10,15,17,18,19,20,21],"s\u00e4kular":6,"s\u00e4kularzahl":6,"static":15,"switch":8,"true":[3,5,8,13,15],"vorw\u00e4rt":19,Axes:13,Das:6,For:[8,9,15,20],The:[3,4,5,8,9,10,15,18,19,20,21],Use:15,Using:[4,19],With:9,_____:8,__abs__:15,__add__:15,__contains__:15,__eq__:15,__ge__:15,__getitem__:15,__gt__:15,__iadd__:15,__imatmul__:15,__imul__:15,__isub__:15,__iter__:[9,15],__le__:15,__lt__:15,__matmul__:15,__mul__:15,__ne__:15,__neg__:15,__pos__:15,__repr__:[9,15],__rmul__:15,__setitem__:15,__str__:[5,9,15],__sub__:15,a_i:15,a_path:5,about:15,abs:15,abs_tol:15,absolut:[10,15],add:9,adding:9,addit:[4,5,10],affin:9,after:3,afterward:15,against:19,agre:5,algorithm:8,algorithmu:6,alia:8,all:4,als:6,also:8,alwai:9,amplitud:[8,17],analyt:18,ang1:9,ang2:9,ang:15,angl:[10,13],angle1:10,angle2:10,angular:8,ani:[5,8],anim:8,appear:13,appli:8,applic:5,approx:18,approxim:[17,18,19],april:6,arc:9,arc_circle_geometri:4,arcbsplinecurvewithknot:9,arccircl:9,arcellips:9,arcwis:5,area:18,arg:15,argument:[4,8,10],arithmet:3,around:[8,10,15],arrai:[3,5],ascens:6,ascension_of_jesu:6,ascii:3,associ:5,associated_geometri:5,assum:[4,10],attach:8,attribut:5,augment:9,author:[3,4],autom:5,automotive_design:[3,4],averag:21,avoid:15,axes:13,axi:[5,8,13],axis2_plac:5,axis2_placement_2d:5,axis2_placement_3d:5,axonometr:13,b_spline:4,b_spline_basi:8,b_spline_curv:5,b_spline_curve_form:5,b_spline_curve_with_knot:[5,8,9],b_spline_curve_with_knots_geometri:4,b_spline_knot:8,back:15,backward:19,base:[4,5,9,14,15,18],basi:8,basis_surfac:5,becaus:8,becom:[4,19],befor:3,begin:[8,15,19,20],beta:19,between:[3,4,8,10],binari:3,block:[3,7,8,14],bmatrix:[15,19,20],bool:[3,5,8,17,18,19],boolean_choos:5,boolean_to_bool:5,boor:8,both:[9,15],bottom:[8,10],bound:3,boundari:10,bounded_curv:5,bounding_box:9,braill:8,build:10,cad_wirefram:13,calcul:[6,8,17,21],call:8,can:[3,4,5,9,15],carbinet:13,cartesian_point:[4,5],cascad:[3,4],cauchi:19,cavali:13,cdot:[15,19,20],center:[8,9,10,13,15],ch_c:[9,15],chang:[8,10],char_set:8,charact:[7,8],characterist:8,chart:[7,8],check:[5,15],choice1:5,choice2:5,choos:19,circl:[5,8,9],circle_sector:9,circular_arc:5,clamp:[4,8],classmethod:9,clear:5,close:[3,4,8,9],closed_curv:5,cmd_str:4,code:14,column:[3,8,15],com:[5,13],comma:4,command:4,common:[3,15],complex:15,composit:18,comput:15,condit:[8,10,19],conduct:15,conic:[4,5],conjug:15,connect:5,consecut:3,consist:5,constant:3,content:[0,3],contextdecor:14,contextlib:14,control:8,control_point:[5,8,9],control_point_span:8,control_points_list:5,convert:[3,4,21],coordin:[5,9,10,15],copi:9,cos:[8,15,20],cosin:8,cosine_wav:8,counterclockwis:10,cox:8,creat:[3,4,9,15],cross:[9,15],cube:13,cubic:10,cubic_deg:10,cudb:8,current:4,curv:[4,5,8,9],curve_3d:5,curve_form:5,curvilinear:13,cycl:8,dai:[6,21],damp:19,data:[1,2,4,5,8,17],data_cmd:4,data_cmds_to_data_dict:4,data_dict:4,data_dict_edge_curve_to_geometri:4,data_dict_to_geometry_world:4,data_dict_to_geometry_world_edge_curv:4,data_section_dict:4,data_step:[1,2],data_step_std:[1,2],databas:8,date:[1,2,3,4,5,7,8,9,10,11,12,13,14,15,17,18,19,20,21],datetim:6,datum:6,days_norm:21,ddot:[19,20],decid:10,declar:5,decreas:8,def:14,defin:[5,10,15],definit:[5,18],deflect:10,deform:10,degener:3,degre:[5,8,9,10],delimit:3,delta:19,den:6,densiti:8,depend:8,der:6,derform:10,deriv:[5,19,20],des:6,describ:[8,20],descript:14,deviat:[8,17],diamet:[19,20],dict:[3,4],die:6,differ:[3,4,19],differenti:[19,20],dim:5,dimens:[8,9],dimension:3,dimension_count:5,dimension_of:5,dimenson:3,dimetr:13,dir:5,dirction:15,direct:[5,8,9,10,15],direction_ratio:5,disk:20,disk_nm:[],disk_nmmdk:[],displac:[10,19],distanc:[8,10],distribut:[4,17],divid:18,dnp:20,dnpp:20,doe:[5,8,10],domain:[5,8],dot:[7,8,15,19,20],down:[8,13],draw:7,drawblock:[1,2],drawil:8,dummi:9,each:[4,8,10],easter:6,easter_fridai:6,easter_mondai:6,easter_sundai:6,eccentr:20,edg:[5,10],edge_curv:5,edge_el:5,edge_end:5,edge_geometri:5,edge_list:5,edge_loop:5,edge_start:5,edgegeometri:5,either:[8,10,15],element:[3,8,10],elev:13,ellips:[4,5,8,9],elliptic_arc:5,empti:[3,4],emptyset:3,encod:5,end:[3,5,8,9,10,15,18,19,20],endpoint:10,endpoint_epsilon:[8,9],endsec:4,entfernung:6,entiti:5,enumer:5,epitrochoid:8,equal:[4,8,13,15,18],equalii:18,equat:[8,19,20],error:[17,19],ersten:6,etc:13,euler:19,everi:[3,19],exampl:[3,4,8,10,14,15,18,19],except:15,exchang:5,expect:17,explicit:[5,19,20],explizit:19,extent:5,exterior:8,f_n:18,factor:[8,10],fail:3,fals:[3,4,5,8,9,15,17,18,19],fassregel:18,faster:3,file:[3,4],file_descript:[3,4],file_nam:[3,4],file_schema:[3,4],filenam:3,fill:15,fill_valu:15,find:3,find_last:3,finit:5,first:[3,8,10,13,19,20],fisrt:8,fit:[2,16],fix:[8,19],flag:5,float64:17,fmdk:19,fnm:[],fold_list:3,follow:3,foral:18,form:8,formal:5,formul:19,formula:8,forward:19,found:[9,15],fourth:19,fpi:19,frac:[8,10,15,18,19],frame:8,frequenc:8,fridai:6,from:[3,4,5,8,15,19],full:[3,8,15,17],fulli:5,func:14,fwhm:17,gamma:19,gau:6,gauss:17,gauss_fit:17,gener:[5,8],geometr:5,geometri:[1,2,5,10,11,12,13],geometric_representation_item:5,geometry2d:[1,2],geometry2d_plot:[1,2],geometry_plot:[1,2,10],geometry_plot_pylab:[1,2],get:[3,9],get_coordin:9,get_id:3,gilt:6,given:[3,8,10,15,17,19],global:[10,19],global_deform:10,gov:5,govern:20,graphic:13,greater:15,gregorian:21,gregorianischen:6,half:17,hand:[9,15],happen:15,has:[3,5,15,19],hashabl:3,hat:15,have:[4,8,13,15],head:8,header:4,height:10,helper:[1,2],hermit:10,hexahedron:9,higher:8,histogram:[7,8],homogen:9,horizont:[8,10],hour:21,hours_norm:21,htm:5,html:5,http:[5,6,13],hyotrochoid:8,hyperbolic_arc:5,hypotrochoid:8,iaiweb:5,identifi:5,idn:5,ids:3,ifc_releas:5,ifcedgecurv:5,ifctopologyresourc:5,ignor:[3,8],imaginari:15,implement:5,implicit:19,implicitli:5,in_second:21,inc:10,incid:10,includ:5,increas:5,increment:19,independ:20,index:[0,3,8,10,15],index_offset:10,indic:5,industri:5,inform:[3,5,17,18,19],init_xyz:9,initi:[19,20],inner:15,insid:[4,8],instanc:5,instance_nam:4,integ:5,integr:[2,5,16],integrand:18,interior:8,intern:8,interpol:10,interpolate_hermit:10,interpret:[3,8],interv:[8,18],intev:8,isclos:15,iscloseto:15,isinst:15,iso:5,isometr:13,issequ:3,item:5,iter:[9,19],its:[5,8,9,15],jahr:6,jesu:6,johann:18,join:8,just:8,kalend:6,kalendarisch:6,kei:[4,15],keim:6,kepler:18,keplersch:18,keyword:10,knot:[5,8,9],knot_multipl:[5,9],knot_span:8,knot_spec:5,knot_typ:5,kutta:19,kwarg:[10,11],kx1:3,label:5,lag:8,lambda:[8,18],larger:15,last:[3,8],lbl:5,lcm:[8,15],ldot:[18,19],lead:8,left:[3,8,10,18],leftrightarrow:17,leg:8,len:15,length:[3,10,15,21],length_measur:5,leq:18,lexic:5,lhape:15,lhd:10,like:[8,15],limit:18,limits_:[8,18],limits_a:18,line:[3,4,5,8,9,10],line_geometri:4,linear:[8,9],lis:5,list:[3,4,5,8,9,10,15,17,18,19],list_to_arrai:5,lmax:15,lmin:15,lns:11,load:3,local:[9,19],locat:[5,15],logic:5,lookahead:4,loop:[5,8],low:5,lower:[3,15,18],lowest:15,lst:3,lvd:10,lvert:19,magnitud:[5,15],magntud:15,mai:5,major:8,make:[8,13],manifold:5,manipul:3,march:6,mass:19,master_represent:5,match:4,mathbf:[8,9,15,20],mathemat:[1,2,8,9],mathmat:20,mathrm:[8,17,18,19],matplotlib:[11,12,13],matrix:[9,15],max:8,max_iter:19,maximum:[17,19],mean:[8,19],meassur:14,method:[5,19,20],militari:13,min:8,minor:8,minumum:3,minut:21,minutes_norm:21,model:[3,4,20],modul:[0,1,2,16],modulu:15,mondai:6,mondparamet:6,mondschaltung:6,move:[8,15],multi:3,multipl:[5,8,15],multiview:13,must:[3,8],mxn:[3,15],name:5,ndarrai:17,necessari:18,necessarili:18,neg:4,newline_replac:3,newmark:19,newmark_newtonraphson:[19,20],newmark_newtonraphson_mdk:[19,20],newmark_newtonraphson_rdk:[],nmmdk:20,node:10,non:[5,8],none:[3,5,7,8,9,10,14,15,17,18],nonperiod:8,nonsens:15,norm:[8,15],normal:[8,9,15,21],note:15,number:[4,5,8,10,15,18,19],numer:[1,2],numerisch:18,numpi:17,obj:3,object:[3,4,5,9,10,14,15],object_data:3,obliqu:13,occur:[3,8],ode:[2,16,20],ode_model:[2,16],offset:[17,21],often:8,omega:8,one:[3,4,8,10,13,19],ones:15,onli:[3,4],open:[3,4,8,9],oppos:5,opposit:5,option:[8,10],order:[8,10,19,20],ordinari:[8,19,20],org:6,orient:5,oriented_edg:5,origin:[10,15],orthogon:[9,15],orthograph:[9,13],oscil:8,osterentfernung:6,osterformel:6,ostergrenz:6,ostersonntag:6,other:[10,15],otherwis:[8,10],otim:15,out:14,outer:15,outsid:8,over:[4,8],own:9,packag:[0,1],page:0,parabolic_arc:5,parallel:13,paramet:[3,5,6,8,10,13,14,15,17,18,19,20,21],parameter_valu:5,parenthesi:4,part:[4,5,8,15],particular:8,pass:[],path:5,path_head_to_tail:5,pattern:[3,8],pcurve_or_surfac:5,peak:8,pentecost:6,per:[3,8,19],perform:15,period:8,perspect:13,phase:[8,15],phi:[8,20],piecewise_bezier_knot:5,pixel:8,placement:5,plan:13,plane:[9,10],plot:[8,10,13],plot_cubic_lin:11,plot_lin:[10,11],plot_post:13,plotter:[11,12,13],pmatrix:15,pnt:5,point1:[9,10],point1_i:10,point1_x:10,point2:[9,10],point2_i:10,point2_x:10,point3:[9,10],point4:[9,10],point5:9,point6:9,point7:9,point8:9,point:[5,8,9,10,13,18,19],point_i:10,point_x:10,pointer_to_new_created_point_object:4,pointer_to_new_created_vertex_object:4,points1_i:10,polygon:[9,10],polygonzugverfahren:19,polylin:[8,9],polyline_form:5,popt:17,posit:[5,8,17],position_norm:21,positive_length_measur:5,possibl:13,preferred_surface_curve_represent:5,print:[3,10,14,15,18,19],print_edge_loop:4,print_list:3,problem:[19,20],processor:[3,4],product:[5,9,15],program:3,project:[9,13],propag:8,properti:9,proport:19,proportion:8,proposit:5,protocol:5,pts:10,pylab:[11,12,13],qquad:19,quad:[18,19,20],quadratur:18,quasi:8,quasi_uniform_knot:5,r2x3_final:5,rac:[],radian:[8,10],radiu:[5,8,9],random:15,rang:[8,15,21],rate:8,rdx:20,rdxp:20,read:[3,4],read_column:3,reader:4,real:[5,15],rectangl:10,recurs:8,reduct:20,ref_direct:5,refer:[5,8],rel_tol:15,relat:8,remov:[3,4],repeat:8,repesent:9,replac:3,repr:[9,15],repres:8,represent:5,representation_item:5,res:5,residuum:19,resourc:5,result:[3,4,8,15],rhd:10,right:[3,8,9,10,15,18],rkx:20,rmx:20,rmxpp:20,roation:10,roll:8,rotat:[10,15,20],rotate_deg:10,rotate_i:[9,15],rotate_x:[9,15],rotate_xi:10,rotate_z:[9,15],rotation_plan:10,row:[8,15],rule:[9,15,18],rung:19,rvd:10,rvert:19,s_x:15,s_y:15,s_z:15,said:8,same:[3,5],same_sens:5,samesens:5,sampl:10,sample_half_open:[8,9],sample_half_open_seq:8,sample_point1_x:10,sample_point2_i:10,sample_point2_x:10,sample_points1_i:10,satisfi:8,save_valu:18,scalar:15,scale:[8,9,13,15],scale_horizont:8,scale_i:10,scale_vert:8,scale_x:10,sche:19,schema:5,seam_curv:5,search:[0,3],second:[3,8,10,19,20,21],seconds_norm:21,section:4,section_test:14,see:15,segment:18,select:5,self:[5,9,15],self_intersect:5,semi:8,semi_axis_1:5,semi_axis_2:5,sens:5,seper:4,seq:3,sequenc:3,set:[3,5,8,15,19],set_aspect:13,set_aspect_equ:13,sever:4,shall:5,shape:[3,4,5],shift:8,shift_horizont:8,shift_vert:8,should:[10,15],side:18,sigma:17,simpson:18,simpsonregel:18,sin:[8,15,20],sine:8,sine_wav:8,sinusoid:8,six:[],size:[3,10,15,19],slope:10,smaller:15,smooth:8,solid:[9,10],solut:[13,18,19],solv:19,solver:19,some:8,sonnenschaltung:6,sonntag:6,sourc:[3,4,5,6,7,8,9,10,11,13,14,15,17,18,19,20,21],space:[8,9,18],space_diagon:9,spacial:6,span:8,spatial:[5,8],special:[5,18],specif:8,specifi:[8,18],speed:8,sphere:13,spline:[8,9],split:4,sqrt:[15,17],squar:[10,19],stabl:19,stackoverflow:13,standard:[5,17,19],start:[3,5,8,9,10],std:5,step:[3,4,5,19],steptool:5,stiff:19,stop:3,store:3,stp_aim:5,str:[3,5,8,9,14,15],str_between:3,str_to_cmd_arg:4,str_to_list:3,straight:10,string:[3,4,5,8,10],stripe:3,struct_tim:21,structur:[3,5,8],subinterv:18,submodul:1,subpackag:1,subtyp:5,sum:[8,15,18],sundai:6,support:8,surfac:5,surface_curv:5,symbol:7,system:[5,9,10,15,19,20],t_0:19,t_axis2_placement_2d:5,t_axis2_placement_3d:5,t_b_spline_curv:5,t_b_spline_curve_with_knot:5,t_boolean_choos:5,t_bounded_curv:5,t_cartesian_point:5,t_circl:5,t_conic:5,t_curv:5,t_dimension_of:5,t_direct:5,t_edg:5,t_edge_curv:5,t_edge_loop:5,t_ellips:5,t_geometric_representation_item:5,t_i:19,t_line:5,t_list_to_arrai:5,t_loop:5,t_n:19,t_oriented_edg:5,t_path:5,t_path_head_to_tail:5,t_placement:5,t_point:5,t_representation_item:5,t_seam_curv:5,t_surface_curv:5,t_topological_representation_item:5,t_vector:5,t_vertex:5,t_vertex_point:5,t_x:15,t_y:15,t_z:15,tabl:10,tagen:6,tangent:8,term:3,test:15,text:[3,5,8,19],tfrac:19,than:[3,10,15],therefor:[15,19],theta:[8,9,15],thi:[3,4,5,8,9,10,13,15,20],thick:19,thicker:8,third:13,thoma:18,three:20,ti1:19,time:[8,9,14,15,19,20,21],time_norm:21,time_of_dai:[1,2],timeit:14,to_str:8,todo:8,togeth:8,tol:19,toler:19,took:14,top:[10,13],topolog:5,topological_representation_item:5,torqu:20,total:5,touch:8,transform:[8,9,15,21],translat:[9,10,15],translate_xi:10,transpos:15,trapez:18,trapezium:18,trapezoid:18,trapezregel:18,trim:5,trimetri:13,tupl:[3,5,8,10,17],two:[3,10,18],type:[3,4,5,6,8,10,15,17,18,20,21],typr:8,u_0:8,u_1:8,u_2:8,u_i:[8,15],u_m:8,u_n:8,u_p:8,u_x:15,u_z:15,uid:3,unbound:5,unhash:3,unicod:8,uniform:[8,15],uniform_knot:5,uniqu:3,unique_end:3,unique_list:3,unique_list_hash:3,unit:8,unknown:[3,4],unspecifi:5,upper:[3,18],upper_index_on_control_point:5,upper_index_on_knot:5,upsid:8,usag:[8,15],use:[15,20],used:[5,14,17],uses:8,using:[3,8,11,12,13,18],usw:6,v_x:15,v_y:15,v_z:15,valu:[4,5,8,15,17,18,19,20,21],varepsilon:19,variabl:[5,6,8,18],varianc:17,varphi:[8,20],vec:10,vector:[5,8,9,10,15],veloc:19,verbos:[3,4,17,18,19],verfahren:19,vert_0:18,vert_a:18,vertcal:10,vertex:5,vertex_geometri:5,vertex_point:[4,5],vertic:[5,8,10,17],view:8,vmatrix:20,vollmond:6,von:6,w_x:15,w_y:15,w_z:15,wave:8,wavelength:8,wavenumb:8,what:10,when:[8,15],where:[8,15,17],whether:5,which:[4,5,8,19],width:[8,10,17],wiki:6,wikipedia:6,window:8,wirefram:9,wireframe3d:13,wireframes_xi:9,wireframes_xyz:9,wise:10,work:13,world:[9,13],wrap:[3,4],write:3,wrong:15,www:5,x90:9,x_0:[8,18,19],x_1:[8,10,18,19,20],x_2:[10,18,19,20],x_3:20,x_4:20,x_5:20,x_6:20,x_column:3,x_fit:17,x_i:[18,19],x_n:18,xm90:9,xp0:19,xp1:20,xp2:20,xp3:20,xp4:20,xp5:20,xp6:20,xpn:20,xpp0:19,xppn:20,xyz:9,y90:9,y_0:19,y_1:10,y_2:10,y_column:3,y_fit:17,year:[6,21],ym90:9,zero:[5,8,15]},titles:["Welcome to pylib\u2019s documentation!","pylib","pylib package","pylib.data module","pylib.data_step module","pylib.data_step_std module","pylib.date module","pylib.drawblock module","pylib.function module","pylib.geometry module","pylib.geometry2d module","pylib.geometry2d_plot module","pylib.geometry_plot module","pylib.geometry_plot_pylab module","pylib.helper module","pylib.mathematics module","pylib.numerical package","pylib.numerical.fit module","pylib.numerical.integration module","pylib.numerical.ode module","pylib.numerical.ode_model module","pylib.time_of_day module"],titleterms:{"function":8,data:3,data_step:4,data_step_std:5,date:6,document:0,drawblock:7,fit:17,geometri:9,geometry2d:10,geometry2d_plot:11,geometry_plot:12,geometry_plot_pylab:13,helper:14,indic:0,integr:18,mathemat:15,modul:[3,4,5,6,7,8,9,10,11,12,13,14,15,17,18,19,20,21],numer:[16,17,18,19,20],ode:19,ode_model:20,packag:[2,16],pylib:[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21],submodul:[2,16],subpackag:2,tabl:0,time_of_dai:21,welcom:0}}) \ No newline at end of file +Search.setIndex({docnames:["index","modules","pylib","pylib.data","pylib.data_step","pylib.data_step_std","pylib.date","pylib.drawblock","pylib.function","pylib.geometry","pylib.geometry2d","pylib.geometry2d_plot","pylib.geometry_plot","pylib.geometry_plot_pylab","pylib.helper","pylib.mathematics","pylib.numerical","pylib.numerical.fit","pylib.numerical.integration","pylib.numerical.ode","pylib.numerical.ode_model","pylib.time_of_day","pylib.tui"],envversion:{"sphinx.domains.c":1,"sphinx.domains.changeset":1,"sphinx.domains.citation":1,"sphinx.domains.cpp":1,"sphinx.domains.javascript":1,"sphinx.domains.math":2,"sphinx.domains.python":1,"sphinx.domains.rst":1,"sphinx.domains.std":1,"sphinx.ext.viewcode":1,sphinx:56},filenames:["index.rst","modules.rst","pylib.rst","pylib.data.rst","pylib.data_step.rst","pylib.data_step_std.rst","pylib.date.rst","pylib.drawblock.rst","pylib.function.rst","pylib.geometry.rst","pylib.geometry2d.rst","pylib.geometry2d_plot.rst","pylib.geometry_plot.rst","pylib.geometry_plot_pylab.rst","pylib.helper.rst","pylib.mathematics.rst","pylib.numerical.rst","pylib.numerical.fit.rst","pylib.numerical.integration.rst","pylib.numerical.ode.rst","pylib.numerical.ode_model.rst","pylib.time_of_day.rst","pylib.tui.rst"],objects:{"":{"function":[8,0,0,"-"],data:[3,0,0,"-"],data_step:[4,0,0,"-"],data_step_std:[5,0,0,"-"],date:[6,0,0,"-"],drawblock:[7,0,0,"-"],fit:[17,0,0,"-"],geometry2d:[10,0,0,"-"],geometry2d_plot:[11,0,0,"-"],geometry:[9,0,0,"-"],geometry_plot:[12,0,0,"-"],geometry_plot_pylab:[13,0,0,"-"],helper:[14,0,0,"-"],integration:[18,0,0,"-"],mathematics:[15,0,0,"-"],ode:[19,0,0,"-"],ode_model:[20,0,0,"-"],pylib:[2,0,0,"-"],time_of_day:[21,0,0,"-"],tui:[22,0,0,"-"]},"pylib.data":{find_last:[3,1,1,""],fold_list:[3,1,1,""],get_id:[3,1,1,""],issequence:[3,1,1,""],load:[3,1,1,""],print_list:[3,1,1,""],read:[3,1,1,""],read_columns:[3,1,1,""],seq:[3,1,1,""],store:[3,1,1,""],str_between:[3,1,1,""],str_to_list:[3,1,1,""],unique_ending:[3,1,1,""],unique_list:[3,1,1,""],unique_list_hashable:[3,1,1,""],write:[3,1,1,""]},"pylib.data_step":{arc_circle_geometry:[4,1,1,""],b_spline_curve_with_knots_geometry:[4,1,1,""],data_cmds_to_data_dict:[4,1,1,""],data_dict_edge_curve_to_geometry:[4,1,1,""],data_dict_to_geometry_world:[4,1,1,""],data_dict_to_geometry_world_edge_curve:[4,1,1,""],data_section_dict:[4,1,1,""],line_geometry:[4,1,1,""],print_edge_loop:[4,1,1,""],step:[4,2,1,""],str_to_cmd_args:[4,1,1,""]},"pylib.data_step_std":{AXIS2_PLACEMENT_2D:[5,2,1,""],AXIS2_PLACEMENT_3D:[5,2,1,""],BOOLEAN_to_bool:[5,1,1,""],BOUNDED_CURVE:[5,2,1,""],B_SPLINE_CURVE:[5,2,1,""],B_SPLINE_CURVE_WITH_KNOTS:[5,2,1,""],CARTESIAN_POINT:[5,2,1,""],CIRCLE:[5,2,1,""],CONIC:[5,2,1,""],CURVE:[5,2,1,""],DIRECTION:[5,2,1,""],EDGE:[5,2,1,""],EDGE_CURVE:[5,2,1,""],EDGE_LOOP:[5,2,1,""],ELLIPSE:[5,2,1,""],GEOMETRIC_REPRESENTATION_ITEM:[5,2,1,""],LINE:[5,2,1,""],LOOP:[5,2,1,""],ORIENTED_EDGE:[5,2,1,""],PATH:[5,2,1,""],PLACEMENT:[5,2,1,""],POINT:[5,2,1,""],REPRESENTATION_ITEM:[5,2,1,""],SEAM_CURVE:[5,2,1,""],SURFACE_CURVE:[5,2,1,""],TOPOLOGICAL_REPRESENTATION_ITEM:[5,2,1,""],VECTOR:[5,2,1,""],VERTEX:[5,2,1,""],VERTEX_POINT:[5,2,1,""],boolean_choose:[5,1,1,""],dimension_of:[5,1,1,""],list_to_array:[5,1,1,""],path_head_to_tail:[5,1,1,""]},"pylib.data_step_std.CARTESIAN_POINT":{__str__:[5,3,1,""]},"pylib.data_step_std.REPRESENTATION_ITEM":{idn:[5,4,1,""]},"pylib.data_step_std.VERTEX_POINT":{__str__:[5,3,1,""]},"pylib.date":{"gau\u00dfsche_osterformel":[6,1,1,""],ascension_of_jesus:[6,1,1,""],easter_friday:[6,1,1,""],easter_monday:[6,1,1,""],easter_sunday:[6,1,1,""],pentecost:[6,1,1,""]},"pylib.drawblock":{histogram:[7,1,1,""]},"pylib.function":{b_spline_basis:[8,1,1,""],b_spline_curve_with_knots:[8,1,1,""],b_spline_knots:[8,1,1,""],circle:[8,1,1,""],cosine_wave:[8,1,1,""],ellipse:[8,1,1,""],epitrochoid:[8,1,1,""],hypotrochoid:[8,1,1,""],sample_half_open:[8,1,1,""],sample_half_open_seq:[8,1,1,""],sine_wave:[8,1,1,""],to_str:[8,1,1,""],transformation:[8,1,1,""]},"pylib.geometry":{ArcBSplineCurveWithKnots:[9,2,1,""],ArcCircle:[9,2,1,""],ArcEllipse:[9,2,1,""],B_spline_curve_with_knots:[9,2,1,""],CS:[9,2,1,""],Circle:[9,2,1,""],Direction:[9,2,1,""],Ellipse:[9,2,1,""],Hexahedron:[9,2,1,""],Line:[9,2,1,""],Point:[9,2,1,""],Polygon:[9,2,1,""],Polyline:[9,2,1,""],Properties:[9,2,1,""],Solid:[9,2,1,""],World:[9,2,1,""],sample_half_open:[9,1,1,""]},"pylib.geometry.CS":{get_coordinates:[9,3,1,""],init_xyz:[9,3,1,""],x90:[9,3,1,""],xm90:[9,3,1,""],y90:[9,3,1,""],ym90:[9,3,1,""]},"pylib.geometry.Direction":{cross:[9,3,1,""]},"pylib.geometry.Point":{projection:[9,3,1,""]},"pylib.geometry.Polyline":{__iter__:[9,3,1,""],__repr__:[9,3,1,""],__str__:[9,3,1,""],ch_cs:[9,3,1,""],points:[9,3,1,""],rotate_x:[9,3,1,""],rotate_y:[9,3,1,""],rotate_z:[9,3,1,""],scale:[9,3,1,""],translate:[9,3,1,""],xy:[9,3,1,""],xyz:[9,3,1,""]},"pylib.geometry.Properties":{circle_sectors:[9,4,1,""]},"pylib.geometry.Solid":{ch_cs:[9,3,1,""],scale:[9,3,1,""],translate:[9,3,1,""],wireframes:[9,3,1,""]},"pylib.geometry.World":{__iter__:[9,3,1,""],__str__:[9,3,1,""],add:[9,3,1,""],bounding_box:[9,3,1,""],center:[9,3,1,""],ch_cs:[9,3,1,""],cs:[9,3,1,""],objects:[9,3,1,""],rotate_x:[9,3,1,""],rotate_y:[9,3,1,""],rotate_z:[9,3,1,""],scale:[9,3,1,""],space_diagonal:[9,3,1,""],translate:[9,3,1,""],wireframes:[9,3,1,""],wireframes_xy:[9,3,1,""],wireframes_xyz:[9,3,1,""]},"pylib.geometry2d":{angle:[10,1,1,""],cubic:[10,1,1,""],cubic_deg:[10,1,1,""],cubics:[10,1,1,""],distance:[10,1,1,""],interpolate_hermite:[10,1,1,""],line:[10,1,1,""],lines:[10,1,1,""],rectangle:[10,1,1,""],rotate:[10,1,1,""],rotate_deg:[10,1,1,""],rotate_xy:[10,1,1,""],square:[10,1,1,""],translate:[10,1,1,""],translate_xy:[10,1,1,""]},"pylib.geometry2d_plot":{plot_cubic_lines:[11,1,1,""],plot_lines:[11,1,1,""]},"pylib.geometry_plot_pylab":{cad_wireframe:[13,1,1,""],plot_post:[13,1,1,""],set_aspect_equal:[13,1,1,""],wireframe3d:[13,1,1,""]},"pylib.helper":{cd:[14,2,1,""],run_file:[14,1,1,""],timeit:[14,2,1,""]},"pylib.mathematics":{lcm:[15,1,1,""],matrix:[15,2,1,""],vector:[15,2,1,""]},"pylib.mathematics.matrix":{__getitem__:[15,3,1,""],__mul__:[15,3,1,""],__repr__:[15,3,1,""],__rmul__:[15,3,1,""],__setitem__:[15,3,1,""],__str__:[15,3,1,""],rotate_x:[15,3,1,""],rotate_y:[15,3,1,""],rotate_z:[15,3,1,""],rx:[15,3,1,""],ry:[15,3,1,""],rz:[15,3,1,""],s:[15,3,1,""],scale:[15,3,1,""],t:[15,3,1,""],translate:[15,3,1,""],transpose:[15,3,1,""],transposed:[15,3,1,""],zeros:[15,3,1,""]},"pylib.mathematics.vector":{__abs__:[15,3,1,""],__add__:[15,3,1,""],__ge__:[15,3,1,""],__getitem__:[15,3,1,""],__gt__:[15,3,1,""],__iadd__:[15,3,1,""],__le__:[15,3,1,""],__lt__:[15,3,1,""],__matmul__:[15,3,1,""],__mul__:[15,3,1,""],__neg__:[15,3,1,""],__pos__:[15,3,1,""],__repr__:[15,3,1,""],__rmul__:[15,3,1,""],__str__:[15,3,1,""],__sub__:[15,3,1,""],abs:[15,3,1,""],ang:[15,3,1,""],arg:[15,3,1,""],ch_cs:[15,3,1,""],conjugate:[15,3,1,""],cross:[15,3,1,""],full:[15,3,1,""],im:[15,3,1,""],isclose:[15,3,1,""],iscloseto:[15,3,1,""],normalize:[15,3,1,""],normalized:[15,3,1,""],ones:[15,3,1,""],random:[15,3,1,""],re:[15,3,1,""],rotate_x:[15,3,1,""],rotate_y:[15,3,1,""],rotate_z:[15,3,1,""],scale:[15,3,1,""],translate:[15,3,1,""],zeros:[15,3,1,""]},"pylib.numerical":{fit:[17,0,0,"-"],integration:[18,0,0,"-"],ode:[19,0,0,"-"],ode_model:[20,0,0,"-"]},"pylib.numerical.fit":{gauss:[17,1,1,""],gauss_fit:[17,1,1,""]},"pylib.numerical.integration":{trapez:[18,1,1,""]},"pylib.numerical.ode":{e1:[19,1,1,""],e2:[19,1,1,""],e4:[19,1,1,""],fpi:[19,1,1,""],i1:[19,1,1,""],newmark_newtonraphson:[19,1,1,""],newmark_newtonraphson_mdk:[19,1,1,""]},"pylib.numerical.ode_model":{disk:[20,1,1,""]},"pylib.time_of_day":{days:[21,1,1,""],days_norm:[21,1,1,""],hours:[21,1,1,""],hours_norm:[21,1,1,""],in_seconds:[21,1,1,""],minutes:[21,1,1,""],minutes_norm:[21,1,1,""],seconds:[21,1,1,""],seconds_norm:[21,1,1,""],transform:[21,1,1,""]},"pylib.tui":{StdOutWrapper:[22,2,1,""],TUI:[22,2,1,""],Window:[22,2,1,""],newwin:[22,1,1,""]},"pylib.tui.StdOutWrapper":{get_text:[22,3,1,""],text:[22,4,1,""],write:[22,3,1,""]},"pylib.tui.TUI":{clear:[22,3,1,""],color_def:[22,3,1,""],color_table:[22,3,1,""],end:[22,3,1,""],getch:[22,3,1,""],refresh:[22,3,1,""]},"pylib.tui.Window":{border:[22,3,1,""],clear:[22,3,1,""],derwin:[22,3,1,""],getch:[22,3,1,""],getmaxyx:[22,3,1,""],initscr:[22,3,1,""],instr:[22,3,1,""],refresh:[22,3,1,""],text:[22,3,1,""],textbox:[22,3,1,""]},pylib:{"function":[8,0,0,"-"],data:[3,0,0,"-"],data_step:[4,0,0,"-"],data_step_std:[5,0,0,"-"],date:[6,0,0,"-"],drawblock:[7,0,0,"-"],geometry2d:[10,0,0,"-"],geometry2d_plot:[11,0,0,"-"],geometry:[9,0,0,"-"],geometry_plot:[12,0,0,"-"],geometry_plot_pylab:[13,0,0,"-"],helper:[14,0,0,"-"],mathematics:[15,0,0,"-"],numerical:[16,0,0,"-"],time_of_day:[21,0,0,"-"],tui:[22,0,0,"-"]}},objnames:{"0":["py","module","Python module"],"1":["py","function","Python function"],"2":["py","class","Python class"],"3":["py","method","Python method"],"4":["py","attribute","Python attribute"]},objtypes:{"0":"py:module","1":"py:function","2":"py:class","3":"py:method","4":"py:attribute"},terms:{"14t14":[3,4],"1st":[4,19],"259f":8,"28ff":8,"2\u03c0f":8,"2nd":[4,19],"3x2":20,"4th":19,"9fsche_osterformel":6,"\u03bb":8,"\u03bd":8,"\u03c0":8,"\u03c6":8,"\u03c9":8,"b\u00e9zier":8,"boolean":[5,8],"case":[8,18],"catch":22,"char":[3,8,22],"class":[4,5,9,14,15,22],"default":[3,8,10,17,18,19,20,21,22],"enum":5,"f\u00fcr":6,"float":[3,5,8,10,17,18,19,20,21],"fr\u00fchling":6,"function":[1,2,3,5,9,14,15,17,18,19,20],"gau\u00dfsch":6,"gau\u00dfsche_osterformel":6,"int":[3,5,6,8,10,15,17,18,19,22],"korrekturgr\u00f6\u00df":6,"m\u00e4rz":6,"m\u00e4rzdatum":6,"new":[4,15,21,22],"return":[3,5,6,8,9,10,15,17,18,19,20,21,22],"s\u00e4kular":6,"s\u00e4kularzahl":6,"static":15,"switch":8,"true":[3,5,8,13,15,22],"vorw\u00e4rt":19,Axes:13,Das:6,For:[0,8,9,15,20],The:[0,3,4,5,8,9,10,15,18,19,20,21,22],Use:15,Using:[4,19],With:9,_____:8,__abs__:15,__add__:15,__contains__:15,__eq__:15,__ge__:15,__getitem__:15,__gt__:15,__iadd__:15,__imatmul__:15,__imul__:15,__isub__:15,__iter__:[9,15],__le__:15,__lt__:15,__matmul__:15,__mul__:15,__ne__:15,__neg__:15,__pos__:15,__repr__:[9,15],__rmul__:15,__setitem__:15,__stderr__:22,__stdout__:22,__str__:[5,9,15],__sub__:15,a_i:15,a_path:5,about:15,abs:15,abs_tol:15,absolut:[10,15],activ:0,add:[9,22],adding:9,addit:[4,5,10],affin:9,after:[3,14],afterward:15,against:19,agre:5,algorithm:8,algorithmu:6,alia:8,all:[4,22],als:6,also:[0,8,22],alwai:9,amplitud:[8,17],anaconda:0,analyt:18,ang1:9,ang2:9,ang:15,angl:[10,13],angle1:10,angle2:10,angular:8,ani:[5,8],anim:8,appear:13,appli:8,applic:5,approx:18,approxim:[17,18,19],april:6,arc:9,arc_circle_geometri:4,arcbsplinecurvewithknot:9,arccircl:9,arcellips:9,arcwis:5,area:18,arg:15,argument:[4,8,10],arithmet:3,around:[8,10,15,22],arrai:[3,5],ascens:6,ascension_of_jesu:6,ascii:3,associ:5,associated_geometri:5,assum:[4,10],attach:8,attribut:[5,22],augment:9,author:[3,4],autom:5,automotive_design:[3,4],avail:22,averag:21,avoid:15,axes:13,axi:[5,8,13],axis2_plac:5,axis2_placement_2d:5,axis2_placement_3d:5,axonometr:13,b_spline:4,b_spline_basi:8,b_spline_curv:5,b_spline_curve_form:5,b_spline_curve_with_knot:[5,8,9],b_spline_curve_with_knots_geometri:4,b_spline_knot:8,back:[14,15,22],background:22,backward:19,base:[0,4,5,9,14,15,18,22],basi:8,basis_surfac:5,bat:0,becaus:8,becom:[4,19],befor:[3,14],begin:[8,15,19,20,22],beta:19,between:[3,4,8,10],binari:3,block:[0,3,7,8,14],bmatrix:[15,19,20],bool:[3,5,8,17,18,19],boolean_choos:5,boolean_to_bool:5,boor:8,border:22,both:[9,15],bottom:[8,10,22],bound:3,boundari:10,bounded_curv:5,bounding_box:9,braill:[0,8],build:[0,10],cad_wirefram:13,calcul:[6,8,17,21],call:8,can:[0,3,4,5,9,15,22],carbinet:13,cartesian_point:[4,5],cascad:[3,4],cauchi:19,cavali:13,cdot:[15,19,20],center:[8,9,10,13,15],ch_c:[9,15],chang:[8,10,14],char_set:8,charact:[0,7,8,22],characterist:8,chart:[0,7,8],check:[5,15,22],choice1:5,choice2:5,choos:19,circl:[5,8,9],circle_sector:9,circular_arc:5,clamp:[4,8],classmethod:9,clean:22,clear:[5,22],close:[3,4,8,9],closed_curv:5,cmd_str:4,code:14,color:22,color_def:22,color_pair:22,color_t:22,column:[3,8,15,22],com:[0,5,13,22],comma:4,command:4,common:[3,15],complex:15,composit:18,comput:15,conda:0,condabin:0,condit:[8,10,19],conduct:15,conic:[4,5],conjug:15,connect:5,consecut:3,consist:5,consol:22,constant:3,content:[0,3,22],context:14,contextdecor:14,contextlib:14,control:8,control_point:[5,8,9],control_point_span:8,control_points_list:5,convert:[3,4,21],coordin:[5,9,10,15,22],copi:9,corner:22,cos:[8,15,20],cosin:8,cosine_wav:8,counterclockwis:10,cox:8,creat:[3,4,9,15],cross:[9,15],cube:13,cubic:10,cubic_deg:10,cudb:8,current:[4,14],curs:[0,22],curv:[4,5,8,9],curve_3d:5,curve_form:5,curvilinear:13,cycl:8,dai:[6,21],damp:19,data:[1,2,4,5,8,17],data_cmd:4,data_cmds_to_data_dict:4,data_dict:4,data_dict_edge_curve_to_geometri:4,data_dict_to_geometry_world:4,data_dict_to_geometry_world_edge_curv:4,data_section_dict:4,data_step:[1,2],data_step_std:[1,2],databas:8,date:[1,2,3,4,5,7,8,9,10,11,12,13,14,15,17,18,19,20,21,22],datetim:6,datum:6,days_norm:21,ddot:[19,20],decid:10,declar:5,decor:22,decreas:8,def:14,defin:[5,10,15],definit:[5,18],deflect:10,deform:10,degener:3,degre:[5,8,9,10],delai:22,delimit:3,delta:19,den:6,densiti:8,depend:8,der:6,derform:10,deriv:[5,19,20],derwin:22,des:6,describ:[8,20],descript:14,deviat:[8,17],diamet:[19,20],dict:[3,4],die:6,differ:[3,4,19],differenti:[19,20],dim:5,dimens:[8,9],dimension:3,dimension_count:5,dimension_of:5,dimenson:3,dimetr:13,dir:5,dirction:15,direct:[5,8,9,10,15],direction_ratio:5,directli:0,directori:14,disk:20,disk_nm:[],disk_nmmdk:[],displac:[10,19],distanc:[8,10],distribut:[4,17],divid:18,dnp:20,dnpp:20,doe:[5,8,10],domain:[5,8],dot:[7,8,15,19,20],dottet:0,down:[8,13],draw:[0,7,22],drawblock:[0,1,2],drawil:[0,8],dummi:9,each:[4,8,10,22],easter:6,easter_fridai:6,easter_mondai:6,easter_sundai:6,eccentr:20,edg:[5,10],edge_curv:5,edge_el:5,edge_end:5,edge_geometri:5,edge_list:5,edge_loop:5,edge_start:5,edgegeometri:5,either:[8,10,15],element:[3,8,10,22],elev:13,ellips:[4,5,8,9],elliptic_arc:5,empti:[3,4],emptyset:3,encapsul:22,encod:5,end:[3,5,8,9,10,15,18,19,20,22],endpoint:10,endpoint_epsilon:[8,9],endsec:4,endwin:22,enter:14,entfernung:6,entiti:5,enumer:5,epitrochoid:8,equal:[4,8,13,15,18],equalii:18,equat:[8,19,20],error:[17,19],ersten:6,etc:13,euler:19,everi:[3,19,22],exampl:[0,3,4,8,10,14,15,18,19,22],except:15,exchang:5,excut:14,execut:14,exit:22,expect:17,explicit:[5,19,20],explizit:19,extent:5,exterior:8,f_n:18,factor:[8,10],fail:3,fals:[3,4,5,8,9,15,17,18,19,22],fassregel:18,faster:3,file:[3,4,14],file_descript:[3,4],file_nam:[3,4,14],file_schema:[3,4],filenam:3,fill:15,fill_valu:15,find:3,find_last:3,finit:5,first:[3,8,10,13,19,20],fisrt:8,fit:[2,16],fix:[8,19],flag:5,float64:17,fmdk:19,fnm:[],fold_list:3,follow:3,font:0,foo:22,footer:22,footer_left:22,footer_right:22,foral:18,form:8,formal:5,formul:19,formula:8,forward:19,found:[9,15],fourth:19,fpi:19,frac:[8,10,15,18,19],frame:8,frequenc:8,fridai:6,from:[3,4,5,8,15,19,22],full:[3,8,15,17],fulli:5,func:14,fwhm:17,gamma:19,gau:6,gauss:17,gauss_fit:17,gener:[5,8],geometr:5,geometri:[1,2,5,10,11,12,13],geometric_representation_item:5,geometry2d:[1,2],geometry2d_plot:[1,2],geometry_plot:[1,2,10],geometry_plot_pylab:[1,2],get:[3,9],get_coordin:9,get_id:3,get_text:22,getch:22,getmaxyx:22,gilt:6,github:0,given:[3,8,10,15,17,19],global:[10,19],global_deform:10,gothic:0,gov:5,govern:20,graphic:13,greater:15,gregorian:21,gregorianischen:6,half:17,hand:[9,15],happen:15,has:[3,5,15,19],has_color:22,hashabl:3,hat:15,have:[4,8,13,15],head:8,header:4,height:[10,22],help:22,helper:[1,2],here:22,hermit:10,hexahedron:9,higher:8,histogram:[0,7,8],homogen:9,horizont:[8,10,22],hour:21,hours_norm:21,htm:5,html:5,http:[0,5,6,13,22],hyotrochoid:8,hyperbolic_arc:5,hypotrochoid:8,iaiweb:5,identifi:5,idn:5,ids:3,ifc_releas:5,ifcedgecurv:5,ifctopologyresourc:5,ignor:[3,8],imaginari:15,implement:5,implicit:19,implicitli:5,in_second:21,inc:10,incid:10,includ:5,increas:5,increment:19,independ:20,index:[0,3,8,10,15],index_offset:10,indic:5,industri:5,inform:[3,5,17,18,19],init_xyz:9,initi:[19,20],initscr:22,inner:15,insid:[4,8,14],instal:0,instanc:5,instance_nam:4,instr:22,integ:5,integr:[2,5,16],integrand:18,interfac:[0,22],interior:8,intern:8,interpol:10,interpolate_hermit:10,interpret:[3,8,14],interv:[8,18],intev:8,isclos:15,iscloseto:15,isinst:15,iso:5,isometr:13,issequ:3,item:5,iter:[9,19],its:[5,8,9,15],jahr:6,jesu:6,johann:18,join:8,just:8,kalend:6,kalendarisch:6,keep:22,kei:[4,15],keim:6,kepler:18,keplersch:18,keyword:10,knot:[5,8,9],knot_multipl:[5,9],knot_span:8,knot_spec:5,knot_typ:5,kutta:19,kwarg:[10,11],kx1:3,label:[5,22],lag:8,lambda:[8,18],larger:15,last:[3,8,22],lbl:5,lcm:[8,15],ldot:[18,19],lead:8,left:[3,8,10,18,22],leftrightarrow:17,leg:8,len:15,length:[3,10,15,21],length_measur:5,leq:18,lexic:5,lhape:15,lhd:10,like:[8,15],limit:18,limits_:[8,18],limits_a:18,line:[0,3,4,5,8,9,10,22],line_geometri:4,linear:[8,9],lis:5,list:[3,4,5,8,9,10,15,17,18,19,22],list_to_arrai:5,lmax:15,lmin:15,lns:11,load:3,local:[9,19],locat:[5,15],logic:5,lookahead:4,loop:[5,8],low:5,lower:[3,15,18],lowest:15,lst:3,lvd:10,lvert:19,magnitud:[5,15],magntud:15,mai:5,main:0,major:8,make:[0,8,13],manag:14,manifold:5,manipul:3,march:6,mass:19,master_represent:5,match:4,mathbf:[8,9,15,20],mathemat:[1,2,8,9],mathmat:20,mathrm:[8,17,18,19],matplotlib:[11,12,13],matrix:[9,15],max:8,max_iter:19,maximum:[17,19],mean:[8,19],meassur:14,method:[5,19,20],militari:13,min:8,minor:8,minumum:3,minut:21,minutes_norm:21,model:[3,4,20],modul:[0,1,2,16],modulu:15,mondai:6,mondparamet:6,mondschaltung:6,move:[8,15],multi:3,multilin:22,multipl:[5,8,15],multiview:13,must:[3,8],mxn:[3,15],mystdout:22,name:5,ncurs:22,ndarrai:17,necessari:18,necessarili:18,neg:4,new_path:14,newline_replac:3,newmark:19,newmark_newtonraphson:[19,20],newmark_newtonraphson_mdk:[19,20],newmark_newtonraphson_rdk:[],newwin:22,nmmdk:20,node:10,non:[5,8],none:[3,5,7,8,9,10,14,15,17,18,22],nonperiod:8,nonsens:15,norm:[8,15],normal:[8,9,15,21,22],note:15,now:14,nsimsun:0,number:[4,5,8,10,15,18,19],numer:[1,2],numerisch:18,numpi:17,obj:3,object:[3,4,5,9,10,14,15,22],object_data:3,obliqu:13,occur:[3,8],ode:[2,16,20],ode_model:[2,16],offset:[17,21],often:8,omega:8,one:[3,4,8,10,13,19,22],ones:15,onli:[3,4],open:[3,4,8,9],oppos:5,opposit:5,option:[8,10,22],order:[8,10,19,20],ordinari:[8,19,20],org:6,orient:5,oriented_edg:5,origin:[10,15],orthogon:[9,15],orthograph:[9,13],oscil:8,osterentfernung:6,osterformel:6,ostergrenz:6,ostersonntag:6,other:[10,15],otherwis:[8,10],otim:15,out:14,outer:15,output:22,outsid:[8,14],over:[4,8],overwright:22,own:9,packag:[0,1],padding_left:22,padding_top:22,page:[0,22],pagen:[],parabolic_arc:5,parallel:13,paramet:[3,5,6,8,10,13,14,15,17,18,19,20,21,22],parameter_valu:5,parent:22,parent_window:22,parenthesi:4,part:[4,5,8,15],particular:8,pass:[],path:5,path_head_to_tail:5,pathtoanaconda3:0,pathtoanaconda3condabinconda:[],pattern:[3,8],pcurve_or_surfac:5,peak:8,pentecost:6,per:[3,8,19],perform:15,period:8,perspect:13,phase:[8,15],phi:[8,20],piecewise_bezier_knot:5,pip:0,pixel:8,placement:5,plan:13,plane:[9,10],plot:[8,10,13],plot_cubic_lin:11,plot_lin:[10,11],plot_post:13,plotter:[11,12,13],pmatrix:15,pnt:5,point1:[9,10],point1_i:10,point1_x:10,point2:[9,10],point2_i:10,point2_x:10,point3:[9,10],point4:[9,10],point5:9,point6:9,point7:9,point8:9,point:[5,8,9,10,13,18,19,22],point_i:10,point_x:10,pointer_to_new_created_point_object:4,pointer_to_new_created_vertex_object:4,points1_i:10,polygon:[9,10],polygonzugverfahren:19,polylin:[8,9],polyline_form:5,popt:17,posit:[5,8,17,22],position_norm:21,positive_length_measur:5,possibl:13,preferred_surface_curve_represent:5,print:[3,10,14,15,18,19,22],print_edge_loop:4,print_list:3,problem:[19,20],processor:[3,4],product:[5,9,15],program:[0,3],project:[9,13],propag:8,properti:9,proport:19,proportion:8,proposit:5,protocol:5,pts:10,pylab:[11,12,13],pythin:14,python:0,qquad:19,quad:[18,19,20],quadratur:18,quasi:[0,8],quasi_uniform_knot:5,r2x3_final:5,rac:[],radian:[8,10],radiu:[5,8,9],random:15,rang:[8,15,21],rate:8,rdx:20,rdxp:20,read:[3,4],read_column:3,reader:4,real:[5,15],rectangl:10,recurs:8,reduct:20,ref_direct:5,refer:[5,8,22],refresh:22,rel_tol:15,relat:8,remov:[3,4],repeat:8,repesent:9,replac:3,repr:[9,15],repres:8,represent:5,representation_item:5,res:5,residuum:19,resourc:5,result:[3,4,8,15],rhd:10,right:[3,8,9,10,15,18,22],rkx:20,rmx:20,rmxpp:20,roation:10,roll:8,rotat:[10,15,20],rotate_deg:10,rotate_i:[9,15],rotate_x:[9,15],rotate_xi:10,rotate_z:[9,15],rotation_plan:10,row:[8,15,22],rto:0,rule:[9,15,18],run:14,run_fil:14,rung:19,runtim:22,rvd:10,rvert:19,s_x:15,s_y:15,s_z:15,said:8,same:[3,5],same_sens:5,samesens:5,sampl:10,sample_half_open:[8,9],sample_half_open_seq:8,sample_point1_x:10,sample_point2_i:10,sample_point2_x:10,sample_points1_i:10,satisfi:8,save_valu:18,scalar:15,scale:[8,9,13,15],scale_horizont:8,scale_i:10,scale_vert:8,scale_x:10,sche:19,schema:5,screen:22,script:0,seam_curv:5,search:[0,3],second:[3,8,10,19,20,21],seconds_norm:21,section:4,section_test:14,see:15,segment:18,select:5,self:[5,9,15],self_intersect:5,semi:8,semi_axis_1:5,semi_axis_2:5,send:22,sens:5,seper:4,seq:3,sequenc:3,set:[3,5,8,15,19,22],set_aspect:13,set_aspect_equ:13,sever:4,shall:5,shape:[3,4,5],shift:8,shift_horizont:8,shift_vert:8,should:[10,15],show:22,side:18,sigma:17,simpson:18,simpsonregel:18,sin:[8,15,20],sine:8,sine_wav:8,sinusoid:8,six:[],size:[3,10,15,19],slope:10,smaller:15,smooth:8,solid:[9,10],solut:[13,18,19],solv:19,solver:19,some:[8,14],sonnenschaltung:6,sonntag:6,sourc:[3,4,5,6,7,8,9,10,11,13,14,15,17,18,19,20,21,22],space:[8,9,18,22],space_diagon:9,spacial:6,span:8,spatial:[5,8],special:[5,18],specif:8,specifi:[8,18],speed:8,sperat:22,sphere:13,spline:[8,9],split:4,sqrt:[15,17],squar:[10,19],stabl:19,stackoverflow:[13,22],standard:[5,17,19,22],start:[3,5,8,9,10,14,22],state:22,std:5,stderr:22,stdout:22,stdoutwrapp:22,stdsc:22,stdscr:22,step:[3,4,5,19],steptool:5,stiff:19,stop:3,store:3,stp_aim:5,str:[3,5,8,9,14,15,22],str_between:3,str_to_cmd_arg:4,str_to_list:3,straight:10,string:[3,4,5,8,10,14,22],stripe:3,struct_tim:21,structur:[3,5,8],stuff:22,style:22,sub:22,subinterv:18,submodul:1,subpackag:1,subtyp:5,sum:[8,15,18],sundai:6,support:8,suppress:22,sure:0,surfac:5,surface_curv:5,symbol:7,sys:22,system:[5,9,10,15,19,20],t_0:19,t_axis2_placement_2d:5,t_axis2_placement_3d:5,t_b_spline_curv:5,t_b_spline_curve_with_knot:5,t_boolean_choos:5,t_bounded_curv:5,t_cartesian_point:5,t_circl:5,t_conic:5,t_curv:5,t_dimension_of:5,t_direct:5,t_edg:5,t_edge_curv:5,t_edge_loop:5,t_ellips:5,t_geometric_representation_item:5,t_i:19,t_line:5,t_list_to_arrai:5,t_loop:5,t_n:19,t_oriented_edg:5,t_path:5,t_path_head_to_tail:5,t_placement:5,t_point:5,t_representation_item:5,t_seam_curv:5,t_surface_curv:5,t_topological_representation_item:5,t_vector:5,t_vertex:5,t_vertex_point:5,t_x:15,t_y:15,t_z:15,tabl:10,tagen:6,tangent:8,term:3,termin:0,test:[15,22],text:[3,5,8,19,22],textbox:22,tfrac:19,than:[3,10,15,22],therefor:[15,19],theta:[8,9,15],thi:[3,4,5,8,9,10,13,15,20,22],thick:19,thicker:8,third:13,thoma:18,three:20,ti1:19,time:[8,9,14,15,19,20,21],time_norm:21,time_of_dai:[1,2],timeit:14,titl:22,tmp:14,to_str:8,todo:8,togeth:8,tol:19,toler:19,took:14,top:[10,13,22],topolog:5,topological_representation_item:5,torqu:20,total:5,touch:8,transform:[8,9,15,21],translat:[9,10,15],translate_xi:10,transpos:15,trapez:18,trapezium:18,trapezoid:18,trapezregel:18,trim:5,trimetri:13,tui:[1,2],tupl:[3,5,8,10,17],two:[3,10,18],txt:22,type:[3,4,5,6,8,10,15,17,18,20,21,22],typr:8,u_0:8,u_1:8,u_2:8,u_i:[8,15],u_m:8,u_n:8,u_p:8,u_x:15,u_z:15,uid:3,unbound:5,underli:0,unhash:3,unicod:[0,8],uniform:[8,15],uniform_knot:5,uniqu:3,unique_end:3,unique_list:3,unique_list_hash:3,unit:8,unknown:[3,4],unspecifi:5,upper:[3,18],upper_index_on_control_point:5,upper_index_on_knot:5,upsid:8,usag:[8,15,22],use:[0,15,20],used:[0,5,14,17],useful:22,user:[0,22],uses:8,using:[3,8,11,12,13,18],usw:6,v_x:15,v_y:15,v_z:15,valu:[4,5,8,15,17,18,19,20,21],varepsilon:19,variabl:[5,6,8,18],varianc:17,varphi:[8,20],vec:10,vector:[5,8,9,10,15],veloc:19,verbos:[3,4,17,18,19],verfahren:19,vert_0:18,vert_a:18,vertcal:10,vertex:5,vertex_geometri:5,vertex_point:[4,5],vertic:[5,8,10,17],view:8,vmatrix:20,vollmond:6,von:6,w_x:15,w_y:15,w_z:15,wave:8,wavelength:8,wavenumb:8,what:10,when:[8,15],where:[8,14,15,17],whether:5,which:[4,5,8,19],widget:22,width:[8,10,17,22],wiki:6,wikipedia:6,window:[0,8,22],wirefram:9,wireframe3d:13,wireframes_xi:9,wireframes_xyz:9,wise:10,work:[13,14],world:[9,13],wrap:[3,4],write:[3,22],wrong:15,www:5,x90:9,x_0:[8,18,19],x_1:[8,10,18,19,20],x_2:[10,18,19,20],x_3:20,x_4:20,x_5:20,x_6:20,x_column:3,x_fit:17,x_i:[18,19],x_n:18,xm90:9,xp0:19,xp1:20,xp2:20,xp3:20,xp4:20,xp5:20,xp6:20,xpn:20,xpp0:19,xppn:20,xyz:9,y90:9,y_0:19,y_1:10,y_2:10,y_column:3,y_fit:17,year:[6,21],ym90:9,you:[0,22],your:22,zephyrproject:0,zero:[5,8,15]},titles:["Welcome to pylib\u2019s documentation!","pylib","pylib package","pylib.data module","pylib.data_step module","pylib.data_step_std module","pylib.date module","pylib.drawblock module","pylib.function module","pylib.geometry module","pylib.geometry2d module","pylib.geometry2d_plot module","pylib.geometry_plot module","pylib.geometry_plot_pylab module","pylib.helper module","pylib.mathematics module","pylib.numerical package","pylib.numerical.fit module","pylib.numerical.integration module","pylib.numerical.ode module","pylib.numerical.ode_model module","pylib.time_of_day module","pylib.tui module"],titleterms:{"function":8,data:3,data_step:4,data_step_std:5,date:6,document:0,drawblock:7,fit:17,geometri:9,geometry2d:10,geometry2d_plot:11,geometry_plot:12,geometry_plot_pylab:13,helper:14,indic:0,integr:18,mathemat:15,modul:[3,4,5,6,7,8,9,10,11,12,13,14,15,17,18,19,20,21,22],numer:[16,17,18,19,20],ode:19,ode_model:20,packag:[2,16],pylib:[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22],submodul:[2,16],subpackag:2,tabl:0,time_of_dai:21,tui:[0,22],welcom:0}}) \ No newline at end of file diff --git a/docs/source/index.rst b/docs/source/index.rst index e0ae45b..08341a4 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -15,8 +15,39 @@ Welcome to pylib's documentation! Indices and tables -================== +------------------ * :ref:`genindex` * :ref:`modindex` * :ref:`search` + + + +tui +--- + +pylib/tui.py is the main module for tui 'terminal user interface' programs. + +* curses package (for Windows install windows-curses) is the underlying main + package to build terminal programs. The curses package can also be used + directly. + + * Windows (Anaconda): + + * ``C:\PathToAnaconda3\condabin\conda.bat activate base`` + * ``python -m pip install windows-curses`` + * https://github.com/zephyrproject-rtos/windows-curses + +* drawille package is used to draw with braille characters (dottet and quasi- + line charts). Make sure you use a font with Unicode Braille characters. For + Windows e. g.: NSimSun, MS Gothic. + + * Install: ``python -m pip install drawille`` + * Windows (Anaconda): + + * ``C:\PathToAnaconda3\condabin\conda.bat activate base`` + * ``python -m pip install drawille`` + +* drawblock.py is used to draw with block characters (histogram). + +example/tui.py is an example script to build a terminal program. diff --git a/docs/source/pylib.rst b/docs/source/pylib.rst index 524f6f0..4275b18 100644 --- a/docs/source/pylib.rst +++ b/docs/source/pylib.rst @@ -32,3 +32,4 @@ Submodules pylib.helper pylib.mathematics pylib.time_of_day + pylib.tui diff --git a/docs/source/pylib.tui.rst b/docs/source/pylib.tui.rst new file mode 100644 index 0000000..b61f490 --- /dev/null +++ b/docs/source/pylib.tui.rst @@ -0,0 +1,7 @@ +pylib.tui module +================ + +.. automodule:: pylib.tui + :members: + :undoc-members: + :show-inheritance: diff --git a/examples/function_b_spline.py b/examples/function_b_spline.py index 212ab21..65ce8a2 100755 --- a/examples/function_b_spline.py +++ b/examples/function_b_spline.py @@ -10,16 +10,15 @@ .. moduleauthor:: Daniel Weschke """ +from mpl_toolkits.mplot3d import Axes3D +assert Axes3D +import pylab from pylib.data import seq, unique_list from pylib.function import ( sample_half_open, sample_half_open_seq, b_spline_basis, b_spline_knots, b_spline_curve_with_knots) from pylib.helper import timeit -from mpl_toolkits.mplot3d import Axes3D -assert Axes3D -import pylab - def b_spline_basis_functions(knots, pmax=None): m = len(knots) - 1 # m = 3 @@ -27,7 +26,7 @@ def b_spline_basis_functions(knots, pmax=None): pmax = m u = seq(knots[0], knots[-1], (knots[-1]-knots[0])/50) Nij = [[[b_spline_basis(knots, i, j)(uj) for uj in u] for - i in range(m-j)] for j in range(pmax+1)] + i in range(m-j)] for j in range(pmax+1)] Nj = [[sum(i) for i in zip(*Nij[:][j])] for j in range(pmax+1)] return u, Nij, Nj @@ -180,14 +179,14 @@ def example5(): (52.5444045251438, 42.8799268641912, -0.372905635604393), (52.7547311828766, 42.9295775362814, -0.373148784408123)] Uu = (0.0228378692889125, - 0.0649893839528174, - 0.130414237399236, - 0.195679174703882, - 0.260898113556269, - 0.326065686455556, - 0.391167888702703, - 0.456323551413636, - 0.521155975846261) + 0.0649893839528174, + 0.130414237399236, + 0.195679174703882, + 0.260898113556269, + 0.326065686455556, + 0.391167888702703, + 0.456323551413636, + 0.521155975846261) mult = (4, 2, 2, 2, 2, 2, 2, 2, 4) U = [Uu[i] for i in range(len(Uu)) for j in range(mult[i])] @@ -205,9 +204,9 @@ def example5(): C = b_spline_curve_with_knots(p, P, U) Cu = sample_half_open(C, U[0], U[-1]) plot_b_spline_curve_with_knots( - Cu = Cu, - CU = sample_half_open_seq(C, Uu) if knots_cp else None, - P = P if knots_cp else None, + Cu=Cu, + CU=sample_half_open_seq(C, Uu) if knots_cp else None, + P=P if knots_cp else None, figure_id='N5 C') pylab.gca().set_zlim3d([-1, 0]) @@ -239,14 +238,14 @@ def example6(): (52.5444045251438, 42.8799268641912, -0.372905635604393), (52.7547311828766, 42.9295775362814, -0.373148784408123)] Uu = (0.0228378692889125, - 0.0649893839528174, - 0.130414237399236, - 0.195679174703882, - 0.260898113556269, - 0.326065686455556, - 0.391167888702703, - 0.456323551413636, - 0.521155975846261) + 0.0649893839528174, + 0.130414237399236, + 0.195679174703882, + 0.260898113556269, + 0.326065686455556, + 0.391167888702703, + 0.456323551413636, + 0.521155975846261) mult = (4, 2, 2, 2, 2, 2, 2, 2, 4) U = [Uu[i] for i in range(len(Uu)) for j in range(mult[i])] @@ -275,86 +274,86 @@ def example6(): def example7(): P = [(-69.99999999999, 6.23746531921, 119.99999999999), - (-69.99999999999, 5.72567326271, 120.0), - (-70.0, 5.2192123782, 120.0), - (-70.0, 4.718082665681, 120.0), - (-70.0, 4.222284125153, 120.0), - (-70.0, 3.731816756617, 120.0), - (-70.0, 3.246680560071, 120.0), - (-70.0, 2.766875535516, 120.0), - (-70.0, 2.292401682953, 120.0), - (-70.0, 1.82325900238, 120.0), - (-70.0, 1.359447493799, 120.0), - (-70.0, 0.900967157208, 120.0), - (-70.0, 0.447817992609, 120.0), - (-69.99999999999, -1.642767914458, 119.99999999999), - (-69.95823302652, -3.284128624962, 119.96005936915), - (-69.87482030195, -4.920567121601, 119.88028704462), - (-69.7502001661, -6.548567099244, 119.76113869291), - (-69.58513326705, -8.164660004507, 119.60341679526), - (-69.38069590753, -9.765475979336, 119.40825949383), - (-69.13826152984, -11.34779669959, 119.17711816806), - (-68.85947036564, -12.90861011093, 118.91172378914), - (-68.54618721656, -14.44516705927, 118.61404198996), - (-68.20044740283, -15.95503981856, 118.28621691953), - (-67.82439084537, -17.43618251348, 117.93050381741), - (-67.42018430873, -18.88699343893, 117.54919035943), - (-66.38758251206, -22.29350540161, 116.57795367665), - (-65.73413448053, -24.21919416036, 115.96554908806), - (-65.03556391343, -26.07956263873, 115.31370192302), - (-64.29648522575, -27.87744521951, 114.62724902124), - (-63.52042791056, -29.61397650413, 113.91024118834), - (-62.71277001846, -31.2871331673, 113.16847249966), - (-61.87901674025, -32.89613508726, 112.4077395496), - (-61.02226890253, -34.44424317029, 111.63151855295), - (-60.14386048877, -35.93622309031, 110.841629897), - (-59.24623340527, -37.37387103089, 110.04091803203), - (-58.33313678246, -38.756819007, 109.23340236149), - (-57.40516397009, -40.08965381341, 108.42014822445), - (-55.01642244455, -43.34968716212, 106.34685334397), - (-53.53813210335, -45.21002358427, 105.08230356996), - (-52.03458081272, -46.96355473328, 103.81650090025), - (-50.50977333246, -48.61777575741, 102.55504546095), - (-48.96692322622, -50.17949288551, 101.30260097008), - (-47.40801072014, -51.65517742458, 100.06277532323), - (-45.83395649691, -53.05076391735, 98.838417665337), - (-44.24537288755, -54.37123987567, 97.632189028576), - (-42.64319994423, -55.62048722024, 96.446976549361), - (-41.02853017217, -56.80167054344, 95.285780596074), - (-39.40157208613, -57.91802439479, 94.15110945761), - (-37.76099941739, -58.97317114245, 93.044667943398), - (-33.51657488475, -61.52870256173, 90.285109332808), - (-30.89322834847, -62.94313830978, 88.677041723595), - (-28.23238814008, -64.22251443102, 87.15321189152), - (-25.55002271787, -65.36600940426, 85.732620462342), - (-22.80465037824, -66.39367032451, 84.407541386373), - (-20.07652968241, -67.27260606721, 83.231827543651), - (-17.27816204332, -68.0519427367, 82.167075623263), - (-14.44812618974, -68.69718956814, 81.25538726298), - (-11.58521735637, -69.2186257426, 80.51004437835), - (-8.697808521544, -69.60868640648, 79.943540692506), - (-5.807821595725, -69.86923851767, 79.563401742733), - (-2.906442029202, -70.00000000001, 79.372539331945), - (0.372271370757, -69.99999999999, 79.372539331937), - (0.762465017147, -69.99999999999, 79.372539331936), - (1.17058093917, -69.99999999999, 79.372539331935), - (1.596619136825, -69.99999999999, 79.372539331934), - (2.040579610114, -69.99999999999, 79.372539331932), - (2.502462359036, -69.99999999999, 79.372539331931), - (2.982267383591, -69.99999999998, 79.37253933193), - (3.479994683778, -69.99999999998, 79.372539331929), - (3.995644259599, -69.99999999998, 79.372539331927), - (4.529216111052, -69.99999999998, 79.372539331926), - (5.080710238139, -69.99999999998, 79.372539331925), - (5.650126640858, -69.99999999997, 79.372539331923), - (6.23746531921, -69.99999999997, 79.372539331922)] + (-69.99999999999, 5.72567326271, 120.0), + (-70.0, 5.2192123782, 120.0), + (-70.0, 4.718082665681, 120.0), + (-70.0, 4.222284125153, 120.0), + (-70.0, 3.731816756617, 120.0), + (-70.0, 3.246680560071, 120.0), + (-70.0, 2.766875535516, 120.0), + (-70.0, 2.292401682953, 120.0), + (-70.0, 1.82325900238, 120.0), + (-70.0, 1.359447493799, 120.0), + (-70.0, 0.900967157208, 120.0), + (-70.0, 0.447817992609, 120.0), + (-69.99999999999, -1.642767914458, 119.99999999999), + (-69.95823302652, -3.284128624962, 119.96005936915), + (-69.87482030195, -4.920567121601, 119.88028704462), + (-69.7502001661, -6.548567099244, 119.76113869291), + (-69.58513326705, -8.164660004507, 119.60341679526), + (-69.38069590753, -9.765475979336, 119.40825949383), + (-69.13826152984, -11.34779669959, 119.17711816806), + (-68.85947036564, -12.90861011093, 118.91172378914), + (-68.54618721656, -14.44516705927, 118.61404198996), + (-68.20044740283, -15.95503981856, 118.28621691953), + (-67.82439084537, -17.43618251348, 117.93050381741), + (-67.42018430873, -18.88699343893, 117.54919035943), + (-66.38758251206, -22.29350540161, 116.57795367665), + (-65.73413448053, -24.21919416036, 115.96554908806), + (-65.03556391343, -26.07956263873, 115.31370192302), + (-64.29648522575, -27.87744521951, 114.62724902124), + (-63.52042791056, -29.61397650413, 113.91024118834), + (-62.71277001846, -31.2871331673, 113.16847249966), + (-61.87901674025, -32.89613508726, 112.4077395496), + (-61.02226890253, -34.44424317029, 111.63151855295), + (-60.14386048877, -35.93622309031, 110.841629897), + (-59.24623340527, -37.37387103089, 110.04091803203), + (-58.33313678246, -38.756819007, 109.23340236149), + (-57.40516397009, -40.08965381341, 108.42014822445), + (-55.01642244455, -43.34968716212, 106.34685334397), + (-53.53813210335, -45.21002358427, 105.08230356996), + (-52.03458081272, -46.96355473328, 103.81650090025), + (-50.50977333246, -48.61777575741, 102.55504546095), + (-48.96692322622, -50.17949288551, 101.30260097008), + (-47.40801072014, -51.65517742458, 100.06277532323), + (-45.83395649691, -53.05076391735, 98.838417665337), + (-44.24537288755, -54.37123987567, 97.632189028576), + (-42.64319994423, -55.62048722024, 96.446976549361), + (-41.02853017217, -56.80167054344, 95.285780596074), + (-39.40157208613, -57.91802439479, 94.15110945761), + (-37.76099941739, -58.97317114245, 93.044667943398), + (-33.51657488475, -61.52870256173, 90.285109332808), + (-30.89322834847, -62.94313830978, 88.677041723595), + (-28.23238814008, -64.22251443102, 87.15321189152), + (-25.55002271787, -65.36600940426, 85.732620462342), + (-22.80465037824, -66.39367032451, 84.407541386373), + (-20.07652968241, -67.27260606721, 83.231827543651), + (-17.27816204332, -68.0519427367, 82.167075623263), + (-14.44812618974, -68.69718956814, 81.25538726298), + (-11.58521735637, -69.2186257426, 80.51004437835), + (-8.697808521544, -69.60868640648, 79.943540692506), + (-5.807821595725, -69.86923851767, 79.563401742733), + (-2.906442029202, -70.00000000001, 79.372539331945), + (0.372271370757, -69.99999999999, 79.372539331937), + (0.762465017147, -69.99999999999, 79.372539331936), + (1.17058093917, -69.99999999999, 79.372539331935), + (1.596619136825, -69.99999999999, 79.372539331934), + (2.040579610114, -69.99999999999, 79.372539331932), + (2.502462359036, -69.99999999999, 79.372539331931), + (2.982267383591, -69.99999999998, 79.37253933193), + (3.479994683778, -69.99999999998, 79.372539331929), + (3.995644259599, -69.99999999998, 79.372539331927), + (4.529216111052, -69.99999999998, 79.372539331926), + (5.080710238139, -69.99999999998, 79.372539331925), + (5.650126640858, -69.99999999997, 79.372539331923), + (6.23746531921, -69.99999999997, 79.372539331922)] Uu = (-3.932977778518, - 1.445001333941e-14, - 14.427668850884, - 34.626262491172, - 65.717581403178, - 114.40570375563, - 120.64191760942) + 1.445001333941e-14, + 14.427668850884, + 34.626262491172, + 65.717581403178, + 114.40570375563, + 120.64191760942) mult = (14, 12, 12, 12, 12, 12, 14) U = [Uu[i] for i in range(len(Uu)) for j in range(mult[i])] @@ -376,3 +375,4 @@ def example7(): if __name__ == "__main__": example7() + pylab.show() diff --git a/examples/tui.py b/examples/tui.py new file mode 100755 index 0000000..973cecb --- /dev/null +++ b/examples/tui.py @@ -0,0 +1,193 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +"""Example tui. + +:Date: 2020-01-12 + +.. module:: tui + :platform: *nix, Windows + :synopsis: Example tui. + +.. moduleauthor:: Daniel Weschke +""" + +import curses +import locale +from pylib.data import seq +from pylib.function import sine_wave, cosine_wave, hypotrochoid, to_str +from pylib.tui import TUI + +locale.setlocale(locale.LC_ALL, '') +CODE = locale.getpreferredencoding() + +def standard_text(window): + window.text( + "1 - Show test page\n" + + "2 - Show Hypotrochoid example\n" + + "h - Show help page\n" + + "q - Exit", 1, 2) + +def help_text(window, tui, str_width_height): + screen_height, screen_width = window.getmaxyx() + last_screen_row = screen_height - 1 + + tui.color_table() # print colors + + window.text("screen width and height", 1, last_screen_row-3) + window.text("\u2502", 3, last_screen_row-2) # \u2502 + window.text("\u2502", 3, last_screen_row-1) # \u2193 v + + window.text("last pressed key as Unicode code point", len(str_width_height)+2, last_screen_row-2) + window.text("\u2502", 1+len(str_width_height)+1, last_screen_row-1) + + num_reloads = "number of screen reloads\u256e" + # screen_width-1-len(num_reloads.encode('utf-16'))//2 + window.text(num_reloads, screen_width-1-len(num_reloads), last_screen_row-1) + +def test_text(window): + window.text("Test page", 1, 2) + +def full_text(window, t): + #window.clear() + screen_height, screen_width = window.getmaxyx() + + # Sine + f = sine_wave(A=0.5, k=0.1, D=0.5) + frame = to_str(f, x_0=0, x_1=1, h=screen_height-2, w=screen_width, t=t) + + # Turtle + import drawille + turtle = drawille.Turtle() + for _ in range(36): + turtle.right(10 + t) + for _ in range(0, 36): + turtle.right(10) + turtle.forward(8) + frame = turtle.frame() + # size for forward 1: width 11+1, height 6 + # size for forward 2: width 23+1, height 12 + # size for forward 5: width 57+1, height 30 + # size for forward 6: width 69+1, height 36 + # size for forward 10: width 114+1, height 58 + # n 12*n 6*n + + # Hypotrochoid + demo = 2 + c = drawille.Canvas() + R = 20 + r = 6 + d = 30 + if demo == 1: + r = int(t/50)%19+1 + x, y, theta = hypotrochoid(R, r, d) + for i in seq(0, theta[1]*0.98, theta[1]/10000): + c.set(x(i+t), y(i+t)) + a = R+d+1 # R-r+d+1 + frame = c.frame(min_x=-a, max_x=a, min_y=-a, max_y=a) + if demo == 2: + d = int(t)%21 + x, y, theta = hypotrochoid(R, r, d) + for i in seq(0, theta[1]*0.98, theta[1]/5000): + c.set(x(i+t), y(i+t)) + a = 2*R # R-r+d+1 + frame = c.frame(min_x=-a, max_x=a, min_y=-a, max_y=a) + + window.text(frame, padding_top=1, color_pair=10) + window.text("R=%2s r=%2s d=%2s" % (R, r, d), 1, int(a/2)+2) + +def win_charts_line(window, f_list, x_0, x_1, w, t, color_pairs, densities): + win_chart_line, _ = window.textbox(height=8, width=52, y=9, x=5, borders=True) + # width 100 pixel / 2 pixels/column = 50 columns + for f, color_pair, density in zip(f_list, color_pairs, densities): + frame = to_str(f, x_0=x_0, x_1=x_1, h=6, w=w, t=t, density=density) + win_chart_line.text(frame, color_pair=color_pair) + +def win_chart_histogram(window, f, x_0, x_1, w, t): + newwin2, _ = window.textbox(height=4, width=52, y=9+8, x=5, borders=True) + + #frame2 = function_frame(f, x_0=x_0, x_1=x_1, h=2, w=w, t=t, char_set="histogram") + frame2 = to_str(f, x_0=x_0, x_1=x_1, h=2, w=w, t=t, char_set="histogram") + newwin2.text(frame2, color_pair=3) + frame3 = to_str(f, x_0=x_0, x_1=x_1, h=2, w=w, t=t, density=0.5, char_set="histogram") + newwin2.text(frame3, color_pair=4) + +def main(delay=1): + """ + no window change for mouse events and resize events. + """ + tui = TUI(delay) + initscr = tui.initscr + try: + tui.last_pressed_ch = 0 # getch() Note that the integer returned does not have to be in ASCII range: function keys, keypad keys and so on return numbers higher than 256. + tui.last_pressed_mouse_ch = 0 + i = 1 + while True: + tui.clear() + + screen_height, screen_width = initscr.getmaxyx() + str_width_height = str(screen_width) + 'x' + str(screen_height) # width and height of the screen + footer_left = [str_width_height, str(tui.last_pressed_ch)] # and last pressed key as char integer ( Unicode code point) + i += 1 # number of screen reloads + initscr.border("Python curses in action!", footer_left, str(i)) + + if tui.last_pressed_ch == ord('1'): + test_text(initscr) + + elif tui.last_pressed_ch == ord('2'): + full_text(initscr, i) + + elif tui.last_pressed_ch == ord('h'): + help_text(initscr, tui, str_width_height) + + elif tui.last_pressed_ch == ord('q'): + break + + else: + standard_text(initscr) + + x_0 = 0 + x_1 = 1 # TODO + w = 50 + t = i/100 + + # define function normed to the range of [0, 1] + y_1 = sine_wave(A=.5, k=.1, D=.5) + y_1_2 = sine_wave(A=.5, k=.1, f=1+1/3, phi=30, D=.5, degree=True) + y_1_3 = sine_wave(A=.5, k=.1, f=1+2/3, phi=60, D=.5, degree=True) + y_2 = cosine_wave(A=.5, k=.1, f=2, D=.5) + win_charts_line(initscr, [y_1, y_1_2, y_1_3, y_2], x_0, x_1, w, t, [209, 215, 221, 227], [5, 5, 5, 5]) + #win_charts_line(initscr, [y_1, y_1_2, y_1_3, y_2], x_0, x_1, w, t, [10, 7, 7, 7], [5, 1, 1, 1]) + #y_2 = cosine_wave(A=0.5, k=0.2, f=2, D=0.5) + #win_charts_line(initscr, [y_1, y_2], x_0, x_1, w, t, [10, 7], [5, 1]) + win_chart_histogram(initscr, y_1, x_0, x_1, w, t) + + # mouse event has occurred + if tui.last_pressed_mouse_ch == curses.KEY_MOUSE: + try: + _, mx, my, _, _ = curses.getmouse() + initscr.text("Mouse pos " + str(mx) + " " + str(my), 1, 6) + initscr.text(initscr.instr(my, mx, 5), mx, my, color_pair=5) + except curses.error: + pass + + # std content + # cursor position (last addstr is cursor position) + if tui.cursor_visibility > 0: + initscr.text("", 1, 6) + + tui.refresh() # update the screen + tui.getch() + + except Exception as e: + import traceback + print('\n'.join(traceback.format_exception(*sys.exc_info()))) + + finally: + tui.end() + +if __name__ == '__main__': + import sys + if len(sys.argv) > 1: + main(sys.argv[1]) + else: + main() diff --git a/pylib/__init__.py b/pylib/__init__.py index 84f9702..e946c39 100644 --- a/pylib/__init__.py +++ b/pylib/__init__.py @@ -6,7 +6,8 @@ project_dir = os.path.abspath(os.path.dirname(__file__)) parent_dir = os.path.dirname(project_dir) vendor_dir = os.path.join(parent_dir, 'vendor') -sys.path.append(vendor_dir) +if vendor_dir not in sys.path: + sys.path.append(vendor_dir) # Now you can import any library located in the "vendor" folder! # import drawille diff --git a/pylib/geometry_plot_pylab.py b/pylib/geometry_plot_pylab.py index e4bb2b6..6258bcb 100644 --- a/pylib/geometry_plot_pylab.py +++ b/pylib/geometry_plot_pylab.py @@ -145,7 +145,37 @@ def cad_wireframe(world, centering=True): plot_post(ax) - def press(event, world, lps): + # 'rotate: ←left, right, up, down, ctrl+left, ctrl+right\n' + + # 'pan: shift+left, shift+right, shift+up, shift+down\n' + + # 'zoom: ctrl+up, ctrl+down\n' + + # 'view: f (front), l (left), r (right), t (top), b (bottom)\n' + + # ' i (isometric), d (dimetric)', + h_open = pylab.text( + 0+.01, 1-.015, + 'rotate: [←], [→], [↑], [↓], [Ctrl][←], [Ctrl][→]\n' + + 'pan: [Shift][←], [Shift][→], [Shift][↑], [Shift][↓]\n' + + 'zoom: [Ctrl][↑], [Ctrl][↓]\n' + + 'view: [f]ront, [l]eft, [r]ight, [t]op, [b]ottom\n' + + ' [i]sometric, [d]imetric', + color='#2280c0', + horizontalalignment='left', + verticalalignment='top', + transform=fig.transFigure, + bbox=dict(facecolor='black', edgecolor='#196090', alpha=0.5), + family='monospace' + ) + h_close = pylab.text( + 0+.01, 1-.015, '[h]elp', + color='#2280c0', + horizontalalignment='left', + verticalalignment='top', + transform=fig.transFigure, + bbox=dict(facecolor='black', edgecolor='#196090', alpha=0.5), + family='monospace', + visible=False + ) + + def press(event, world, lps, h_open, h_close): #print('key pressed:', event.key) #sys.stdout.flush() if event.key in [ @@ -215,6 +245,10 @@ def cad_wireframe(world, centering=True): world.scale(0.9) for i, j in zip(lps, world.wireframes_xy()): i.set_data(j) + if event.key == 'h': + visible = h_open.get_visible() + h_open.set_visible(not visible) + h_close.set_visible(visible) fig.canvas.draw() def onresize(event, w): @@ -223,26 +257,8 @@ def cad_wireframe(world, centering=True): pylab.ylim((-r, r)) fig.canvas.mpl_connect('key_press_event', - lambda event: press(event, world, lps)) + lambda event: press(event, world, lps, + h_open, h_close)) fig.canvas.mpl_connect('resize_event', lambda event: onresize(event, world)) - - # 'rotate: ←left, right, up, down, ctrl+left, ctrl+right\n' + - # 'pan: shift+left, shift+right, shift+up, shift+down\n' + - # 'zoom: ctrl+up, ctrl+down\n' + - # 'view: f (front), l (left), r (right), t (top), b (bottom)\n' + - # ' i (isometric), d (dimetric)', - pylab.text( - 0+.01, 1-.015, - 'rotate: [←], [→], [↑], [↓], [Ctrl][←], [Ctrl][→]\n' + - 'pan: [Shift][←], [Shift][→], [Shift][↑], [Shift][↓]\n' + - 'zoom: [Ctrl][↑], [Ctrl][↓]\n' + - 'view: [f]ront, [l]eft, [r]ight, [t]op, [b]ottom\n' + - ' [i]sometric, [d]imetric', - horizontalalignment='left', - verticalalignment='top', - transform=fig.transFigure, - bbox=dict(facecolor='black', alpha=0.5), - family='monospace' - ) pylab.show() diff --git a/pylib/helper.py b/pylib/helper.py index 4c4fce1..b346219 100755 --- a/pylib/helper.py +++ b/pylib/helper.py @@ -10,6 +10,7 @@ .. moduleauthor:: Daniel Weschke """ +import os import time from contextlib import ContextDecorator @@ -46,3 +47,43 @@ class timeit(ContextDecorator): elapsed_time_ms = (time.time() - self.start_time) * 1000 print('{:s} took {:.3f} ms'.format(self.description, elapsed_time_ms)) return False + +class cd: + """Context manager for changing the current working directory + + :param new_path: the directory to change into + :type new_path: string + + :Example: + + :: + + # enter the directory and run some code: + with cd("~/tmp"): + # we are now in ~/tmp + # code + # outside the context manager we are back where we started. + """ + def __init__(self, new_path): + self.new_path = os.path.expanduser(new_path) + + def __enter__(self): + self.saved_path = os.getcwd() + os.chdir(self.new_path) + + def __exit__(self, etype, value, traceback): + os.chdir(self.saved_path) + +def run_file(file_name): + """Run a file. + + Inside a pythin interpreter it changes to the directory of the + file and after excuting the file it changes back to the working + directory before. + + :param file_name: the file to execute + :type file_name: string + """ + workdir = os.path.dirname(os.path.abspath(file_name)) + with cd(workdir): + exec(open(file_name).read()) diff --git a/pylib/mathematics.py b/pylib/mathematics.py index a820b7c..3a6f360 100644 --- a/pylib/mathematics.py +++ b/pylib/mathematics.py @@ -633,7 +633,7 @@ class matrix(list): """ def __getitem__(self, index): - """ + r""" For index return value, for range return new vector object. :Example: @@ -790,7 +790,7 @@ class matrix(list): :Example: >>> m = matrix.zeros(3, 3) - >>> print(m)\ + >>> print(m) [[0.0, 0.0, 0.0], [0.0, 0.0, 0.0], [0.0, 0.0, 0.0]] """ return matrix([[0. for i in range(n)] for j in range(m)]) diff --git a/pylib/tui.py b/pylib/tui.py new file mode 100644 index 0000000..43cb122 --- /dev/null +++ b/pylib/tui.py @@ -0,0 +1,360 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +"""TUI module. + +:Date: 2020-01-10 + +.. module:: tui + :platform: *nix, Windows + :synopsis: TUI module. + +.. moduleauthor:: Daniel Weschke +""" +# TODO: two classes to distinguish between curses (main tui) and +# window (to handle sub windows)? +# TODO: width resizing, min width now 6 because of text and border +# TODO: height resizing, min height +import sys +import curses + + +def newwin(height, width, y, x): + win = Window() + win.window = curses.newwin(height, width, y, x) + return win + + +class StdOutWrapper: + """Send print to stdout (print to the standard console). + + usage: + + :: + + # catch all prints into StdOutWrapper + mystdout = StdOutWrapper() + sys.stdout = mystdout + sys.stderr = mystdout + + # begin curses (curses.initscr()) + + # do your stuff here + # print("foo") + # you can also output mystdout.get_text() in a ncurses widget in + # runtime + + # end curses (curses.endwin()) + + # go back to normal state and print all catched prints to stdout + sys.stdout = sys.__stdout__ + sys.stderr = sys.__stderr__ + sys.stdout.write(mystdout.get_text()) + + source: + https://stackoverflow.com/a/14010948 + """ + text = "" + def write(self, txt): + self.text += txt + self.text = '\n'.join(self.text.split('\n')[-30:]) + def get_text(self): + return '\n'.join(self.text.split('\n')) + #def get_text(self,beg,end): + # return '\n'.join(self.text.split('\n')[beg:end]) + + +class TUI: + """TUI text-based user interface + + initscr is the encapsulation window object of the stdscr + stdsc is the curses.initscr + """ + + def __init__(self, delay=5): + """ + :param delay: sets the curses.halfdelay, value between 1 and 255. + :param type: int + """ + if not isinstance(delay, int): + try: + delay = int(delay) + except ValueError: + print("TUI(delay)") + print("Could not convert the argument to an integer.") + + # catch all prints into StdOutWrapper + self.stdout = StdOutWrapper() + sys.stdout = self.stdout + sys.stderr = self.stdout + + # Define the appearance of some interface elements + hotkey_attr = curses.A_BOLD | curses.A_UNDERLINE + menu_attr = curses.A_NORMAL + + self.initscr = Window() + self.initscr.initscr() + self.stdscr = self.initscr.window + #print(type(self.stdscr)) + #print(type(self.initscr)) + + try: + curses.cbreak() + curses.halfdelay(delay) # How many tenths of a second are waited, from 1 to 255 + #stdscr.nodelay(1) + curses.noecho() + self.cursor_visibility = 0 # Set the cursor state. visibility can be set to 0, 1, or 2, for invisible, normal, or very visible. + curses.curs_set(self.cursor_visibility) + self.stdscr.keypad(1) + curses.mousemask(1) # activate mouse events + + # init colors + if curses.has_colors(): + curses.start_color() # initializes 8 basic colors. 0:black, 1:red, 2:green, 3:yellow, 4:blue, 5:magenta, 6:cyan, and 7:white. + curses.use_default_colors() + for i in range(0, curses.COLORS): + curses.init_pair(i + 1, i, -1) # Color pair 0 is hard-wired to white on black, and cannot be changed. + except: pass + + self.last_pressed_ch = 0 # getch() Note that the integer returned does not have to be in ASCII range: function keys, keypad keys and so on return numbers higher than 256. + self.last_pressed_mouse_ch = 0 + + def refresh(self): + self.initscr.refresh() # update the screen + + def getch(self): + # keep last key value + last_pressed_ch_current = self.initscr.getch() + if last_pressed_ch_current != curses.ERR: + # keep last key while window resizing + if last_pressed_ch_current == curses.KEY_MOUSE: + self.last_pressed_mouse_ch = last_pressed_ch_current + if last_pressed_ch_current in [curses.KEY_MOUSE, curses.KEY_RESIZE]: + pass + else: + self.last_pressed_ch = last_pressed_ch_current + + def color_table(self, window=None): + """Print all available colors with default background. + Check if curses.has_colors() is True. + """ + # TODO: position + # FIXME: use own text method? + # FIXME: build full str first and then print? + if not curses.has_colors(): + return + if window is None: + window = self.stdscr + + window.addstr(2, 1, '{0} colors available'.format(curses.COLORS)) + if curses.can_change_color(): + window.addstr(' (can change color: {0})'.format(curses.can_change_color())) + _, maxx = window.getmaxyx() + step_size = 4 + maxx = maxx - maxx % step_size + x = 0 + y = 3 + try: + for i in range(0, curses.COLORS): + window.addstr(y, x, '{0:{1}}'.format(i, step_size), curses.color_pair(i)) + x = (x + step_size) % maxx + if x == 0: + y += 1 + except: + # End of screen reached + pass + + def color_def(self): + if curses.can_change_color(): # if True curses.init_color(color_number, r, g, b) can be used + pass + # changes colors for the terminal also after closing the program. + #curses.color_content(0) + #tmp = curses.color_content(1) + #print(curses.color_content(1)) + #curses.init_color(0, 1000, 0, 0) # color_number = init_pair number - 1 (maybe because init_pair number 0 is hard-wired and not changeable) + #curses.init_color(1, 1000, 500, 1000) + #print(curses.color_content(1)) + #curses.init_color(1, *tmp) + #print(curses.color_content(1)) + + def clear(self): + self.stdscr.clear() + + def end(self): + """clean up""" + self.stdscr.clear() + curses.nocbreak() + self.stdscr.keypad(0) + curses.echo() + curses.endwin() + + # go back to normal state and print all catched prints to stdout + sys.stdout = sys.__stdout__ + sys.stderr = sys.__stderr__ + sys.stdout.write(self.stdout.get_text()) + + +class Window: + """Window + """ + def __init__(self): + self.window = None + + def initscr(self): + self.window = curses.initscr() + + def derwin(self, height, width, y, x): + win = Window() + win.window = self.window.derwin(height, width, y, x) + return win + + def clear(self): + return self.window.clear() + + def getmaxyx(self): + return self.window.getmaxyx() + + def getch(self): + return self.window.getch() + + def instr(self, y, x, n): + return self.window.instr(y, x, n).decode() + + def text(self, string, padding_left=0, padding_top=0, attribute=0, color_pair=0): + r"""Test to screen. If multiline than keep the x position for + each new line. + + :Example: + + :: + + text(stdscr, 2, 1, "1 - Show test page") + text(stdscr, 3, 1, "h - Show help page") + text(stdscr, 4, 1, "q - Exit") + + text(stdscr, 2, 1, + "1 - Show test page\\n" + + "h - Show help page\\n" + + "q - Exit") + + .. note:: + Writing in the last char of the window (last row bottom and + last column right) is suppressed + """ + win_height, win_width = self.window.getmaxyx() + if win_width-padding_left < 2: # unicode can have 2 char width + return + yi = padding_top + #for row in string.split("\n"): + # window.addnstr(yi, x, row, win_width-x-1, curses.color_pair(9)) # 5 + # yi += 1 + for row in string.split("\n"): # TODO: os.linesep? + xi = padding_left + for char in row: + # write only inside the window + if not yi >= win_height and not xi >= win_width: + # do not write in the last char of window (last row bottom and last column right) + # unicodes may use multiple chars, this will raise an error for the last char in the window + if yi == win_height-1 and xi >= win_width-1: + break + #if yi == win_height-1 and xi >= win_width-1: + # try: + # char.encode("ascii") + # except UnicodeEncodeError: + # break + + # dont add str if empty braille char or simple space character + if char != chr(0x2800) and char != " " and xi < win_width and yi < win_height: + self.window.addstr(yi, xi, char, attribute|curses.color_pair(color_pair)) + xi += 1 + yi += 1 + + def border(self, title="", footer_left="", footer_right="", style="horizontal"): + """Set border around the window with optional title and footer + labels. + + :param window: the window to draw a border + :type window: curses.window + :param title: the title for the window (default = "") + :type title: str + :param footer_left: the footer label (default = ""). If footer_left + is a list than every element of the list will be printed sperated + by one column. This is useful to not overwright the border with a + space character. + :type footer_left: str or list + """ + win_height, win_width = self.window.getmaxyx() + if win_width < 3: + return + + if isinstance(style, str): + if style == "horizontal": + self.window.border( + ' ', + ' ', + curses.ACS_HLINE, + curses.ACS_HLINE, + curses.ACS_HLINE, + curses.ACS_HLINE, + curses.ACS_HLINE, + curses.ACS_HLINE, + ) + elif style == "full": + self.window.border(0, 0, 0, 0, 0, 0, 0, 0, ) + else: # list + self.window.border(*style) + + if title: + self.text(title, 1) + + if footer_left: + last_win_row = win_height - 1 + if isinstance(footer_left, str): + self.text(footer_left, 1, last_win_row) + else: # list + pos = 1 + for footer_left_i in footer_left: + self.text(footer_left_i, pos, win_height-1) + pos += len(footer_left_i)+1 + + if footer_right: + self.text(footer_right, win_width - 1 - len(footer_right), last_win_row) + + def textbox(self, height, width, y, x, borders=False): + """Add sub window. + + :param parent_window: the parent window + :type parent_window: curses.window + :param height: the height of the sub window. The reference point of + the sub window is the top left corner. + :type height: int + :param width: the width of the sub window. The reference point of + the sub window is the top left corner. + :type width: int + :param y: the y coordinate (position) of the sub window. Start from + the top. + :type y: int + :param x: the x coordinate (position) of the sub window. Start from + the left. + :returns: the sub window content and decoration + :rtype: (curses.window, curses.window) + """ + # TODO: not to work with two window object but one with the + # possibility to access the derwin(s). Either self.derwins + # or another DoubleWindow class for border and text or do it + # in this class? + screen_height, screen_width = self.window.getmaxyx() + newwin_width = screen_width-x if x+width > screen_width else width + newwin_height = screen_height-y if y+height > screen_height else height + if newwin_width > 0 and newwin_height > 0: + win = self.derwin(newwin_height, newwin_width, y, x) + if borders: + win.border(style="full") + if newwin_width-2 > 0 and newwin_height-1 > 0: + subwin = win.derwin(newwin_height-1, newwin_width-2, 1, 1) + return subwin, win # text and border + return newwin(1, 1, 0, 0), win # only border, no text (top left 1 char) + return win, newwin(1, 1, 0, 0) # only text, no border (top left 1 char) + return newwin(1, 1, 0, 0), newwin(1, 1, 0, 0) # no border and no text (top left 1 char) + + def refresh(self): + self.window.refresh()