Package: pyboxen
pyboxenCreate beautiful boxes in the terminal using PythonThis package is a Python "port" of the popular NPM packageboxen.It's built on top ofRich, and features an API that would be familiar to the users of the NPM boxen package.🛠️ InstallUsingpippip install pyboxen🔗 UsageSimplest of simple boxesfrompyboxenimportboxenprint(boxen("Python is cool!"))Define optionsfrompyboxenimportboxenprint(boxen("Python is cool!",padding=1,margin=1,color="cyan",))Multiple texts andRich RenderablesYou can even use Rich's special color style syntax for the text, title and subtitle as wellExample:[red]Hello[/red] [bold italic]World[/]frompyboxenimportboxen# Multiple textsprint(boxen("Python is cool!","Yeah it totally is!","I [red]:heart:[/red]  [yellow bold]Python[/]!",# You can even use Rich syntax here too!padding=1,margin=1,color="cyan",))# Rich renderables, with a mix of strings and renderablesfromrich.tableimportTabletable=Table(show_header=True,header_style="bold magenta")table.add_column("Date",style="dim",width=12)table.add_column("Title")table.add_column("Production Budget",justify="right")table.add_column("Box Office",justify="right")table.add_row("Dec 20, 2019","Star Wars: The Rise of Skywalker","$275,000,000","$375,126,118")table.add_row("May 25, 2018","[red]Solo[/red]: A Star Wars Story","$275,000,000","$393,151,347",)table.add_row("Dec 15, 2017","Star Wars Ep. VIII: The Last Jedi","$262,000,000","[bold]$1,332,539,889[/bold]",)print(boxen("Python is cool!",table))Title and subtitlesfrompyboxenimportboxenprint(boxen("Titles and subtitles!",title="Hello, [black on cyan] World [/]",subtitle="Cool subtitle goes here",subtitle_alignment="center",color="yellow",padding=1,))🔮 APIboxen(*text, **kwargs)textA variable (infinite) amount of text strings orRich Renderables, or a mix of both.kwargsCustomize options for the boxAvailable options include:color:str="white",style:Literal["ascii","ascii2","ascii_double_head","square","square_double_head","minimal","horizontals","rounded","heavy","double"]="rounded"padding:Union[int,tuple[int]]=0,margin:Union[int,tuple[int]]=0,text_alignment:Literal["left","center","right"]="center",box_alignment:Literal["left","center","right"]="left",title:str=None,title_alignment:Literal["left","center","right"]="left",subtitle:str=None,subtitle_alignment:Literal["left","center","right"]="left",fullwidth:bool=False,colorThe color of the box in color or hex code starting with #, defaults to whitestyleThe style of the box, defaults to roundedpaddingThe padding between the text and the box in int or tuple of ints, defaults to 0marginThe margin around the box in int or tuple of ints, defaults to 0text_alignmentThe alignment of the text inside the box, defaults to centerbox_alignmentThe alignment of the box in the terminal, defaults to lefttitleThe title of the box, displayed on the top of the box, if providedtitle_alignmentThe alignment of the title, defaults to leftsubtitleThe subtitle of the box, displayed on the bottom of the box, if providedsubtitle_alignmentThe alignment of the subtitle, defaults to leftfullwidthIf True, the box will expand to fill the entire terminal width, defaults to FalseNotepaddingandmarginattributes can be either an int, a tuple of ints (with a total of either 2 elements or 4 elements)
Example:2- all of top, right, bottom, left(2, 4)- (top = bottom, right = left)(2, 4, 6, 8)- (top, right, bottom, left)❤️ SupportYou can support further development of this project bygiving it a 🌟and help me make even better stuff in the future bybuying me a ☕Also, if you liked this repo, consider checking out my other projects, that would be real cool!💫 Attributions and special thanksboxen- the NPM package I was inspired fromrich- for making such an incredibly powerful text customization tool