demos/01_buffer.py
author Radek Brich <radek.brich@devl.cz>
Sat, 15 Mar 2014 15:28:20 +0100
changeset 85 6828c5b16087
parent 83 ebe732b9ef19
child 92 b97c4e25ed6d
permissions -rwxr-xr-x
Add colors to curses demo.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
78
6031e99c8ad3 Add Buffer class with basic drawing methods.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     1
#!/usr/bin/env python3
6031e99c8ad3 Add Buffer class with basic drawing methods.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     2
6031e99c8ad3 Add Buffer class with basic drawing methods.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     3
import sys
6031e99c8ad3 Add Buffer class with basic drawing methods.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     4
sys.path.append('..')
6031e99c8ad3 Add Buffer class with basic drawing methods.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     5
6031e99c8ad3 Add Buffer class with basic drawing methods.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     6
from tuikit.core.buffer import Buffer
83
ebe732b9ef19 Refactor Driver, CursesDriver: init, close, draw.
Radek Brich <radek.brich@devl.cz>
parents: 81
diff changeset
     7
from tuikit.driver.driver import Driver
78
6031e99c8ad3 Add Buffer class with basic drawing methods.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     8
6031e99c8ad3 Add Buffer class with basic drawing methods.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     9
83
ebe732b9ef19 Refactor Driver, CursesDriver: init, close, draw.
Radek Brich <radek.brich@devl.cz>
parents: 81
diff changeset
    10
buffer = Buffer(16, 8)
ebe732b9ef19 Refactor Driver, CursesDriver: init, close, draw.
Radek Brich <radek.brich@devl.cz>
parents: 81
diff changeset
    11
buffer.fill(c='#')
ebe732b9ef19 Refactor Driver, CursesDriver: init, close, draw.
Radek Brich <radek.brich@devl.cz>
parents: 81
diff changeset
    12
buffer.hline(1, 1, 14, c='-')
ebe732b9ef19 Refactor Driver, CursesDriver: init, close, draw.
Radek Brich <radek.brich@devl.cz>
parents: 81
diff changeset
    13
buffer.hline(1, 6, 14, c='-')
ebe732b9ef19 Refactor Driver, CursesDriver: init, close, draw.
Radek Brich <radek.brich@devl.cz>
parents: 81
diff changeset
    14
buffer.vline(7, 2, 4, c='|')
ebe732b9ef19 Refactor Driver, CursesDriver: init, close, draw.
Radek Brich <radek.brich@devl.cz>
parents: 81
diff changeset
    15
buffer.puts(8, 4, 'Hello!')
ebe732b9ef19 Refactor Driver, CursesDriver: init, close, draw.
Radek Brich <radek.brich@devl.cz>
parents: 81
diff changeset
    16
buffer.frame()
78
6031e99c8ad3 Add Buffer class with basic drawing methods.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    17
83
ebe732b9ef19 Refactor Driver, CursesDriver: init, close, draw.
Radek Brich <radek.brich@devl.cz>
parents: 81
diff changeset
    18
driver = Driver()
ebe732b9ef19 Refactor Driver, CursesDriver: init, close, draw.
Radek Brich <radek.brich@devl.cz>
parents: 81
diff changeset
    19
driver.init()
ebe732b9ef19 Refactor Driver, CursesDriver: init, close, draw.
Radek Brich <radek.brich@devl.cz>
parents: 81
diff changeset
    20
driver.draw(buffer)
ebe732b9ef19 Refactor Driver, CursesDriver: init, close, draw.
Radek Brich <radek.brich@devl.cz>
parents: 81
diff changeset
    21
driver.close()
ebe732b9ef19 Refactor Driver, CursesDriver: init, close, draw.
Radek Brich <radek.brich@devl.cz>
parents: 81
diff changeset
    22