| Line | |
|---|
| 1 | from __future__ import with_statement |
|---|
| 2 | |
|---|
| 3 | import sys |
|---|
| 4 | sys.path.append('..') |
|---|
| 5 | |
|---|
| 6 | import ooxcb |
|---|
| 7 | from ooxcb.protocol import xproto |
|---|
| 8 | |
|---|
| 9 | conn = ooxcb.connect() |
|---|
| 10 | setup = conn.setup |
|---|
| 11 | |
|---|
| 12 | screen = conn.setup.roots[conn.pref_screen] |
|---|
| 13 | window = xproto.Window.create_toplevel_on_screen(conn, screen, |
|---|
| 14 | back_pixel=screen.white_pixel, |
|---|
| 15 | event_mask=xproto.EventMask.Exposure | xproto.EventMask.ButtonPress |
|---|
| 16 | ) |
|---|
| 17 | |
|---|
| 18 | gc = xproto.GContext.create(conn, window) |
|---|
| 19 | |
|---|
| 20 | with conn.bunch(): |
|---|
| 21 | window.map() |
|---|
| 22 | |
|---|
| 23 | @window.event |
|---|
| 24 | def on_expose(evt): |
|---|
| 25 | #gc.poly_line(window, [(0, 0), (640, 480)]) |
|---|
| 26 | gc.poly_line(window, [(10, 10), (600, 400), (10, 400), (10, 10)]) |
|---|
| 27 | conn.flush() |
|---|
| 28 | |
|---|
| 29 | @window.event |
|---|
| 30 | def on_button_press(evt): |
|---|
| 31 | conn.disconnect() |
|---|
| 32 | sys.exit() |
|---|
| 33 | |
|---|
| 34 | # Our mainloop. |
|---|
| 35 | while 1: |
|---|
| 36 | conn.wait_for_event().dispatch() |
|---|
| 37 | |
|---|
| 38 | conn.disconnect() |
|---|