demos/03_event.py
changeset 119 dd91747504dd
parent 118 8c7970520632
equal deleted inserted replaced
118:8c7970520632 119:dd91747504dd
     2 
     2 
     3 from tuikit.core.buffer import Buffer
     3 from tuikit.core.buffer import Buffer
     4 from tuikit.driver.cursesw import CursesWDriver
     4 from tuikit.driver.cursesw import CursesWDriver
     5 
     5 
     6 buffer = Buffer()
     6 buffer = Buffer()
     7 line = 0
       
     8 with CursesWDriver() as driver:
     7 with CursesWDriver() as driver:
     9     buffer.resize(*driver.size)
     8     buffer.resize(*driver.size)
    10     buffer.puts(str(driver.size), 0, 10)
     9     buffer.puts("Press a key or mouse button. Ctrl-C to exit.", 0, 0)
       
    10     line = 1
    11     while True:
    11     while True:
    12         for event in driver.getevents():
       
    13             buffer.puts(str(event), 0, line)
       
    14             line += 1
       
    15         driver.draw(buffer)
    12         driver.draw(buffer)
    16         driver.flush()
    13         driver.flush()
    17         if line >= buffer.size.h:
    14         if line >= buffer.size.h:
    18             buffer.fill()
    15             buffer.fill()
    19             line = 0
    16             line = 0
       
    17         for event in driver.getevents():
       
    18             buffer.puts(str(event), 0, line)
       
    19             line += 1