Package: borders
BordersDescriptionis an updated version ofborders: it enhances the functionality of creating frames around text output adding new features, and improving existing ones. Borders creates a frame around a string or a list of strings where any item is considered a new line.FeaturesInput Functionality: Provides an option to use theframe()function in place ofinput()to create a framed prompt for user input.Spacing Control: Customisable alignment for the frame and the text within the frame.Width Customization:** Customisable width of frame and text lines.Latest Version 1.2.0Now supporting single string input.Colour Support: Expanded colour options now accept most color names,sRGBvalues[0-255];[0-255];[0-255],Hexvalues#[00-FF][00-FF][00-FF],xtermcolor number in the formatx[0-255], andANSI codes0, [40-47], [100-107].Frame styles: Six different frame styles now available.Table of ContentsGetting StartedPrerequisitesInstallationUsageParametersExamplesDefault settingsText and Frame ColoursTuplesAlignmentDisplaySpacingMinimum WidthMaximum WidthInputContributingLicenseGetting StartedPrerequisitesBorders relies on the Python standard library,textlinebreakerandpolychromylibraries, and if your system isWindowsin addition it might requirecoloramato fix color compatibility.InstallationInstall the packagepipinstallbordersor upgrade it to the latest versionpipinstall--upgradebordersImport the package in your programfrombordersimportframeUsageAdd the following line in your code to import the modulefrombordersimportframeSimply use the functionframe()instead ofprint()to print a frame around your output.Alternatively set the parameterwindow = "input"to useframe()in place ofinput().The text to be printed can be a mixed list of:stringstuples containing a string with the text to print and at least one of the following parameters:Optional value (integers or strings) for the colour of the textOptional value (integers or strings) for the background colour of the textOptional value (string) for the alignment of the lineParameterscolour: set the text colour.allowed values: most color names, RGB values [0-255];[0-255];[0-255], Hex values #[00-FF][00-FF][00-FF], xterm color number in the format x[0-255], and ANSI codes 0, [30-37], [90-97].default value =37.text_background: set the background colour of the text.allowed values: most color names, RGB values [0-255];[0-255];[0-255], Hex values #[00-FF][00-FF][00-FF], xterm color number in the format x[0-255], and ANSI codes 0, [40-47], [100-107].default value =0.frame_colour: set the frame colour.allowed values: most color names, RGB values [0-255];[0-255];[0-255], Hex values #[00-FF][00-FF][00-FF], xterm color number in the format x[0-255], and ANSI codes 0, [30-37], [90-97].default value =37.frame_background: set the background colour of the frame.allowed values: most color names, RGB values [0-255];[0-255];[0-255], Hex values #[00-FF][00-FF][00-FF], xterm color number in the format x[0-255], and ANSI codes 0, [40-47], [100-107].default value =0.frame_style: allows to change the style of the frameallowed values:'single','double','double horizontal','double vertical','dots',Nonedefault value ='double'alignment: set the alignment of the text inside the frame.allowed values:'left','centre','center','right'default value ='left'display: set the position of the frame inside the terminal.allowed values:'left','centre','center','right'default value ='left'spacing: set the space between the frame and the text.allowed values: from0 to 3default value =1min_width: set the min length of text in a line.allowed values: integers above8,'max'(this value assign to the frame the width of the terminal)default value =42max_width: set the max length of text in a line.allowed values: integers above8,'max'(this value assign to the frame the width of the terminal)default value =70window: Set the behaviour of the function, to output or input.allowed values:'print','input'default value ='print'ExamplesHere are some examples of how to use the frame() function with different parameters.Default settingsSimply usingframe()will print a frame around a given output.frombordersimportframe# Example 1: Default settingsoutput=["Hello,","World!"]frame(output)Output 1Text and Frame ColoursWe can set a colour for the text (e.g. 34 for Blue) and one for the frame (e.g. 31 for Red)frombordersimportframe# Example 2: Setting text and frame coloursoutput=["Hello,","World!"]frame(output,colour="34",frame_colour="31")Output 2TuplesUsing atuplewe can set different colours for each line, let's try setting blue, and red as general colours for the text and the frame.Then let's set one line with yellow text, one with green, and highlight one in white.frombordersimportframe# Example 3: Using tuple to set different colours for each lineoutput=["This text's color is Blue (System Color)",("This text's color is Aquamarine","Aquamarine"),("This text's color is Coral","255;127;80"),("This text's color is Cosmic Latte","#FFF8E7"),("This text is highlighted in Yellow","","x226"),("Frame's color is Red (System Color)",31),"This text's color is back to Blue (System Color)"]frame(output,colour=34,frame_colour=31)Output 3Frame Stylefrombordersimportframe# Example 4: Setting a different styles for the framestyles=["single","double","double horizontal","double vertical","dots",None]forsinstyles:# Print out the name of the style in a frame of that style.frame(f"{s}",frame_colour="Red",frame_background="Gainsboro",alignment="centre",frame_style=s)Output 4AlignmentThe parameteralignmentallows you to change the alignment of the text inside the frame.Withalignment="right"will allign the text to the right of the frame.frombordersimportframe# Example 5: Setting lines width equal to 60,# the general alignment of the text to the right,# and the alignment of the second line to the leftoutput=["There are only 10 kinds of people in this world:",("Those who know binary and Those who don't.","left"),"Anonymous"]frame(output,min_width=60,alignment="right")Output 5DisplayThe parameterdisplayallows you to change the position of the frame inside the terminal.frombordersimportframe# Example 6: Setting the position of the frame in the centre of the terminal# and the alignment of the text to the rightoutput=["There are only 10 kinds of people in this world:","Those who know binary and Those who don't.","Anonymous"]frame(output,alignment="right",display="centre")Output 6SpacingSpecifying different values for the parameterspacing, you can increase or decrease the space between text and frame.spacing=2Withspacing=2it will leave2blank lines at the top and the bottom, and8blank spaces before and after the text.frombordersimportframe# Example 7: Setting the spacing between the text and the frame equal to 2output=["Hello,","World!"]frame(output,spacing=2)Output 7Spacing = 0Withspacing=0it will create the frame around the text with no spaces.frombordersimportframe# Example 8: Setting the spacing between the text and the frame equal to 0output=["Hello,","World!"]frame(output,spacing=0)Output 8Minimum WidthThe parametermin_widthset the minimum width inside the frame.Withmin_width=30the output frame will have a wider space on the left.frombordersimportframe# Example 9:output=["Hello,","World!"]frame(output,min_width=30)Output 9Maximum WidthThe parametermax_widthset the max length of text on a line.Let's see what happens to the following string:"There are only 10 kinds of people in this world: Those who know binary and Those who don’t."max_width=100frombordersimportframe# Example 10:output=["There are only 10 kinds of people in this world: Those who know binary and Those who don't."]frame(output,max_width=100)Output 10max_width=50frombordersimportframe# Example 11:output=["There are only 10 kinds of people in this world: Those who know binary and Those who don't."]frame(output,max_width=50)Output 11max_width=25frombordersimportframe# Example 12:output=["There are only 10 kinds of people in this world: Those who know binary and Those who don't."]frame(output,max_width=25)Output 12InputYou can use the functionframe()in place ofinput()to create a frame around the prompt and get the input from the user.frombordersimportframe# Example 13: Using frame() in place of input()num1=int(frame(["Please,","enter a number"],window="input"))num2=num1*2output=[f"The double of{num1}",f"is{num2}"]frame(output)Output 13ContributingIf you'd like to contribute to this project, please follow these steps:Fork the repository on GitHub.Clone the fork to your local machine.Create a new branch for your feature or bug fix.Make your changes and commit them.Push the changes to your fork on GitHub.Create a pull request to the original repository.LicenseThis project is licensed under the MIT License - see theLICENSEfile for details.