Skip to main content
Join the official 2019 Python Developers SurveyStart the survey!

The project help you to quickly build layouts in terminal (命令行ui布局工具)

Project description

terminal_layout

The project help you to quickly build layouts in terminal
(这个一个命令行ui布局工具)

image0

asciicast

install

pip install terminal-layout

Usage

  • easy demo:
import time
from terminal_layout import *

ctl = LayoutCtl(TextView('id1', 'hello world!', width=20, fore=Fore.red, back=Back.green))

ctl.draw()

time.sleep(2)

view = ctl.find_view_by_id('id1')
view.text = 'hi world'
ctl.re_draw()

image2

  • use table layout:
from terminal_layout import *

ctl = LayoutCtl.quick(TableLayout,
                [
                    [TextView('title', 'Student', fore=Fore.black, back=Back.yellow, width=17,
                              gravity=Gravity.center)],

                    [TextView('', 'No.', width=5, back=Back.yellow),
                     TextView('', 'Name', width=12, back=Back.yellow)],

                    [TextView('st1_no', '1', width=5, back=Back.yellow),
                     TextView('st1_name', 'Bob', width=12, back=Back.yellow)],

                    [TextView('stw_no', '2', width=5, back=Back.yellow),
                     TextView('st1_name', 'Tom', width=12, back=Back.yellow)]
                ]

                )

ctl.draw()

image3

  • use python2 unicode
# -*- coding: utf-8 -*-
from terminal_layout import *
import sys
reload(sys)
sys.setdefaultencoding('utf-8')

ctl = LayoutCtl.quick(TableLayout,
                      [
                          [TextView('', u'中文,你好', back=Back.cyan, width=Width.wrap)],
                          [TextView('', u'中文,你好', back=Back.cyan, width=6)],
                          [TextView('', u'日本語,こんにちは', back=Back.cyan, width=Width.wrap)],
                      ]

                      )

ctl.draw()

image4

Properties

属性说明

  • fore & back
TextView('','fore',fore=Fore.red)
TextView('','back',back=Back.red)

image5

  • style
TextView('','style',style=Style.dim)

image6

  • width
TextView('','width',width=10)

image7

  • weight
TextView('','weight',weight=1)

image8

  • gravity
TextView('','gravity',gravity=Gravity.left)

image9

  • visibility
TextView('','',visibility=Visibility.visible)

image10

  • ex_style

not support windows

from terminal_layout import *
TextView('','ex_style',style=Style.ex_blink)

image11

  • ex_fore & ex_back

not support windows

from terminal_layout import *
TextView('','ex_fore',fore=Fore.ex_red_1)
TextView('','ex_back',back=Back.ex_red_1)

image12

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for terminal-layout, version 1.0.5
Filename, size File type Python version Upload date Hashes
Filename, size terminal_layout-1.0.5-py3-none-any.whl (34.8 kB) File type Wheel Python version py3 Upload date Hashes View hashes
Filename, size terminal_layout-1.0.5.tar.gz (17.2 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page