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.

331 lines
12 KiB

10 years ago
10 years ago
11 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
9 years ago
9 years ago
10 years ago
9 years ago
10 years ago
10 years ago
9 years ago
10 years ago
9 years ago
10 years ago
10 years ago
9 years ago
9 years ago
10 years ago
10 years ago
10 years ago
9 years ago
10 years ago
9 years ago
10 years ago
9 years ago
10 years ago
10 years ago
10 years ago
10 years ago
9 years ago
9 years ago
9 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
9 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
9 years ago
9 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
9 years ago
  1. Gooey (Beta)
  2. =====
  3. Turn (almost) any Python Console Program into a GUI application with one line
  4. <p align="center">
  5. <img src="https://raw.githubusercontent.com/chriskiehl/Gooey/master/resources/primary.png"/>
  6. </p>
  7. Table of Contents
  8. -----------------
  9. - [Gooey](#gooey)
  10. - [Table of contents](#table-of-contents)
  11. - [Latest Update](#latest-update)
  12. - [Quick Start](#quick-start)
  13. - [Installation Instructions](#installation-instructions)
  14. - [Usage](#usage)
  15. - [What It Is](#what-is-it)
  16. - [Why Is It](#why)
  17. - [Who is this for](#who-is-this-for)
  18. - [How does it work](#how-does-it-work)
  19. - [Configuration](#configuration)
  20. - [Full/Advanced](#advanced)
  21. - [Basic](#basic)
  22. - [No Config](#no-config)
  23. - [Final Screen](#final-screen)
  24. - [Change Log](#change-log)
  25. - [TODO](#todo)
  26. - [Contributing](#wanna-help)
  27. - [Image Credits](#image-credits)
  28. ----------
  29. ###Artist Wanted!
  30. Want to contribute to Gooey? We need icons/logos!
  31. Drop me an <a href="mailto:audionautic@gmail.com">email</a> if you want to help out!
  32. ----------------
  33. ##Quick Start
  34. ###Installation instructions
  35. The easiest way to install Gooey is via `pip`
  36. pip install Gooey
  37. Alternatively, you can install Gooey by cloning the project to your local directory
  38. git clone https://github.com/chriskiehl/Gooey.git
  39. run `setup.py`
  40. python setup.py install
  41. ###Usage
  42. Gooey is attached to your code via a simple decorator on whichever method has your `argparse` declarations (usually `main`).
  43. from gooey import Gooey
  44. @Gooey <--- all it takes! :)
  45. def main():
  46. parser = ArgumentParser(...)
  47. # rest of code
  48. Different styling and functionality can be configured by passing arguments into the decorator.
  49. # options
  50. @Gooey(advanced=Boolean, # toggle whether to show advanced config or not
  51. language=language_string, # Translations configurable via json
  52. show_config=True, # skip config screens all together
  53. program_name='name', # Defaults to script name
  54. program_description, # Defaults to ArgParse Description
  55. default_size=(610, 530), # starting size of the GUI
  56. required_cols=1, # number of columns in the "Required" section
  57. optional_cols=2, # number of columbs in the "Optional" section
  58. dump_build_config=False) # Dump the JSON Gooey uses to configure itself
  59. )
  60. def main():
  61. parser = ArgumentParser(...)
  62. # rest of code
  63. See: [How does it Work](#how-does-it-work) section for details on each option.
  64. Gooey will do its best to choose sensible widget defaults to display in the GUI. However, if more fine tuning is desired, you can use the drop-in replacement `GooeyParser` in place of `ArgumentParser`. This lets you control which widget displays in the GUI. See: [GooeyParser](#gooeyparser)
  65. from gooey import Gooey, GooeyParser
  66. @Gooey
  67. def main():
  68. parser = GooeyParser(description="My Cool GUI Program!")
  69. parser.add_argument('Filename', widget="FileChooser")
  70. parser.add_argument('Date', widget="DateChooser")
  71. ...
  72. What is it?
  73. -----------
  74. Gooey converts your Console Applications into end-user-friendly GUI applications. It lets you focus on building robust, configurable programs in a familiar way, all without having to worry about how it will be presented to and interacted with by your average user.
  75. Why?
  76. ---
  77. Because as much as we love the command prompt, the rest of the world looks at it like an ugly relic from the early '80s. On top of that, more often than not programs need to do more than just one thing, and that means giving options, which previously meant either building a GUI, or trying to explain how to supply arguments to a Console Application. Gooey was made to (hopefully) solve those problems. It makes programs easy to use, and pretty to look at!
  78. Who is this for?
  79. ----------------
  80. If you're building utilities for yourself, other programmers, or something which produces a result that you want to capture and pipe over to another console application (e.g. *nix philosophy utils), Gooey probably isn't the tool for you. However, if you're building 'run and done,' around-the-office-style scripts, things that shovel bits from point A to point B, or simply something that's targeted at a non-programmer, Gooey is the perfect tool for the job. It lets you build as complex of an application as your heart desires all while getting the GUI side for free.
  81. How does it work?
  82. -----------------
  83. Gooey is attached to your code via a simple decorator on whichever method has your `argparse` declarations.
  84. @Gooey
  85. def my_run_func():
  86. parser = ArgumentParser(...)
  87. # rest of code
  88. At run-time, it parses your Python script for all references to `ArgumentParser`. (The older `optparse` is currently not supported.) These references are then extracted, assigned a `component type` based on the `'action'` they provide, and finally used to assemble the GUI.
  89. ####Mappings:
  90. Gooey does its best to choose sensible defaults based on the options it finds. Currently, `ArgumentParser._actions` are mapped to the following `WX` components.
  91. | Parser Action | Widget | Example |
  92. |:----------------------|-----------|------|
  93. | store | TextCtrl | <img src="https://raw.githubusercontent.com/chriskiehl/Gooey/master/resources/general_tb.png"/>|
  94. | store_const | CheckBox | <img src="https://raw.githubusercontent.com/chriskiehl/Gooey/master/resources/check_box.png"/>|
  95. | store_true| CheckBox | <img src="https://raw.githubusercontent.com/chriskiehl/Gooey/master/resources/check_box.png"/>|
  96. | store_False | CheckBox| <img src="https://raw.githubusercontent.com/chriskiehl/Gooey/master/resources/check_box.png"/> |
  97. | append | TextCtrl | <img src="https://raw.githubusercontent.com/chriskiehl/Gooey/master/resources/general_tb.png"/> |
  98. | count| DropDown &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | <img src="https://raw.githubusercontent.com/chriskiehl/Gooey/master/resources/count_dropdown.png"/> |
  99. | Mutually Exclusive Group | RadioGroup | <img src="https://github.com/chriskiehl/Gooey/blob/master/resources/radio_group.png"/>
  100. |choice &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;| DropDown | <img src="https://raw.githubusercontent.com/chriskiehl/Gooey/master/resources/options_dropdown.png"/> |
  101. ###GooeyParser
  102. If the above defaults aren't cutting it, you can control the exact widget type by using the drop-in `ArgumentParser` replacement `GooeyParser`. This gives you the additional keyword argument `widget`, to which you can supply the name of the component you want to display. Best part? You don't have to change any of your `argparse` code to use it. Drop it in, and you're good to go.
  103. **Example:**
  104. from argparse import ArgumentParser
  105. ....
  106. def main():
  107. parser = ArgumentParser(description="My Cool Gooey App!")
  108. parser.add_argument('filename', help="name of the file to process")
  109. Given then above, Gooey would select a normal `TextField` as the widget type like this:
  110. <p align="center">
  111. <img src="https://raw.githubusercontent.com/chriskiehl/Gooey/master/resources/textfield_demo.PNG">
  112. </p>
  113. However, by dropping in `GooeyParser` and supplying a `widget` name, you can display a much more user friendly `FileChooser`
  114. from gooey import GooeyParser
  115. ....
  116. def main():
  117. parser = GooeyParser(description="My Cool Gooey App!")
  118. parser.add_argument('filename', help="name of the file to process", widget='FileChooser')
  119. <p align="center"><img src="https://github.com/chriskiehl/Gooey/blob/master/resources/chooser_demo.PNG"></p>
  120. **Custom Widgets:**
  121. | Widget | Example |
  122. |----------------|------------------------------|
  123. | Directory/FileChooser | <p align="center"><img src="https://raw.githubusercontent.com/chriskiehl/Gooey/master/resources/filechooser.gif" width="400"></p> |
  124. | DateChooser &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;| <p align="center"><img src="https://raw.githubusercontent.com/chriskiehl/Gooey/master/resources/datechooser.gif" width="400"></p> |
  125. -------------------------------------------
  126. Configuration
  127. ------------
  128. Gooey comes in three main flavors.
  129. - Full/Advanced
  130. - Basic
  131. - No config
  132. Each has the following options:
  133. | Parameter | Summary |
  134. |-----------|---------|
  135. | language | Gooey is (kind of) international ready (sans Unicode issues (TODO)). All program text is stored in an external `json` file. Translating to your host language only requires filling in the key/value pairs.|
  136. |program_name | The name displayed in the title bar of the GUI window. If the value is `None`, the title is pulled from `sys.argv[0]`. |
  137. | program_description | Sets the text displayed in the top panel of the `Settings` screen. If `None` the description is pulled from the `ArgumentParser`. |
  138. ###Advanced
  139. The default view is the "full" or "advanced" configuration screen. It can be toggled via the `advanced` parameter in the `Gooey` decorator.
  140. @gooey(advanced=True)
  141. def main():
  142. # rest of code
  143. This view presents each action in the `Argument Parser` as a unique GUI component. This view is ideal for presenting the program to users which are unfamiliar with command line options and/or Console Programs in general. Help messages are displayed along side each component to make it as clear as possible which each widget does.
  144. <p align="center">
  145. <img src="https://raw.githubusercontent.com/chriskiehl/Gooey/master/resources/advanced_config.png">
  146. </p>
  147. --------------------------------------------
  148. ###Basic
  149. The basic view is best for times when the user is familiar with Console Applications, but you still want to present something a little more polished than a simple terminal. The basic display is accessed by setting the `advanced` parameter in the `gooey` decorator to `False`.
  150. @gooey(advanced=False)
  151. def main():
  152. # rest of code
  153. <p align="center">
  154. <img src="https://raw.githubusercontent.com/chriskiehl/Gooey/master/resources/basic_config.png">
  155. </p>
  156. ----------------------------------------------
  157. ###No Config
  158. No Config pretty much does what you'd expect: it doesn't show a configuration screen. It hops right to the `display` section and begins execution of the host program. This is the one for improving the appearance of little one-off scripts.
  159. <p align="center">
  160. <img src="https://raw.githubusercontent.com/chriskiehl/Gooey/master/resources/no_config.png">
  161. </p>
  162. ---------------------------------------
  163. Final Screen
  164. ------------
  165. <p align="center">
  166. <img src="https://raw.githubusercontent.com/chriskiehl/Gooey/master/resources/final_screen.png">
  167. </p>
  168. ----------------------------------------------
  169. ###Change Log
  170. ----------
  171. - Removed parsing code, replaced it with @SylvainDe patch
  172. - Fixed issue #87
  173. - Fixed issue #85
  174. - Argparse no longer required to me in `main` (issue 84)
  175. - Drag and Drop support (`Issue #28`)
  176. <p align="center">
  177. <img src="https://github.com/chriskiehl/Gooey/blob/master/resources/dragdrop.gif" width="500">
  178. </p>
  179. Tada!
  180. - Added drag and drop support
  181. - Added new widget packs: DateChooser, FileChooser, DirChooser
  182. - fixed several parsing related issues.
  183. - Gooey now has a sane setup.py (thanks to hero user LudoVio)
  184. - Gooey now builds from json for easy configurability
  185. - Side Note: This was done with big strides towards making Gooey language agnostic. Coming Soon!
  186. - Fixed GUI layout so that resizing works better
  187. ###Planned Features:
  188. - Language agnostic!
  189. - Stop/cancel button on run screen
  190. TODO
  191. ----
  192. * Add to pypi
  193. * Update graphics
  194. * Get OS X version working.
  195. Wanna help?
  196. -----------
  197. Code, translation, graphics? Pull requests are welcome.
  198. [1]: http://i.imgur.com/7fKUvw9.png