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.

92 lines
1.5 KiB

  1. # Using Gooey as a frontend for any language.
  2. Gooey can be used as the frontend for _any_ language. Whether you've built your application in Java, Node, or Haskell, Gooey can still be used to create a fast, free UI with just a little bit of Python.
  3. Gooey let's you specify the `target` that is should execute during runtime as an argument to the main decorator.
  4. Clojure example:
  5. ```
  6. lein new app clojure-program
  7. ```
  8. ```
  9. (ns clojure-program.core
  10. (:gen-class))
  11. (defn -main
  12. "Tiny example."
  13. [& args]
  14. (println "here are the args: " args)
  15. (doseq [x (range 10)]
  16. (println x)
  17. (Thread/sleep 500)))
  18. ```
  19. ```
  20. lein uberjar
  21. ```
  22. ```
  23. ./target/uberjar/clojure-program-0.1.0-SNAPSHOT-standalone.jar
  24. ```
  25. ```
  26. java -jar target/uberjar/clojure-program-0.1.0-SNAPSHOT-standalone.jar -arg1 foo -arg2 bar
  27. ```
  28. ```
  29. here are the args: (-f foo -b qwer)
  30. 0
  31. 1
  32. 2
  33. 3
  34. etc...
  35. ```
  36. ```
  37. mkdir clojure-ui-example
  38. cd clojure-ui-example
  39. ```
  40. ```
  41. virtualenv venv
  42. pip install gooey
  43. ```
  44. ```
  45. mkdir resources
  46. ```
  47. src/main.py
  48. ```
  49. from gooey import Gooey, GooeyParser, local_resource_path
  50. jar_path = local_resource_path('resources/clojure-gooey-0.1.0-SNAPSHOT-standalone.jar')
  51. @Gooey(image_dir=local_resource_path('stuff/images/'), target='java -jar ' + jar_path)
  52. def main():
  53. parser = GooeyParser(description="My program")
  54. parser.add_argument('filename', metavar='Filename', help='filename', widget='FileChooser')
  55. parser.parse_args()
  56. if __name__ == '__main__':
  57. main()
  58. ```