Package: beaupy
BeauPyA Python library of interactive CLI elements you have been looking forFor documentation but more and prettier seehereAcknowledgmentBeauPy stands on the shoulders of giants. It is based on another library with which it shares some of the source code,cutie, developed byKamik423. It has begun as a fork but has since diverged into it's own thing and as such, detached from the original repository.OverviewBeauPyimplements a number of common interactive elements:FunctionFunctionalityselectPrompt to pick a choice from a listselect_multiplePrompt to select one or multiple choices from a listconfirmPrompt with a question and yes/no optionspromptPrompt that takes free input with optional validation, type conversion and input hidingTUI elements shown in the above gif are the result of the following code:importtimefrombeaupyimportconfirm,prompt,select,select_multiplefrombeaupy.spinnersimport*fromrich.consoleimportConsoleconsole=Console()# Confirm a dialogifconfirm("Will you take the ring to Mordor?"):names=["Frodo Baggins","Samwise Gamgee","Legolas","Aragorn","[red]Sauron[/red]",]console.print("Who are you?")# Choose one item from a listname=select(names,cursor="🢧",cursor_style="cyan")console.print(f"Alámenë,{name}")item_options=["The One Ring","Dagger","Po-tae-toes","Lightsaber (Wrong franchise! Nevermind, roll with it!)",]console.print("What do you bring with you?")# Choose multiple options from a listitems=select_multiple(item_options,tick_character='🎒',ticked_indices=[0],maximal_count=3)potato_count=0if"Po-tae-toes"initems:# Prompt with type conversion and validationpotato_count=prompt('How many potatoes?',target_type=int,validator=lambdacount:count>0)# Spinner to show while doing some workspinner=Spinner(DOTS,"Packing things...")spinner.start()time.sleep(2)spinner.stop()# Get input without showing it being typedif"friend"==prompt("Speak, [blue bold underline]friend[/blue bold underline], and enter",secure=True).lower():# Custom spinner animationspinner_animation=['▉▉','▌▐','  ','▌▐','▉▉']spinner=Spinner(spinner_animation,"Opening the Door of Durin...")spinner.start()time.sleep(2)spinner.stop()else:spinner_animation=['🐙🌊    ⚔️ ','🐙 🌊   ⚔️ ','🐙  🌊  ⚔️ ','🐙   🌊 ⚔️ ','🐙    🌊⚔️ ']spinner=Spinner(spinner_animation,"Getting attacked by an octopus...")spinner.start()time.sleep(2)spinner.stop()if'The One Ring'initems:console.print("[green]You throw The One Ring to a lava from an eagle![/green]")else:console.print("[red]You forgot the ring and brought Middle-Earth to its knees![/red]")console.print(f"And you brought{potato_count}taters!")For more information refer tomore examplesor definitive, but much less excitingAPI documentationInstallationFrom PyPI:pipinstallbeaupyFrom source:gitclonehttps://github.com/petereon/beaupy.git
poetrybuild
pipinstall./dist/beaupy-{{some-version}}-py3-none-any.whlRoadmapThis repository has aassociated GitHub projectwhere work that is currently done can be seen.ContributingIf you would like to contribute, please feel free to suggest features or implement them yourself.Alsoplease report any issues and bugs you might find!DevelopmentTo start development you can clone the repository:gitclonehttps://github.com/petereon/beaupy.gitChange the directory to the project directory:cd./beaupy/This project usespoetryas a dependency manager. You can install the dependencies using:poetryinstallFor testing, this project relies onward. It is included as a development dependency, so
after installing the dependencies you can simply execute the following:poetryrunpoetestMaking sure the code follows quality standards and formatting can be ensured by executingpoetryrunpoelintYou can also have the tests and lints run after every saved change by executing a respective watch commandpoetryrunpoetest:watchorpoetryrunpoelint:watchAfter you have made your changes, create a pull request towards a master branch of this repositoryLooking forward to your pull requests!CompatibilityInternal logic ofbeaupyis supported for all the major platforms (Windows, Linux, macOS).For user input from console,beaupyrelies onpetereon/yakh, which is tested against all the major platforms and Python versions.For printing to consolebeaupyrelies onTextualize/rich, whichclaims to supportall the major platforms.Known IssuesVersion2.x.x: arrow keys reportedly don't always work on Windows. Resolved in3.x.xVersion3.5.0: various option display bugs inselectandselect_multiple. Resolved in3.5.4Awesome projects usingbeaupytherealOri/Genter: A strong password generator and built in password manager made with python3!therealOri/byte: Steganography Image/Data Injector. For artists or people to inject their own Datamark "Watermark" into their images/art or files!LicenseThe project is licensed under theMIT License.