test.py 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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 select('This is select input', [
  13. {'value': 1, 'label': 'one', 'selected': False, 'disabled': False},
  14. {'value': 2, 'label': 'two', 'selected': True, 'disabled': False},
  15. {'value': 2, 'label': 'three disabled', 'selected': False, 'disabled': True},
  16. ], type=SELECT, multiple=False)
  17. text_print('Your input:%s' % res)
  18. res = yield from select('This is multiple select input', [
  19. {'value': 1, 'label': 'one', 'selected': True, '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=True)
  23. text_print('Your input:%s' % res)
  24. res = yield from select('This is RADIO input', [
  25. {'value': 1, 'label': 'one', 'selected': False, 'disabled': False},
  26. {'value': 2, 'label': 'two', 'selected': True, 'disabled': False},
  27. {'value': 2, 'label': 'three disabled', 'selected': False, 'disabled': True},
  28. ], type=RADIO, multiple=True)
  29. text_print('Your input:%s' % res)
  30. res = yield from select('This is CHECKBOX 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=CHECKBOX, multiple=True)
  35. text_print('Your input:%s' % res)
  36. res = yield from input('This is single input')
  37. text_print('Your input:%s' % res)
  38. res = yield from input('This is another single input')
  39. text_print('Your input:%s' % res)
  40. res = yield from input_group('Group input', [
  41. input('Input 1', name='one'),
  42. input('Input 2', name='two'),
  43. select('Input 2', options=['A', 'B', 'C'], type=CHECKBOX, name='three')
  44. ])
  45. text_print('Your input:')
  46. json_print(res)
  47. start_ioloop(say_hello)