Skip to content

Commit

Permalink
docs
Browse files Browse the repository at this point in the history
  • Loading branch information
gojuukaze committed Jan 13, 2023
1 parent 74e01f5 commit a4374fb
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 13 deletions.
28 changes: 17 additions & 11 deletions docs/draw.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
- **LayoutCtl** :layout管理器,负责绘制所有元素
- **View** : 基础控件,Layout 与 TextView 其实都属于 View

- Layout : 布局控制器,控制 TextView 显示的位置。 目前支持的Layout有两种 TableLayout(表格布局), TableRow(行布局)
- Layout : 布局控制器,控制 TextView 显示的位置。 目前支持的Layout有两种 TableLayout(表格布局), TableRow(行布局)

- TextView : 用于显示文字的view。

Expand Down Expand Up @@ -43,7 +43,8 @@

每次手动创建layout,text_view会很麻烦,这里为 TableRow,TableLayout,LayoutCtl 提供了quick_init()函数帮助快速创建

- TableRow
TableRow
~~~~~~~~~~~~~~~~

.. code-block:: python
Expand All @@ -59,14 +60,13 @@
.. note::
LayoutCtl()接受的参数是View,因此直接把TableRow放到ctl中。

你也可以把TextView直接放入LayoutCtl(),如:

.. code-block:: python
你也可以把TextView直接放入LayoutCtl(),如::

ctl = LayoutCtl(TextView('title', 'Title', width=10, back=Back.blue))


- TableLayout
TableLayout
~~~~~~~~~~~~~~~~~

.. code-block:: python
Expand Down Expand Up @@ -100,9 +100,8 @@ v3.0.0+ data支持 ``[[TextView]]`` 这样的形式,且可以通过 ``row_id_f
)
- LayoutCtl

LayoutCtl
~~~~~~~~~~~~~~~~
.. code-block:: python
from terminal_layout import *
Expand All @@ -111,14 +110,21 @@ v3.0.0+ data支持 ``[[TextView]]`` 这样的形式,且可以通过 ``row_id_f
[
[TextView('title', 'Title', width=Width.wrap)], # row id: root_row_0
[TextView('data1', '1.', width=3), TextView('data2', 'foo', width=5)], # row id: root_row_1
]
],
id="root",
row_id_formatter='{table_id}_row_{index}'
)
ctl.draw()
ctl.stop()
.. note::

对于LayoutCtl.quick(),会自动为layout添加id
v3.0.0开始,可以通过 ``id`` 配置最外层的layout id。

创建 ``TableLayout`` 时可通过 ``row_id_formatter`` 配置 row id。其支持的展位符如下:

- table_id :即 id 设置的值
- index

修改view的属性
----------------
Expand Down
4 changes: 3 additions & 1 deletion docs/getStarted.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,6 @@
ctl.draw()
ctl.stop()
``LayoutCtl`` , ``TableLayout`` , ``TextView`` 是该项目重要的元素,阅读 :doc:`/draw` , :doc:`/keyListener` 熟悉如何使用它们
``LayoutCtl`` , ``TableLayout`` , ``TextView`` 是该项目重要的元素,接下来阅读 :doc:`/draw` 熟悉如何使用它们。

如需监听键盘事件,则阅读: :doc:`/keyListener`
6 changes: 6 additions & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,17 @@ Welcome to terminal_layout's documentation!
.. image:: _static/demo_v2_1.gif

|
.. image:: _static/demo.gif

|
.. image:: https://asciinema.org/a/226120.svg
:target: https://asciinema.org/a/226120

|
你可以从 :doc:`getStarted` 开始学习如何使用terminal_layout


Expand Down
2 changes: 1 addition & 1 deletion docs/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ installation
Python Support
===================
----------------------

====== ===============
Python terminal_layout
Expand Down

0 comments on commit a4374fb

Please sign in to comment.