Проект помогает быстро создавать макеты в терминале.
(Это инструмент для создания пользовательского интерфейса командной строки).
Некоторые расширения основаны на terminal_layout:
Видео демонстрация
pip install terminal-layout
Python | terminal_layout |
---|---|
2.7 | 2.1.x |
3.5+ | 3.x |
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,
],
)
# или layout=ctl.get_layout()
layout = ctl.find_view_by_id('root')
layout.set_width(20)
# по умолчанию: auto_re_draw=True
ctl.draw()
# вызов delay_set_text() должен быть установлен auto_re_draw=True,
# в противном случае необходимо запустить поток для вызова re_draw() самостоятельно
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)
# Если вы вызываете draw() с auto_re_draw=True, вы должны остановить()
ctl.stop()
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()
# не нужно вызывать stop()
# ctl.stop()
# -*- 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()
TextView('','fore',fore=Fore.red)
TextView('','back',back=Back.red)
TextView('','style',style=Style.dim)
TextView('','width',width=10)
TextView('','weight',weight=1)
TextView('','gravity',gravity=Gravity.left)
TextView('','',visibility=Visibility.visible)
TextView('','ex_style',style=Style.ex_blink)
```python
TextView('', 'ex_fore', fore=Fore.ex_red_1)
TextView('', 'ex_back', back=Back.ex_red_1)
<img width="560" src="pic/ex_color.jpeg"/>
# LICENSE
[GPLv3](https://github.com/gojuukaze/terminal_layout/blob/master/LICENSE)
# Thanks
* [colorama](https://github.com/tartley/colorama): простая кроссплатформенная библиотека для цветного текста в терминале на Python;
* [colored](https://gitlab.com/dslackw/colored): очень простая библиотека Python для работы с цветом и форматированием в терминале.
# Спонсорство
Разработка open-source — непростое дело. Если вы считаете, что это вам помогло, можете поддержать проект небольшой суммой.
You can comment after Login
Inappropriate content may be displayed here and will not be shown on the page. You can check and modify it through the relevant editing function
If you confirm that the content does not involve inappropriate language/advertisement redirection/violence/vulgar pornography/infringement/piracy/false/insignificant or illegal content related to national laws and regulations, you can click submit to make an appeal, and we will handle it as soon as possible.
Comments ( 0 )