GithubHelp home page GithubHelp logo

skyformat99 / terminal_layout Goto Github PK

View Code? Open in Web Editor NEW

This project forked from gojuukaze/terminal_layout

0.0 1.0 0.0 2.9 MB

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

License: GNU General Public License v3.0

Python 100.00%

terminal_layout's Introduction

terminal_layout

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

asciicast

link

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()

  • 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()

  • 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()

Properties

属性说明

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

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

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

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

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

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

  • ex_style (not support windows)
TextView('','ex_style',style=Style.ex_blink)

  • ex_fore & ex_back (not support windows)
TextView('','ex_fore',fore=Fore.ex_red_1)
TextView('','ex_back',back=Back.ex_red_1)

LICENSE

GPLv3

Thanks

  • colorama : Simple cross-platform colored terminal text in Python
  • colored : Very simple Python library for color and formatting in terminal

terminal_layout's People

Contributors

gojuukaze avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.