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.

301 lines
11 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
9 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
9 years ago
10 years ago
9 years ago
10 years ago
9 years ago
10 years ago
9 years ago
9 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
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 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. - [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 drag and drop support
  30. - Added new widget packs: DateChooser, FileChooser, DirChooser
  31. - fixed several parsing related issues.
  32. - Gooey now has a sane setup.py (thanks to hero user LudoVio)
  33. - Gooey now builds from json for easy configurability
  34. - Side Note: This was done with big strides towards making Gooey language agnostic. Coming Soon!
  35. - Fixed GUI layout so that resizing works better
  36. **Planned Features:**
  37. - Language agnostic!
  38. - Stop/cancel button on run screen
  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. And run `setup.py`
  45. python setup.py install
  46. ###Usage
  47. Gooey is attached to your code via a simple decorator on your `main` method.
  48. from gooey import Gooey
  49. @Gooey <--- all it takes! :)
  50. def main():
  51. # rest of code
  52. Different styling and functionality can be configured by passing arguments into the decorator.
  53. # options
  54. @Gooey(advanced=Boolean, # toggle whether to show advanced config or not
  55. language=language_string, # Translations configurable via json
  56. config=Boolean, # skip config screens all together
  57. program_name='name', # Defaults to script name
  58. program_description # Defaults to ArgParse Description
  59. )
  60. def main():
  61. # rest of app
  62. See: [How does it Work](#how-does-it-work) section for details on each option.
  63. 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)
  64. from gooey import Gooey
  65. @Gooey <--- all it takes! :)
  66. def main():
  67. parser = GooeyParser(description="My Cool GUI Program!")
  68. parser.add_argument('Filename', widget="FileChooser")
  69. What is it?
  70. -----------
  71. 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.
  72. Why?
  73. ---
  74. 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!
  75. Who is this for?
  76. ----------------
  77. 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.
  78. How does it work?
  79. ------------------
  80. Gooey is attached to your code via a simple decorator on your `main` method.
  81. @Gooey <--- all it takes! :)
  82. def main():
  83. # rest of code
  84. 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.
  85. ####Mappings:
  86. Gooey does its best to choose sensible defaults based on the options it finds. Currently, `ArgumentParser._actions` are mapped to the following `WX` components.
  87. | Parser Action | Widget | Example |
  88. |:----------------------|-----------|------|
  89. | store | TextCtrl | <img src="https://raw.githubusercontent.com/chriskiehl/Gooey/master/resources/general_tb.png"/>|
  90. | store_const | CheckBox | <img src="https://raw.githubusercontent.com/chriskiehl/Gooey/master/resources/check_box.png"/>|
  91. | store_true| CheckBox | <img src="https://raw.githubusercontent.com/chriskiehl/Gooey/master/resources/check_box.png"/>|
  92. | store_False | CheckBox| <img src="https://raw.githubusercontent.com/chriskiehl/Gooey/master/resources/check_box.png"/> |
  93. | append | TextCtrl | <img src="https://raw.githubusercontent.com/chriskiehl/Gooey/master/resources/general_tb.png"/> |
  94. | 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"/> |
  95. | Mutually Exclusive Group | Radio Group | <img src="https://raw.githubusercontent.com/chriskiehl/Gooey/master/resources/radio_group.png"/>
  96. |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"/> |
  97. ###GooeyParser
  98. 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.
  99. **Example:**
  100. from argparse import ArgumentParser
  101. ....
  102. def main():
  103. parser = ArgumentParser(description="My Cool Gooey App!")
  104. parser.add_argument('filename', help="name of the file to process")
  105. Given then above, Gooey would select a normal `TextField` as the widget type like this:
  106. TEXTFIELD_DEMO.png
  107. However, by dropping in `GooeyParser` and supplying a `widget` name, you display a much more user friendly `FileChooser`
  108. from gooeyimport GooeyParser
  109. ....
  110. def main():
  111. parser = GooeyParser(description="My Cool Gooey App!")
  112. parser.add_argument('filename', help="name of the file to process", widget='FileChooser')
  113. **Custom Widgets:**
  114. | Widget | Example |
  115. |----------------|------------------------------|
  116. | FileChooser | img |
  117. | DirChooser | img |
  118. | DateChooser | |
  119. -------------------------------------------
  120. Configuration
  121. ------------
  122. Gooey comes in three main flavors.
  123. - Full/Advanced
  124. - Basic
  125. - No config
  126. Each has the following options:
  127. | Parameter | Summary |
  128. |-----------|---------|
  129. | 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.|
  130. |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]`. |
  131. | program_description | Sets the text displayed in the top panel of the `Settings` screen. If `None` the description is pulled from the `ArgumentParser`. |
  132. ###Advanced
  133. The default view is the "full" or "advanced" configuration screen. It can be toggled via the `advanced` parameter in the `Gooey` decorator.
  134. @gooey(advanced=True)
  135. def main():
  136. # rest of code
  137. 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.
  138. <p align="center">
  139. <img src="https://raw.githubusercontent.com/chriskiehl/Gooey/master/resources/advanced_config.png">
  140. </p>
  141. --------------------------------------------
  142. ###Basic
  143. 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`.
  144. @gooey(advanced=False)
  145. def main():
  146. # rest of code
  147. <p align="center">
  148. <img src="https://raw.githubusercontent.com/chriskiehl/Gooey/master/resources/basic_config.png">
  149. </p>
  150. ----------------------------------------------
  151. ###No Config
  152. 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.
  153. <p align="center">
  154. <img src="https://raw.githubusercontent.com/chriskiehl/Gooey/master/resources/no_config.png">
  155. </p>
  156. ---------------------------------------
  157. Final Screen
  158. ------------
  159. <p align="center">
  160. <img src="https://raw.githubusercontent.com/chriskiehl/Gooey/master/resources/final_screen.png">
  161. </p>
  162. ----------------------------------------------
  163. TODO
  164. ----
  165. * Add to pypi
  166. * Themes
  167. * 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`.
  168. * Update graphics
  169. * Optparse support?
  170. * Get OS X version working.
  171. Wanna help?
  172. -----------
  173. * Do you art? I'd love to swap out the graphics to something more stylistically unified.
  174. * 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.
  175. [1]: http://i.imgur.com/7fKUvw9.png