You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

94 lines
3.1 KiB

  1. from gooey import Gooey
  2. from gooey import GooeyParser
  3. @Gooey(
  4. sidebar_title="Your Custom Title",
  5. show_sidebar=True,
  6. dump_build_config=True,
  7. show_success_modal=False,
  8. force_stop_is_error=False,
  9. language='chinese'
  10. )
  11. def main():
  12. dest_vars = [
  13. 'textfield',
  14. 'textarea',
  15. 'password',
  16. 'commandfield',
  17. 'dropdown',
  18. 'listboxie',
  19. 'counter',
  20. 'overwrite',
  21. 'mutextwo',
  22. 'filechooser',
  23. 'filesaver',
  24. 'dirchooser',
  25. 'datechooser'
  26. ]
  27. parser = get_parser()
  28. args = parser.parse_args()
  29. import time
  30. for i in dest_vars:
  31. assert getattr(args, i) is not None
  32. print("Success")
  33. def get_parser():
  34. desc = "Example application to show Gooey's various widgets"
  35. parser = GooeyParser(description=desc, add_help=False)
  36. parser.add_argument('--textfield', default=2, widget="TextField")
  37. parser.add_argument('--textarea', default="oneline twoline", widget='Textarea')
  38. parser.add_argument('--password', default="hunter42", widget='PasswordField')
  39. parser.add_argument('--commandfield', default="cmdr", widget='CommandField')
  40. parser.add_argument('--dropdown', choices=["one", "two"], default="two", widget='Dropdown')
  41. parser.add_argument('--listboxie',
  42. nargs='+',
  43. default=['Option three', 'Option four'],
  44. choices=['Option one', 'Option two', 'Option three',
  45. 'Option four'],
  46. widget='Listbox',
  47. gooey_options={
  48. 'height': 300,
  49. 'validate': '',
  50. 'heading_color': '',
  51. 'text_color': '',
  52. 'hide_heading': True,
  53. 'hide_text': True,
  54. })
  55. parser.add_argument('-c', '--counter', default=3, action='count', widget='Counter')
  56. parser.add_argument("-o", "--overwrite", action="store_true", default=True, widget='CheckBox')
  57. parser.add_argument("-bo", "--blockcheckbox", action="store_true", default=True, widget='BlockCheckbox')
  58. ### Mutex Group ###
  59. verbosity = parser.add_mutually_exclusive_group(
  60. required=True,
  61. gooey_options={
  62. 'initial_selection': 1
  63. }
  64. )
  65. verbosity.add_argument(
  66. '--mutexone',
  67. default=True,
  68. action='store_true',
  69. help="Show more details")
  70. verbosity.add_argument(
  71. '--mutextwo',
  72. default='mut-2',
  73. widget='TextField')
  74. parser.add_argument("--filechooser", default="fc-value", widget='FileChooser')
  75. parser.add_argument("--filesaver", default="fs-value", widget='FileSaver')
  76. parser.add_argument("--dirchooser", default="dc-value", widget='DirChooser')
  77. parser.add_argument("--datechooser", default="2015-01-01", widget='DateChooser')
  78. parser.add_argument("--multidirchooser", default="2015-01-01", widget='MultiDirChooser')
  79. return parser
  80. if __name__ == '__main__':
  81. main()