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.

251 lines
9.4 KiB

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
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
  1. Gooey (Beta)
  2. =====
  3. Turn (almost) any 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. - [Change Log](#change-log)
  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. - [TODO](#todo)
  25. - [Contributing](#wanna-help)
  26. - [Image Credits](#image-credits)
  27. Change Log
  28. ----------
  29. - Added `Restart` Button. `Issue #20` (hacked it in there ;) need to pretty it up later.)
  30. - Fixed bug in language class
  31. **Notes**
  32. First attempt at packaging went not as planned. I've since swapped from `distutils` to `setuptools` and that seems to have remedied the issue. However, if you do receive an error after running `setup.py` please let me know by submitting an issue! It was caused by the image and language files not copying to the correct location during setup, so in a pinch you can remedy this by manually copying `/images` and `/languages` from the repo into `/site-packages/gooey`.
  33. **Panned Features:**
  34. - docopt support -- The people demand it!
  35. - Ability to customize widgets (e.g. FileChooser instead of TextBox)
  36. - stop/cancel button on run screen
  37. **Currently Working on:**
  38. Fixing Parser issues ([#18](https://github.com/chriskiehl/Gooey/issues/18))
  39. ----------
  40. ##Quick Start
  41. ###Installation instructions
  42. To install Gooey, simply clone the project to your local directory
  43. git clone https://github.com/chriskiehl/Gooey.git
  44. ###Usage
  45. Gooey is attached to your code via a simple decorator on your `main` method.
  46. from gooey import Gooey
  47. @Gooey <--- all it takes! :)
  48. def main():
  49. # rest of code
  50. Different styling and functionality can be configured by passing arguments into the decorator.
  51. # options
  52. @Gooey(advanced=Boolean, # toggle whether to show advanced config or not
  53. language=language_string, # Translations configurable via json
  54. config=Boolean, # skip config screens all together
  55. program_name='name', # Defaults to script name
  56. program_description # Defaults to ArgParse Description
  57. )
  58. def main():
  59. # rest of app
  60. See: [How does it Work](#how-does-it-work) section for details on each option.
  61. What is it?
  62. -----------
  63. 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.
  64. Why?
  65. ---
  66. Because as much as we love the command prompt, the rest of the world looks at it like some kind of 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!
  67. Who is this for?
  68. ----------------
  69. If you're building utilities for yourself, other programmers, or something which produces a result that you want 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.
  70. How does it work?
  71. ------------------
  72. Gooey is attached to your code via a simple decorator on your `main` method.
  73. @Gooey <--- all it takes! :)
  74. def main():
  75. # rest of code
  76. At runtime, it loads the Abstract Syntax Tree for your module and parses it 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.
  77. ####Mappings:
  78. Currently, the `ArgumentParser._actions` are mapped to the following `WX` components.
  79. | Parser Action | Widget | Example |
  80. |:----------------------|-----------|------|
  81. | store | TextCtrl | <img src="https://raw.githubusercontent.com/chriskiehl/Gooey/master/resources/general_tb.png"/>|
  82. | store_const | CheckBox | <img src="https://raw.githubusercontent.com/chriskiehl/Gooey/master/resources/check_box.png"/>|
  83. | store_true| CheckBox | <img src="https://raw.githubusercontent.com/chriskiehl/Gooey/master/resources/check_box.png"/>|
  84. | store_False | CheckBox| <img src="https://raw.githubusercontent.com/chriskiehl/Gooey/master/resources/check_box.png"/> |
  85. | append | TextCtrl | <img src="https://raw.githubusercontent.com/chriskiehl/Gooey/master/resources/general_tb.png"/> |
  86. | 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"/> |
  87. |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"/> |
  88. -------------------------------------------
  89. Configuration
  90. ------------
  91. Gooey comes in three main flavors.
  92. - Full/Advanced
  93. - Basic
  94. - No config
  95. And each with the following options:
  96. | Parameter | Summary |
  97. |-----------|---------|
  98. | 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.|
  99. |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]`. |
  100. | program_description | Sets the text displayed in the top panel of the `Settings` screen. If `None` the decription is pulled from the `ArgumentParser`. |
  101. ###Advanced
  102. The default view is the "full" or "advanced" configuration screen. It can be toggled via the `advanced` parameter in the `Gooey` decorator.
  103. @gooey(advanced=True)
  104. def main():
  105. # rest of code
  106. 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.
  107. <p align="center">
  108. <img src="https://raw.githubusercontent.com/chriskiehl/Gooey/master/resources/advanced_config.png">
  109. </p>
  110. --------------------------------------------
  111. ###Basic
  112. 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`.
  113. @gooey(advanced=False)
  114. def main():
  115. # rest of code
  116. <p align="center">
  117. <img src="https://raw.githubusercontent.com/chriskiehl/Gooey/master/resources/basic_config.png">
  118. </p>
  119. ----------------------------------------------
  120. ###No Config
  121. 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 guy for classing up the delivery of little one-off scripts.
  122. <p align="center">
  123. <img src="https://raw.githubusercontent.com/chriskiehl/Gooey/master/resources/no_config.png">
  124. </p>
  125. ---------------------------------------
  126. Final Screen
  127. ------------
  128. <p align="center">
  129. <img src="https://raw.githubusercontent.com/chriskiehl/Gooey/master/resources/final_screen.png">
  130. </p>
  131. ----------------------------------------------
  132. TODO
  133. ----
  134. * Add to pypi
  135. * Themes
  136. * Add ability to customize the mapping between `Parser` actions and `wxComponents`. For instance, if your program had a file as a required argument, it'd be far more useful to the end user to supply a `wx.FileDialog` rather than a simple `TextBox`.
  137. * Update graphics
  138. * Optparse support?
  139. * Get OS X version working.
  140. Wanna help?
  141. -----------
  142. * Do you art? I'd love to swap out the graphics to something more stylistically unified.
  143. * Programmer? Pull requests are super welcome. The projects style is *fantastically* inconsistent, though. So be warned :) I tried to follow the WxWidgets style of Leading Capital methods and CamelCased variables, but.. Python habits die hard. So, there are underscores littered all over the place.
  144. [1]: http://i.imgur.com/7fKUvw9.png