• home
  • about
  • 全ての投稿
  • ソフトウェア・ハードウェアの設定のまとめ
  • 分析関連のまとめ
  • ヘルスケア関連のまとめ
  • 生涯学習関連のまとめ

blessed

date: 2020-12-29 excerpt: blessed

tag: blessedpythoncurses


blessed

概要

  • terminalで自由に描画する際に必要なライブラリ
  • pythonのデフォルトのcursesは全画面を描画の対象とするが、blessedは特定のterminalの空き領域のみを対象とできる

公式サイト

  • https://blessed.readthedocs.io/

具体例

  • https://github.com/jquast/blessed/tree/master/bin

最小構成

from blessed import Terminal
import sys


def main():
    """Program entry point."""
    term = Terminal()
    assert term.hpa(1) != u'', (
        'Terminal does not support hpa (Horizontal position absolute)')

    print()
    with term.cbreak():
        inp = None
        while inp != "q":
            sys.stderr.write(term.move_yx(term.height-1, 0) + "なにか出力するテキスト")
            sys.stderr.flush()
            inp = term.inkey(0.04)


if __name__ == "__main__":
    main()

練習で作ったソフトウェア

googleカレンダーをcuiで描画して、vimのキーバインドで詳細を確認できるソフトウェア

  • gist


blessedpythoncurses Share Tweet