4
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

なんか作ってみる

Pythonと何かで

cursesを使って見た目動いてるものがいいかと思い、Macのターミナル上で”X”が左右へ移動するのを作りました。

なんとかライダー2kのクルマのライトっぽい感じに見えるかしら。

k2k.png

Ctl-C入れると終わります。

k2k.py
import curses
import time
import signal
import sys

N_CNT = 12
M_CNT = 24

MIN_NUM = 1
MAX_NUM = 26 

def handler(signal, frame):
        print('Done');
        sys.exit(0)
signal.signal(signal.SIGINT, handler)
 
stdscr = curses.initscr()

def main(stdscr):

    n = N_CNT
    m = M_CNT

    while(True):

        for i in range(MIN_NUM, MAX_NUM):

            m =  m + 1

            stdscr.clear()
            stdscr.addstr(n, m, 'X')
            stdscr.refresh()

            time.sleep(0.1)

        #stdscr.getkey()
 
        for i in range(MIN_NUM, MAX_NUM):

            m =  m - 1

            stdscr.clear()
            stdscr.addstr(n, m, 'X')
            stdscr.refresh()

            time.sleep(0.1)

    pass

if __name__ == '__main__':
    curses.wrapper(main)

ここ

4
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?