test.py 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. from tornado import gen
  2. from tornado.ioloop import IOLoop
  3. from tornado import websocket
  4. import json
  5. from wsrepl.ioloop import start_ioloop
  6. from wsrepl.interact import *
  7. from tornado.gen import sleep
  8. # 业务逻辑 协程
  9. def say_hello():
  10. # 向用户输出文字
  11. text_print("Welcome!!!")
  12. res = yield from actions('Action button', [
  13. {'value': '1', 'label': 'One', 'disabled': False},
  14. {'value': '2', 'label': 'Two', 'disabled': False},
  15. {'value': '3', 'label': 'Three', 'disabled': True},
  16. ])
  17. text_print('Your input:%s' % res)
  18. res = yield from select('This is select input', [
  19. {'value': 1, 'label': 'one', 'selected': False, 'disabled': False},
  20. {'value': 2, 'label': 'two', 'selected': True, 'disabled': False},
  21. {'value': 2, 'label': 'three disabled', 'selected': False, 'disabled': True},
  22. ], type=SELECT, multiple=False)
  23. text_print('Your input:%s' % res)
  24. res = yield from select('This is multiple select input', [
  25. {'value': 1, 'label': 'one', 'selected': True, 'disabled': False},
  26. {'value': 2, 'label': 'two', 'selected': True, 'disabled': False},
  27. {'value': 2, 'label': 'three disabled', 'selected': False, 'disabled': True},
  28. ], type=SELECT, multiple=True)
  29. text_print('Your input:%s' % res)
  30. res = yield from select('This is RADIO input', [
  31. {'value': 1, 'label': 'one', 'selected': False, 'disabled': False},
  32. {'value': 2, 'label': 'two', 'selected': True, 'disabled': False},
  33. {'value': 2, 'label': 'three disabled', 'selected': False, 'disabled': True},
  34. ], type=RADIO)
  35. text_print('Your input:%s' % res)
  36. res = yield from select('This is CHECKBOX input', [
  37. {'value': 1, 'label': 'one', 'selected': False, 'disabled': False},
  38. {'value': 2, 'label': 'two', 'selected': True, 'disabled': False},
  39. {'value': 2, 'label': 'three disabled', 'selected': False, 'disabled': True},
  40. ], type=CHECKBOX)
  41. text_print('Your input:%s' % res)
  42. res = yield from input('This is single input')
  43. text_print('Your input:%s' % res)
  44. res = yield from input('This is another single input')
  45. text_print('Your input:%s' % res)
  46. res = yield from input_group('Group input', [
  47. input('Input 1', name='one'),
  48. input('Input 2', name='two'),
  49. select('Input 2', options=['A', 'B', 'C'], type=CHECKBOX, name='three')
  50. ])
  51. text_print('Your input:')
  52. json_print(res)
  53. start_ioloop(say_hello)