author | Radek Brich <radek.brich@devl.cz> |
Sun, 22 Feb 2015 09:53:13 +0100 | |
changeset 119 | dd91747504dd |
parent 118 | 8c7970520632 |
permissions | -rwxr-xr-x |
118
8c7970520632
Add mouse events, event demo.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1 |
#!/usr/bin/env python3 |
8c7970520632
Add mouse events, event demo.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
2 |
|
8c7970520632
Add mouse events, event demo.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
3 |
from tuikit.core.buffer import Buffer |
8c7970520632
Add mouse events, event demo.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
4 |
from tuikit.driver.cursesw import CursesWDriver |
8c7970520632
Add mouse events, event demo.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
5 |
|
8c7970520632
Add mouse events, event demo.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
6 |
buffer = Buffer() |
8c7970520632
Add mouse events, event demo.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
7 |
with CursesWDriver() as driver: |
8c7970520632
Add mouse events, event demo.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
8 |
buffer.resize(*driver.size) |
119
dd91747504dd
Redraw widgets on request. Add scrollbar demo.
Radek Brich <radek.brich@devl.cz>
parents:
118
diff
changeset
|
9 |
buffer.puts("Press a key or mouse button. Ctrl-C to exit.", 0, 0) |
dd91747504dd
Redraw widgets on request. Add scrollbar demo.
Radek Brich <radek.brich@devl.cz>
parents:
118
diff
changeset
|
10 |
line = 1 |
118
8c7970520632
Add mouse events, event demo.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
11 |
while True: |
8c7970520632
Add mouse events, event demo.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
12 |
driver.draw(buffer) |
8c7970520632
Add mouse events, event demo.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
13 |
driver.flush() |
8c7970520632
Add mouse events, event demo.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
14 |
if line >= buffer.size.h: |
8c7970520632
Add mouse events, event demo.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
15 |
buffer.fill() |
8c7970520632
Add mouse events, event demo.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
16 |
line = 0 |
119
dd91747504dd
Redraw widgets on request. Add scrollbar demo.
Radek Brich <radek.brich@devl.cz>
parents:
118
diff
changeset
|
17 |
for event in driver.getevents(): |
dd91747504dd
Redraw widgets on request. Add scrollbar demo.
Radek Brich <radek.brich@devl.cz>
parents:
118
diff
changeset
|
18 |
buffer.puts(str(event), 0, line) |
dd91747504dd
Redraw widgets on request. Add scrollbar demo.
Radek Brich <radek.brich@devl.cz>
parents:
118
diff
changeset
|
19 |
line += 1 |