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.

219 lines
8.5 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
  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/readme_images/primary.png"/>
  6. </p>
  7. Table of Contents
  8. -----------------
  9. - [Gooey](#gooey)
  10. - [Table of contents](#table-of-contents)
  11. - [Quick Start](#quick-start)
  12. - [Installation Instructions](#installation-instructions)
  13. - [Usage](#usage)
  14. - [What It Is](#what-is-it)
  15. - [Why Is It](#why)
  16. - [Who is this for](#who-is-this-for)
  17. - [How does it work](#how-does-it-work)
  18. - [Configuration](#configuration)
  19. - [Full/Advanced](#advanced)
  20. - [Basic](#basic)
  21. - [No Config](#no-config)
  22. - [Final Screen](#final-screen)
  23. - [TODO](#todo)
  24. - [Contributing](#wanna-help)
  25. - [Image Credits](#image-credits)
  26. Quick Start
  27. -------------
  28. ###Installation instructions
  29. To install Gooey, simply clone the project to your local directory
  30. git clone https://github.com/chriskiehl/Gooey.git
  31. ###Usage
  32. Gooey is attached to your code via a simple decorator on your `main` method.
  33. from gooey import Gooey
  34. @Gooey <--- all it takes! :)
  35. def main():
  36. # rest of code
  37. Different styling and functionality can be configured by passing arguments into the decorator.
  38. # options
  39. @Gooey(advanced=Boolean, # toggle whether to show advanced config or not
  40. language=language_string, # Translations configurable via json
  41. config=Boolean, # skip config screens all together
  42. program_name='name', # Defaults to script name
  43. program_description # Defaults to ArgParse Description
  44. )
  45. def main():
  46. # rest of app
  47. See: [How does it Work](#how-does-it-work) section for details on each option.
  48. What is it?
  49. -----------
  50. 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.
  51. Why?
  52. ---
  53. 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!
  54. Who is this for?
  55. ----------------
  56. 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.
  57. How does it work?
  58. ------------------
  59. Gooey is attached to your code via a simple decorator on your `main` method.
  60. @gooey <--- all it takes! :)
  61. def main():
  62. # rest of code
  63. 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.
  64. ####Mappings:
  65. Currently, the `ArgumentParser._actions` are mapped to the following `WX` components.
  66. | Parser Action | Widget | Example |
  67. |:----------------------|-----------|------|
  68. | store | TextCtrl | <img src="https://raw.githubusercontent.com/chriskiehl/Gooey/master/readme_images/general_tb.png"/>|
  69. | store_const | CheckBox | <img src="https://raw.githubusercontent.com/chriskiehl/Gooey/master/readme_images/check_box.png"/>|
  70. | store_true| CheckBox | <img src="https://raw.githubusercontent.com/chriskiehl/Gooey/master/readme_images/check_box.png"/>|
  71. | store_False | CheckBox| <img src="https://raw.githubusercontent.com/chriskiehl/Gooey/master/readme_images/check_box.png"/> |
  72. | append | TextCtrl | <img src="https://raw.githubusercontent.com/chriskiehl/Gooey/master/readme_images/general_tb.png"/> |
  73. | 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/readme_images/count_dropdown.png"/> |
  74. |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/readme_images/options_dropdown.png"/> |
  75. -------------------------------------------
  76. Configuration
  77. ------------
  78. Gooey comes in three main flavors.
  79. - Full/Advanced
  80. - Basic
  81. - No config
  82. And each with the following options:
  83. | Parameter | Summary |
  84. |-----------|---------|
  85. | 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.|
  86. |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]`. |
  87. | program_description | Sets the text displayed in the top panel of the `Settings` screen. If `None` the decription is pulled from the `ArgumentParser`. |
  88. ###Advanced
  89. The default view is the "full" or "advanced" configuration screen. It can be toggled via the `advanced` parameter in the `Gooey` decorator.
  90. @gooey(advanced=True)
  91. def main():
  92. # rest of code
  93. 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.
  94. <p align="center">
  95. <img src="https://raw.githubusercontent.com/chriskiehl/Gooey/master/readme_images/advanced_config.png">
  96. </p>
  97. --------------------------------------------
  98. ###Basic
  99. 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`.
  100. @gooey(advanced=False)
  101. def main():
  102. # rest of code
  103. <p align="center">
  104. <img src="https://raw.githubusercontent.com/chriskiehl/Gooey/master/readme_images/basic_config.png">
  105. </p>
  106. ----------------------------------------------
  107. ###No Config
  108. 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.
  109. <p align="center">
  110. <img src="https://raw.githubusercontent.com/chriskiehl/Gooey/master/readme_images/no_config.png">
  111. </p>
  112. ---------------------------------------
  113. Final Screen
  114. ------------
  115. <p align="center">
  116. <img src="https://raw.githubusercontent.com/chriskiehl/Gooey/master/readme_images/final_screen.png">
  117. </p>
  118. ----------------------------------------------
  119. TODO
  120. ----
  121. * Add to pypi
  122. * Themes
  123. * 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`.
  124. * Update graphics
  125. * Optparse support?
  126. * Get OS X version working.
  127. Wanna help?
  128. -----------
  129. * Do you art? I'd love to swap out the graphics to something more stylistically unified.
  130. * 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.
  131. [1]: http://i.imgur.com/7fKUvw9.png