author | Radek Brich <radek.brich@devl.cz> |
Sat, 15 Mar 2014 14:43:47 +0100 | |
changeset 84 | 04dfb5ddf031 |
parent 83 | ebe732b9ef19 |
child 85 | 6828c5b16087 |
permissions | -rwxr-xr-x |
83
ebe732b9ef19
Refactor Driver, CursesDriver: init, close, draw.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1 |
#!/usr/bin/env python3 |
ebe732b9ef19
Refactor Driver, CursesDriver: init, close, draw.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
2 |
|
ebe732b9ef19
Refactor Driver, CursesDriver: init, close, draw.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
3 |
import sys |
ebe732b9ef19
Refactor Driver, CursesDriver: init, close, draw.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
4 |
sys.path.append('..') |
ebe732b9ef19
Refactor Driver, CursesDriver: init, close, draw.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
5 |
|
ebe732b9ef19
Refactor Driver, CursesDriver: init, close, draw.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
6 |
from tuikit.core.buffer import Buffer |
ebe732b9ef19
Refactor Driver, CursesDriver: init, close, draw.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
7 |
from tuikit.driver.curses import CursesDriver |
ebe732b9ef19
Refactor Driver, CursesDriver: init, close, draw.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
8 |
|
ebe732b9ef19
Refactor Driver, CursesDriver: init, close, draw.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
9 |
|
ebe732b9ef19
Refactor Driver, CursesDriver: init, close, draw.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
10 |
buffer = Buffer(16, 8) |
ebe732b9ef19
Refactor Driver, CursesDriver: init, close, draw.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
11 |
buffer.fill(c='#') |
ebe732b9ef19
Refactor Driver, CursesDriver: init, close, draw.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
12 |
buffer.hline(1, 1, 14, c='-') |
ebe732b9ef19
Refactor Driver, CursesDriver: init, close, draw.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
13 |
buffer.hline(1, 6, 14, c='-') |
ebe732b9ef19
Refactor Driver, CursesDriver: init, close, draw.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
14 |
buffer.vline(7, 2, 4, c='|') |
ebe732b9ef19
Refactor Driver, CursesDriver: init, close, draw.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
15 |
buffer.puts(8, 4, 'Hello!') |
ebe732b9ef19
Refactor Driver, CursesDriver: init, close, draw.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
16 |
buffer.frame() |
ebe732b9ef19
Refactor Driver, CursesDriver: init, close, draw.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
17 |
|
ebe732b9ef19
Refactor Driver, CursesDriver: init, close, draw.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
18 |
driver = CursesDriver() |
ebe732b9ef19
Refactor Driver, CursesDriver: init, close, draw.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
19 |
with driver: |
ebe732b9ef19
Refactor Driver, CursesDriver: init, close, draw.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
20 |
driver.draw(buffer) |
84
04dfb5ddf031
Refactor Driver, CursesDriver: draw, setattr, input.
Radek Brich <radek.brich@devl.cz>
parents:
83
diff
changeset
|
21 |
buffer.setattr('red on blue, bold') |
04dfb5ddf031
Refactor Driver, CursesDriver: draw, setattr, input.
Radek Brich <radek.brich@devl.cz>
parents:
83
diff
changeset
|
22 |
buffer.puts(8, 4, 'Hello!') |
83
ebe732b9ef19
Refactor Driver, CursesDriver: init, close, draw.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
23 |
driver.draw(buffer, 20, 10) |
84
04dfb5ddf031
Refactor Driver, CursesDriver: draw, setattr, input.
Radek Brich <radek.brich@devl.cz>
parents:
83
diff
changeset
|
24 |
driver.flush() |
04dfb5ddf031
Refactor Driver, CursesDriver: draw, setattr, input.
Radek Brich <radek.brich@devl.cz>
parents:
83
diff
changeset
|
25 |
driver.getevents() |
83
ebe732b9ef19
Refactor Driver, CursesDriver: init, close, draw.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
26 |