Package: conlay
Conlay - Console LayoutCreate visually pleasing console layouts with this easy-to-use Python library.InstallingInstall usingpippipinstallconlayor install it fromPyPiExamplefromconlayimport*layout=Conlay()blank_box=BoldBox(0,0,30,5)layout.add(blank_box)label=ThinLabel(0,0,"this is a test")blank_box.add(label)layout.print()Console output:┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃╭──────────────╮            ┃
┃│this is a test│            ┃
┃╰──────────────╯            ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛


>Conlay()Conlay()is the core class within the library. It generates and prints out the layout.layout=Conlay()There are some attributes that can be used to modify or update the positioning, scale, color and other things. Because eachLayoutElement()is a subclass ofConlay(), eachLayoutElement()has the same attributes.attributedescriptionexpected typedefault valuerelative_xRelative x-position to the parent objectint0relative_yRelative y-position to the parent objectint0absolute_xAbsolute x-positionint0absolute_yAbsolute y-positionint0widthElements widthint0min_widthMinimal width. May limit the specified withint0max_widthMaximal width. May limit the specified withint0heightElements heightint0min_heightMinimal height. May limit the specified withint0max_heightMaximal height. May limit the specified withint0zindexIndicates whether an element is printed above or below other elementsint0padding_xSpecifies the padding on the x axis, which affects the absolute position of the child elementsint0padding_ySpecifies the padding on the y axis, which affects the absolute position of the child elementsint0textSpecifies the text contentstrn/aplaceholderSpecifies the placeholder contentstrn/acontentStores the text content of the input element, etc.strn/abackgroundSpecifies whether the element should have a background or notboolFalsebackground_colorSpecifies the background colorColor.BgColor.Bg.clearborder_colorSpecifies the border colorColor.FgColor.Fg.cleartext_colorSpecifies the text colorColor.FgColor.Fg.clearplaceholder_colorSpecifies the placeholder colorColor.FgColor.Fg.rgb(150, 150, 150)Conlay.add()You can useadd()to addLayoutElementsto otherLayoutElements.Syntax:parent.add(child)argumentdescriptionexpected typechildchild elementLayoutElements()or one of its subclasses such asBox(),Label(), etc.Example:# add a LayoutElement to the main layoutlayout=Conlay()layout.add(ThinBox(...))# add a LayoutElement to another LayoutElementBoldBox(...).add(ThinLabel(...))Conlay.print()You have to callprint()to generate and print out the layout.Syntax:layout.print()Example:layout=Conlay()...layout.print()LayoutElement()TheLayoutElement()class serves as a superclass for all other layout elements such asBox(),Label(), etc.Syntax:element=LayoutElement(x,y,w,h,border)argumentdescriptionexpected typexRelative x-position to its parent elementintyRelative y-position to its parent elementintwElements widthinthElements heightintborderBorders character setBorder()or one of its subclasses such asBold()orThin()Example:fromconlayimport*layout=Conlay()element=LayoutElement(0,0,30,5,Thin())layout.add(element)layout.print()Console output:╭────────────────────────────╮
│                            │
│                            │
│                            │
╰────────────────────────────╯


>Box()TheBox()class is a subclass of theLayoutElement()class and is used to create a simple box.Syntax:element=Box(x,y,w,h,border)argumentdescriptionexpected typexRelative x-position to its parent elementintyRelative y-position to its parent elementintwElements widthinthElements heightintborderBorders character setBorder()or one of its subclasses such asBold()orThin()Example:fromconlayimport*layout=Conlay()box=Box(0,0,30,5,Thin())layout.add(box)layout.print()Console output:╭────────────────────────────╮
│                            │
│                            │
│                            │
╰────────────────────────────╯


>ThinBox()TheThinBox()class is a subclass of theBox()class and is used to create a simple box with aThin()Border.Syntax:element=ThinBox(x,y,w,h)argumentdescriptionexpected typexRelative x-position to its parent elementintyRelative y-position to its parent elementintwElements widthinthElements heightintExample:fromconlayimport*layout=Conlay()thinbox=ThinBox(0,0,30,5)layout.add(thinbox)layout.print()Console output:╭────────────────────────────╮
│                            │
│                            │
│                            │
╰────────────────────────────╯


>BoldBox()TheBoldBox()class is a subclass of theBox()class and is used to create a simple box with aBold()Border.Syntax:element=BoldBox(x,y,w,h)argumentdescriptionexpected typexRelative x-position to its parent elementintyRelative y-position to its parent elementintwElements widthinthElements heightintExample:fromconlayimport*layout=Conlay()boldbox=BoldBox(0,0,30,5)layout.add(boldbox)layout.print()Console output:┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃                            ┃
┃                            ┃
┃                            ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛


>Label()TheLabel()class is a subclass of theLayoutElement()class and is used to create a simple box.Syntax:element=Label(x,y,text,border)argumentdescriptionexpected typexRelative x-position to its parent elementintyRelative y-position to its parent elementinttextText contentstrborderBorders character setBorder()or one of its subclasses such asBold()orThin()fromconlayimport*layout=Conlay()label=Label(0,0,"this is a test",Thin())layout.add(label)layout.print()Console output:╭──────────────╮
│this is a test│
╰──────────────╯


>ThinLabel()TheThinLabel()class is a subclass of theLabel()class and is used to create a simple label with aThin()Border.Syntax:element=ThinLabel(x,y,text)argumentdescriptionexpected typexRelative x-position to its parent elementintyRelative y-position to its parent elementinttextText contentstrfromconlayimport*layout=Conlay()thinlabel=ThinLabel(0,0,"this is a test")layout.add(thinlabel)layout.print()Console output:╭──────────────╮
│this is a test│
╰──────────────╯


>BoldLabel()TheBoldLabel()class is a subclass of theLabel()class and is used to create a simple label with aBold()Border.Syntax:element=BoldLabel(x,y,text)argumentdescriptionexpected typexRelative x-position to its parent elementintyRelative y-position to its parent elementinttextText contentstrfromconlayimport*layout=Conlay()boldlabel=BoldLabel(0,0,"this is a test")layout.add(boldlabel)layout.print()Console output:┏━━━━━━━━━━━━━━┓
┃this is a test┃
┗━━━━━━━━━━━━━━┛


>Input()TheInput()class is a subclass of theLayoutElement()class and is used to create a input field.Syntax:element=Input(x,y,text,length,border)argumentdescriptionexpected typexRelative x-position to its parent elementintyRelative y-position to its parent elementinttextText contentstrlengthexpected input lengthintborderBorders character setBorder()or one of its subclasses such asBold()orThin()fromconlayimport*layout=Conlay()input_element=Input(0,0,"input:",10,Thin())layout.add(input_element)layout.print()Console output:╭────────────────╮
│input:          │
╰────────────────╯


>after you've entered a text, you can get it with the element.content variablefromconlayimport*layout=Conlay()input_element=Input(0,0,"input:",10,Thin())layout.add(input_element)layout.print()print(input_element.content)ThinInput()TheThinInput()class is a subclass of theInput()class and is used to create a simple input field with aThin()Border.Syntax:element=ThinInput(x,y,text,length)argumentdescriptionexpected typexRelative x-position to its parent elementintyRelative y-position to its parent elementinttextText contentstrlengthexpected input lengthintfromconlayimport*layout=Conlay()input_element=ThinInput(0,0,"input:",10)layout.add(input_element)layout.print()Console output:╭────────────────╮
│input:          │
╰────────────────╯


>BoldInput()TheBoldInput()class is a subclass of theInput()class and is used to create a simple input field with aBold()Border.Syntax:element=BoldInput(x,y,text,length)argumentdescriptionexpected typexRelative x-position to its parent elementintyRelative y-position to its parent elementinttextText contentstrlengthexpected input lengthintfromconlayimport*layout=Conlay()input_element=BoldInput(0,0,"input:",10)layout.add(input_element)layout.print()Console output:┏━━━━━━━━━━━━━━━━┓
┃input:          ┃
┗━━━━━━━━━━━━━━━━┛


>CursorTheCursorclass provides a few functions for simpleAnsi Escapecursor actions.Cursor.setPosition()Set the cursor to a specific position. TheAnsi Escape Sequenceused for this command is\x1b[<y>;<x>H.Syntax:Cursor.setPosition(x,y)Example:Cursor.setPosition(10,5)Cursor.shiftHorizontal()Move the cursor along the X axis. TheAnsi Escape Sequenceused for this command is\x1b[<x>Dand\x1b[<x>C.Syntax:Cursor.shiftHorizontal(x)Example:# move the cursor 10 collumns to the rightCursor.shiftHorizontal(10)# move the cursor 5 collumns to the leftCursor.shiftHorizontal(-5)Cursor.shiftVertical()Move the cursor along the Y axis. TheAnsi Escape Sequenceused for this command is\x1b[<y>Aand\x1b[<y>B.Syntax:Cursor.shiftVertical(y)Example:# move the cursor 10 collumns downCursor.shiftVertical(10)# move the cursor 5 collumns upCursor.shiftVertical(-5)Cursor.hide()Hides the cursor. TheAnsi Escape Sequenceused for this command is\x1b[?25l.Syntax:Cursor.hide()Cursor.show()Shows the cursor. TheAnsi Escape Sequenceused for this command is\x1b[?25h.Syntax:Cursor.show()ConsoleTheConsoleclass provides a few functions for simpleAnsi Escapeconsole actions.Console.reset()This Function resets the console. TheAnsi Escape Sequenceused for this command is\x1bc.Syntax:Console.reset()Console.clear()This Function clears the console. TheAnsi Escape Sequenceused for this command is\x1b[3J.Syntax:Console.clear()Console.eraseLineToEnd()Erase the line from the cursor position to the end. TheAnsi Escape Sequenceused for this command is\x1b[0K.Syntax:Console.eraseLineToEnd()Console.eraseLineFromStart()Erase the line from start to the cursor position. TheAnsi Escape Sequenceused for this command is\x1b[1K.Syntax:Console.eraseLineFromStart()Console.eraseLine()Erase the line. TheAnsi Escape Sequenceused for this command is\x1b[2K.Syntax:Console.eraseLine()ColorTheColorclass allows you to set the foreground and background color using theAnsi Escape Color Codes.Color.BgTheColor.Bgclass provides a few predefined backgroundAnsi Escape Color Codes.Variable Namergb valuesansi escape sequenceColor.Bg.black0,   0,   0\x1b[49mColor.Bg.black0,   0,   0\x1b[48;2;0;0;0mColor.Bg.white255, 255, 255\x1b[48;2;255;255;255mColor.Bg.red205,  49,  49\x1b[48;2;205;49;49mColor.Bg.green13, 188, 121\x1b[48;2;13;188;121mColor.Bg.blue36, 114, 200\x1b[48;2;36;114;200mColor.Bg.yellow229, 229,  16\x1b[48;2;229;229;16mColor.Bg.purple188,  63, 188\x1b[48;2;188;63;188mColor.Bg.cyan17, 168, 205\x1b[48;2;17;168;205mColor.Bg.rgb()This function takes three argumentsr, g, band returns a customized backgroundAnsi Escape Color CodeSyntax:Color.Bg.rgb(r,g,b)Example:>>>Color.Bg.rgb(255,0,100)'\x1b[48;2;255;0;100m'Color.FgTheColor.Fgclass provides a few predefined foregroundAnsi Escape Color Codes.Variable Namergb valuesansi escape sequenceColor.Bg.black0,   0,   0\x1b[39mColor.Fg.black0,   0,   0\x1b[38;2;0;0;0mColor.Fg.white255, 255, 255\x1b[38;2;255;255;255mColor.Fg.red205,  49,  49\x1b[38;2;205;49;49mColor.Fg.green13, 188, 121\x1b[38;2;13;188;121mColor.Fg.blue36, 114, 200\x1b[38;2;36;114;200mColor.Fg.yellow229, 229,  16\x1b[38;2;229;229;16mColor.Fg.purple188,  63, 188\x1b[38;2;188;63;188mColor.Fg.cyan17, 168, 205\x1b[38;2;17;168;205mColor.Fg.rgb()This function takes three argumentsr, g, band returns a customized foregroundAnsi Escape Color CodeSyntax:Color.Fg.rgb(r,g,b)Example:>>>Color.Fg.rgb(255,0,100)'\x1b[38;2;255;0;100m'BorderTheBorder()class and its subclasses serve as a character set and define the required Unicode characters.class attributesunicode charactersverticaln/ahorizontaln/atop_leftn/atop_rightn/abottom_leftn/abottom_rightn/aThin()TheThin()class is a subclass ofBorder()and serves as a character set and defines the required thin Unicode characters.class attributesunicode charactersvertical\u2503horizontal\u2501top_left\u250Ftop_right\u2513bottom_left\u2517bottom_right\u251BBold()TheBold()class is a subclass ofBorder()and serves as a character set and defines the required bold Unicode characters.class attributesunicode charactersvertical\u2502horizontal\u2500top_left\u256Dtop_right\u256Ebottom_left\u2570bottom_right\u256FSummaryConlay()add()print()ElementsLayoutElement()Box()ThinBox()BoldBox()Label()ThinLabel()BoldLabel()Input()ThinInput()BoldInput()Cursor & ConsoleCursorsetPosition()shiftHorizontal()shiftVertical()hide()show()Consolereset()clear()eraseLineToEnd()eraseLineFromStart()eraseLine()ColoringColorBgrgb()Fgrgb()Border & Border TypesBorderBoldThinLicenseLicensed under theMIT License.