Skip to main content

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布局工具)
https://github.com/gojuukaze/terminal_layout/raw/master/pic/demo_v2_1.gif https://github.com/gojuukaze/terminal_layout/raw/master/pic/demo.gif

Some extensions base on terminal_layout

progress.gif

choice.gif


** video demo **

https://asciinema.org/a/226120.svg

install

pip install terminal-layout

Dependencies

  • Python 2.7, 3.5+ (maybe 3.4)

  • Linux, OS X, and Windows systems.

Usage

  • easy demo:

import time
from terminal_layout import *

ctl = LayoutCtl.quick(TableLayout,
                      # table id: root
                      [
                          [TextView('t1', 'Hello World!', width=Width.fill, back=Back.blue)],  # <- row id: root_row_0,
                          [TextView('t2', '', fore=Fore.magenta)],  # <- row id: root_row_1,
                      ],
                      )

# or layout=ctl.get_layout()
layout = ctl.find_view_by_id('root')
layout.set_width(20)

# default: auto_re_draw=True
ctl.draw()

# call delay_set_text() must be set auto_re_draw=True,
# otherwise you must start a thread to call re_draw() by yourself
ctl.find_view_by_id('t2').delay_set_text('你好,世界!', delay=0.2)

time.sleep(0.5)
row3 = TableRow.quick_init('', [TextView('t3', 'こんにちは、世界!')])
layout.add_view(row3)

# If you call draw() with auto_re_draw=True, you must stop()
ctl.stop()

image2

  • disable auto_re_draw

import time
from terminal_layout import *

ctl = LayoutCtl.quick(TableLayout,
                      # table id: root
                      [
                          [TextView('t1', 'Hello World!', width=Width.fill, back=Back.blue)],  # <- row id: root_row_1,
                          [TextView('t2', '', fore=Fore.magenta)],  # <- row id: root_row_2,
                      ],
                      )


layout = ctl.find_view_by_id('root')
layout.set_width(20)

ctl.draw(auto_re_draw=False)

ctl.find_view_by_id('t2').set_text('你好,世界!')
ctl.re_draw()

time.sleep(0.5)
row3 = TableRow.quick_init('', [TextView('t3', 'こんにちは、世界!')])
layout.add_view(row3)
ctl.re_draw()

# don't need call stop()
# ctl.stop()
  • 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()

image3

Properties

  • fore & back

TextView('','fore',fore=Fore.red)
TextView('','back',back=Back.red)
https://github.com/gojuukaze/terminal_layout/raw/master/pic/color.jpeg
  • style

TextView('','style',style=Style.dim)
https://github.com/gojuukaze/terminal_layout/raw/master/pic/style.jpeg
  • width

TextView('','width',width=10)
https://github.com/gojuukaze/terminal_layout/raw/master/pic/width.jpeg
  • weight

TextView('','weight',weight=1)
https://github.com/gojuukaze/terminal_layout/raw/master/pic/weight.jpeg
  • gravity

TextView('','gravity',gravity=Gravity.left)
https://github.com/gojuukaze/terminal_layout/raw/master/pic/gravity.jpeg
  • visibility

TextView('','',visibility=Visibility.visible)
https://github.com/gojuukaze/terminal_layout/raw/master/pic/visibility.jpeg
  • ex_style (not support windows)

TextView('','ex_style',style=Style.ex_blink)
https://github.com/gojuukaze/terminal_layout/raw/master/pic/ex_style.jpeg
  • ex_fore & ex_back (not support windows)

TextView('','ex_fore',fore=Fore.ex_red_1)
TextView('','ex_back',back=Back.ex_red_1)
https://github.com/gojuukaze/terminal_layout/raw/master/pic/ex_color.jpeg

LICENSE

GPLv3

Thanks

  • colorama : Simple cross-platform colored terminal text in Python

  • colored : Very simple Python library for color and formatting in terminal

Project details


Download files

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

Source Distribution

terminal_layout-2.1.4.tar.gz (41.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

terminal_layout-2.1.4-py3-none-any.whl (49.2 kB view details)

Uploaded Python 3

File details

Details for the file terminal_layout-2.1.4.tar.gz.

File metadata

  • Download URL: terminal_layout-2.1.4.tar.gz
  • Upload date:
  • Size: 41.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.1

File hashes

Hashes for terminal_layout-2.1.4.tar.gz
Algorithm Hash digest
SHA256 61b5ad951b66208b4a1980407acac7e3202020b0065d64fdfb93c8e7b7bb8d79
MD5 608b53f04d20b194cc3c5b2fffee64b9
BLAKE2b-256 1c9fe2bd1537399e38dbdfb3cbde1961a175ffc5ff8fb3c7a3c68dbdc331959c

See more details on using hashes here.

File details

Details for the file terminal_layout-2.1.4-py3-none-any.whl.

File metadata

File hashes

Hashes for terminal_layout-2.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 a629f5042c4e99ac2fe59b3bdf3c99d0d03efc66513286ce87d76fc284641249
MD5 e7cefe8b1347f80a6db90ee9099167b5
BLAKE2b-256 8e9714901a909af9fcba4225a6ab93c4ae906639d0dd2b1525a48d9fefc62c28

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page