| 1 | import x3 |
| 2 | |
| 3 | def my_callback(cmd, what, arg, more): |
| 4 | print cmd, what, arg |
| 5 | |
| 6 | class my_viewclient: |
| 7 | def key(self, name, mods, code): |
| 8 | print name, mods, code |
| 9 | return 1 |
| 10 | def mouse(self, buttons, mods, x, y): |
| 11 | print buttons, mods, x, y |
| 12 | def draw(self, dc): |
| 13 | print 'rect:', dc.rect |
| 14 | dc.moveto(0, 0) |
| 15 | dc.lineto(100, 100) |
| 16 | print dc.currentpoint() |
| 17 | dc.stroke() |
| 18 | dc.selectfont("Nimbus Sans L", 0, 0) |
| 19 | dc.setfontsize(12) |
| 20 | dc.moveto(50, 10) |
| 21 | dc.showtext(u"\u00a1hello, world!") |
| 22 | print dc.textextents(u"\u00a1hello, world!") |
| 23 | |
| 24 | win = x3.window(0, "foo", my_callback) |
| 25 | |
| 26 | m = x3.menu(win, "bar") |
| 27 | |
| 28 | x3.menuitem(m, "baz", "bazz", "<ctrl>b") |
| 29 | x3.menusep(m) |
| 30 | x3.menuitem(m, "Quit", "quit", "<ctrl>q") |
| 31 | |
| 32 | v = x3.vbox(win, 0, 12) |
| 33 | |
| 34 | v.setpacking(True, False, 0) |
| 35 | x3.button(v, "butt", u"\u00a1hello!") |
| 36 | x3.edittext(v, "quux") |
| 37 | v.setpacking(True, True, 0) |
| 38 | x3.view(v, 263, my_viewclient()) |
| 39 | |
| 40 | x3.main() |