| 1 |
#!/usr/bin/env python |
| 2 |
|
| 3 |
# Copyright (c) Twisted Matrix Laboratories. |
| 4 |
# See LICENSE for details. |
| 5 |
|
| 6 |
""" |
| 7 |
Displays a frame with two buttons and a background image, using pyui library. |
| 8 |
|
| 9 |
Run this example by typing in: |
| 10 |
python pyuidemo.py |
| 11 |
|
| 12 |
Select "Quit" button to exit demo. |
| 13 |
""" |
| 14 |
|
| 15 |
import pyui |
| 16 |
|
| 17 |
from twisted.internet import pyuisupport, reactor |
| 18 |
|
| 19 |
|
| 20 |
def onButton(self): |
| 21 |
print("got a button") |
| 22 |
|
| 23 |
|
| 24 |
def onQuit(self): |
| 25 |
reactor.stop() |
| 26 |
|
| 27 |
|
| 28 |
def main(): |
| 29 |
pyuisupport.install(args=(640, 480), kw={"renderer": "2d"}) |
| 30 |
|
| 31 |
w = pyui.widgets.Frame(50, 50, 400, 400, "clipme") |
| 32 |
b = pyui.widgets.Button("A button is here", onButton) |
| 33 |
q = pyui.widgets.Button("Quit!", onQuit) |
| 34 |
|
| 35 |
w.addChild(b) |
| 36 |
w.addChild(q) |
| 37 |
w.pack() |
| 38 |
|
| 39 |
w.setBackImage("pyui_bg.png") |
| 40 |
reactor.run() |
| 41 |
|
| 42 |
|
| 43 |
if __name__ == "__main__": |
| 44 |
main() |