Package: asciiTUI
Python asciiTUIDescriptionThis is a library of tools for you to use with your needs for an attractive type of terminal (console) display.
Typeprint(dir(asciiTUI))for further functions, then typeprint(asciiTUI.<func>.__doc__)for further document information of each function.InstallationTo install the Python libraries and command line utilities, run:pipinstallasciiTUIIf you want to upgrade this library do the command:pipinstallasciiTUI--upgradeorpipinstallasciiTUI==<version>When the installation is complete, import theasciiTUImodule>>>importasciiTUIastuiLibary usage - Variablelorem_ipsumThis is alorem_ipsumvariable which contains the lorem ipsum text in English form. With the following usage:>>>print(tui.lorem_ipsum)Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.Libary usage - Functions and Classremove_ansiTheremove_ansi()function is used to remove or clean existing ansi escape codes \033, \x1b, and others and return the cleaned text. As usage:>>>text='\033[32mHello World!\033[36m'>>>len(text)# check length22>>>len(tui.remove_ansi(text=text))# check length and removing ansi escape12Args:text(required) (type: str[auto]) : The main text that will remove the ansi codeterminal_sizeTheterminal_size()function is used to get the terminal sizex:width ory:height. As usage:>>>tui.terminal_size(get='x')120>>># The numbers above will not match the output results you get. It all depends on the size of your terminal when executed.>>>tui.terminal_size(get='xy')(120, 30)You can directly get x and y in one function withget='xy'orget='yx'as usage:>>>x,y=tui.terminal_size(get='xy')>>>print(x)120>>>print(y)30Args:get(required) (type: str[auto]) : The type of terminal size you will get.x: width,y: heightRaises:OptionNotFoundError: If thegetoption is not found for example searching for anything other thanxandythe results will throw this exceptionrgbThergb()function is used to display colored text with the number of colors depending on the coder, g, bentered and can displaystyleformat in the form offg(foreground) orbg(background). As usage:>>>print(tui.rgb(r=23,g=102,b=7,style='fg')+'Hello World!'+tui.rgb())Hello World!>>># The resulting output is in the form of RGB colors in general. Style as foreground (fg) or background (bg) type. The resulting color depends on the type of console used.Args:r(default: 255) (type: int[None]) : Red value (0-255)g(default: 255) (type: int[None]) : Green value (0-255)b(default: 255) (type: int[None]) : Blue value (0-255)style(default: 'fg') (type: str[auto]) : Color style, eitherfgfor foreground orbgfor backgroundRaises:TypeError: If typer, g, bis notintValueError: Ifr, g, bis one of the values less than 0 and more than 255OptionNotFoundError: Ifstyleoption is not foundjustifyThejustify()function is used to load string text to be in the middle or on the left and can adjust the width size to suit the terminal size or not according to needs. As usage:>>>print(tui.justify(...content=tui.lorem_ipsum,...width=50,...make='center',...fill=' ',...height=50,...align=False,...wrap=True...))Lorem Ipsum is simply dummy text of the printingand typesetting industry. Lorem Ipsum has been theindustry's standard dummy text ever since the1500s, when an unknown printer took a galley oftype and scrambled it to make a type specimenbook. It has survived not only five centuries, butalso the leap into electronic typesetting,remaining essentially unchanged. It waspopularised in the 1960s with the release ofLetraset sheets containing Lorem Ipsum passages,and more recently with desktop publishing softwarelike Aldus PageMaker including versions of LoremIpsum.There are types ofmakethat can be printed, namely:make='center'LoremIpsumissimplydummytextoftheprintingandtypesettingindustry.LoremIpsumhasbeentheindustry's standard dummy text ever since the1500s, when an unknown printer took a galley oftype and scrambled it to make a type specimenbook. It has survived not only five centuries, butalso the leap into electronic typesetting,remaining essentially unchanged. It waspopularised in the 1960s with the release ofLetraset sheets containing Lorem Ipsum passages,and more recently with desktop publishing softwarelike Aldus PageMaker including versions of LoremIpsum.make='right'Lorem Ipsum is simply dummy text of the printingand typesetting industry. Lorem Ipsum has been theindustry'sstandarddummytexteversincethe1500s,whenanunknownprintertookagalleyoftypeandscrambledittomakeatypespecimen
book.Ithassurvivednotonlyfivecenturies,butalsotheleapintoelectronictypesetting,remainingessentiallyunchanged.Itwaspopularisedinthe1960swiththereleaseofLetrasetsheetscontainingLoremIpsumpassages,
andmorerecentlywithdesktoppublishingsoftwarelikeAldusPageMakerincludingversionsofLoremIpsum.make='left'LoremIpsumissimplydummytextoftheprintingandtypesettingindustry.LoremIpsumhasbeenthe
industry'sstandarddummytexteversincethe
1500s,whenanunknownprintertookagalleyoftypeandscrambledittomakeatypespecimen
book.Ithassurvivednotonlyfivecenturies,but
alsotheleapintoelectronictypesetting,
remainingessentiallyunchanged.Itwas
popularisedinthe1960swiththereleaseof
LetrasetsheetscontainingLoremIpsumpassages,
andmorerecentlywithdesktoppublishingsoftware
likeAldusPageMakerincludingversionsofLorem
Ipsum.Args:content(required) (type: str[auto]) : Content string to be justifiedwidth(required) (type: int[None]) : Set the width sizemake(default: 'center') (type: str[auto]) : Make the string printed with the centercenteror to the rightrightor to the leftleftfill(default: ' ') (type: str[auto]) : Fill characterheight(default: 50) (type: int[None]) : Set the height sizealign(default: False) (type: bool[auto]) : Makes text center align (depending on size in height)wrap(default: True) (type: bool[auto]) : Word wrappingRaises:TypeError: Ifwidth, heightare notintOptionNotFoundError: Iftypefmtoption is not foundtableThetable()function is used to create an art ASCII table with headers and data in list form. As usage:>>>print(tui.table(...headers=['NUM','Name'],...data=[...[1,'Alice'],...[2,'Steve'],...],...typefmt='table',...tjust=['center','left'],...borders=['\u2500','\u2502','\u250c','\u2510','\u2514','\u2518','\u252c','\u2534','\u251c','\u2524','\u253c']# need 11 borders...))┌─────┬───────┐│ NUM │ Name  │├─────┼───────┤│ 1   │ Alice │├─────┼───────┤│ 2   │ Steve │└─────┴───────┘If you experience problems with the console displaying borders, you can change the borders as follows:borders=['-', '|', '+', '+', '+', '+', '+', '+', '+', '+', '+']Output:+-----+-------+|NUM|Name|+-----+-------+|1|Alice|+-----+-------+|2|Steve|+-----+-------+There are 3 types of table displays, namelytable,table_fancy-grid,tabulate, here are some displays of each type:typefmt='table'┌─────┬───────┐
│NUM│Name│
├─────┼───────┤
│1│Alice│
├─────┼───────┤
│2│Steve│
└─────┴───────┘typefmt='table_fancy-grid'┌─────┬───────┐
│NUM│Name│
├─────┼───────┤
│1│Alice│
│2│Steve│
└─────┴───────┘typefmt='tabulate'NUM│Name───────────1│Alice2│SteveArgs:headers(required) (type: list[None]) : The header list is in the form of a list type. Example:['NUM', 'Name'] [<col 1>, <col 2>]data(requared) (type: (list[None] values> list[None]) ) : The data list is in the form of a list type. Example:[[1, 'Alice'], [2, 'Steve']] [<row 1>, <row 2>]typefmt(default: 'table') (type: str[auto]) : Table model type (tableortable_fancy-gridortabulate)tjust(default: ['center', 'left']) (type: list[None]) : Justify the layout of headers and data (centerorrightorleft). (usingjustify()function). Index:[<make:headers>, <make:data>]borders(default: ['\u2500', '\u2502', '\u250c', '\u2510', '\u2514', '\u2518', '\u252c', '\u2534', '\u251c', '\u2524', '\u253c']) (type: list[None]) : Changing bordersRaises:TypeError: If theheader, data, tjust, borderstype is not a listValueError: If the contents of theborders, tjustlist are less or more than borders:11, tjust:2OptionNotFoundError: Iftypefmtoption is not foundInit_cmd_splitTheInit_cmd_split()class is an init character used to split command line arguments separated by delimiters defined in this class, such as escape characters, quotes, line breaks, and other special characters. As usage:>>>cs=tui.Init_cmd_split(...esc_char='\\',...quotes_char='"',...ln_char=';',...backslash_char='\\',...param_char=' '...)>>>command=r'pip install asciiTUI; echo "Hello World!\""; py'# main commandArgs:esc_char(default: '\\') (type: str[auto]) : Escape characterquotes_char(default: '"') (type: str[auto]) : Quote characterln_char(default: ';') (type: str[auto]) : Line character. To separate and create rowsbackslash_char(default: '\\') (type: str[auto]) : Backslash characterparam_char(default: ' ') (type: str[auto]) : Parameter character. To separate parametersFunctions (method):split_argsThis method will separate arguments and lines in list form as usage:>>>cs.split_args(cmd=command)[['pip', 'install', 'asciiTUI'], ['echo', 'Hello World!"'], ['py']]Args:cmd(required) (type: str[auto]) : Main command stringsplit_lnThis method will separate only rows in list form as usage:>>>cs.split_ln(cmd=command)['pip install asciiTUI', 'echo "Hello World!\""', 'py']Args:cmd(required) (type: str[auto]) : Main command stringRaises:Init_cmd_split:ValueError: If all arguments or parameters are less or more than 1 in lengthInit_progress_barTheInit_progress_bar()class is used to load a loading or progress display on the console. As usage:>>>fromtimeimportsleep>>>pb=tui.Init_progress_bar(...typefmt='simple-box',...width=50,...maxp=100,...showpercent=True,...bar_borders=["#",".","[","]"]...)Here are some types of progress bars:typefmt='simple-box'[#########################################] 100.0%typefmt='simple-line',bar_borders=['=','-','[',']']===========================================100.0%Args:typefmt(default: 'simple-box') (type: str[auto]) : Type of progress model (simple-boxorsimple-line)width(default: 50) (type: int[None]) : Width length of the progress barmaxp(default: 100) (type: int[None]) : Maximum progress percentageshowpercent(default : True) (type: bool[auto]): Displays progress percentbar_borders(default : ["#", ".", "[", "]"]) (type: list[None]) : Changing bordersFunctions (method):strbarThis method is a method for producing a progress bar output with specified progress. As usage:>>>print(pb.strbar(progress=12.4))# 12.4%[#####....................................] 12.4%Args:progress(required) (type: int[None]) : Current percent progressRaises:Init_progress_bar:TypeError: Ifwidth, maxpare notintInit_progress_bar:ValueError: If the contents of thebar_borderslist are less or more than 4strbar:TypeError: If theprogresstype is notintorfloatstrbar:OptionNotFoundError: Iftypefmtoption is not foundpwinputThepwinput()function is used to take input from the user, but the typed display is only a mask so that the input entered cannot be read. As usage:>>>pw=tui.pwinput(prompt='Password: ',mask='*');print(pw)Password: ***********Hello WorldArgs:prompt(default: '') (type: str[auto]) : Appearance of prompt or text.mask(default: '*') (type: str[auto]) : As the character mask displayed.Raises:ValueError: If themasklength is more than 1 characterErrorsOptionNotFoundErrorIf an option or type entered is not foundPythonVersionErrorIf you are using Python version 2CHANGE LOG1.2.9Fix justify functionFix Init_cmd_splitDocumentation updates