Browse Source

Updated Documentation

pull/1/head
chriskiehl 10 years ago
parent
commit
494ba52705
3 changed files with 58 additions and 28 deletions
  1. 80
      README.md
  2. 4
      gooey/mockapplications/example_argparse_souce_in_try.py
  3. 2
      gooey/mockapplications/mockapp.py

80
README.md

@ -3,7 +3,7 @@ Gooey (Beta)
Turn (almost) any Console Program into a GUI application with one line
<p align="center">
<img src="http://i.imgur.com/T3XUPAy.png"/>
<img src="http://i.imgur.com/r6KOyKx.png"/>
</p>
@ -13,6 +13,9 @@ Table of Contents
- [Gooey](#gooey)
- [Table of contents](#table-of-contents)
- [Quick Start](#quick-start)
- [Installation Instructions](#installation-instructions)
- [Usage](#usage)
- [What It Is](#what-is-it)
- [Why Is It](#why)
- [Who is this for](#who-is-this-for)
@ -22,13 +25,42 @@ Table of Contents
- [Basic](#basic)
- [No Config](#no-config)
- [Final Screen](#final-screen)
- [Installation Instructions](#installation-instructions)
- [TODO](#todo)
- [Contributing](#wanna-help)
- [Image Credits](#image-credits)
Quick Start
-------------
###Installation instructions
To install Gooey, simply clone the project to your local directory
git clone https://github.com/chriskiehl/Gooey.git
###Usage
Gooey is attached to your code via a simple decorator on your `main` method.
@gooey <--- all it takes! :)
def main():
# rest of code
Different styling and functionality can be configured by passing arguments into the decorator.
# options
@Gooey(advanced=Boolean, # toggle whether to show advanced config or not
language=language_string, # Translations configurable via json
config=Boolean, # skip config screens all together
program_name='name', # Defaults to script name
program_description # Defaults to ArgParse Description
)
def main():
# rest of app
See: [How does it Work](#how-does-it-work) section for details on each option.
What is it?
@ -39,12 +71,12 @@ Gooey converts your Console Applications into end-user friendly GUI applications
Why?
---
Because as much as we love the command prompt, the rest of the world looks at it like some ugly relic from the '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!
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!
Who is this for?
----------------
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. common *nix style 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'll be used by 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.
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.
How does it work?
------------------
@ -57,17 +89,20 @@ Gooey is attached to your code via a simple decorator on your `main` method.
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.
####Mappings:
Currently, the `ArgumentParser._actions` are mapped to the following `WX` components.
| Parser Action | WxWidget |
| Parser Action | Widget | Example |
|:----------------------|-----------|
| store | TextCtrl |
| store_const | CheckBox |
| store_true| CheckBox |
| store_False | CheckBox|
| append | TextCtrl |
| count| DropDown|
|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 |
| store | TextCtrl | <img src="http://i.imgur.com/isFGFg8.png"/>|
| store_const | CheckBox | <img src="http://i.imgur.com/epHu2Vg.png"/>|
| store_true| CheckBox | <img src="http://i.imgur.com/epHu2Vg.png"/>|
| store_False | CheckBox| <img src="http://i.imgur.com/epHu2Vg.png"/> |
| append | TextCtrl | <img src="http://i.imgur.com/isFGFg8.png"/> |
| count| DropDown &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | <img src="http://i.imgur.com/E7bCeC4.png"/> |
|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="http://i.imgur.com/rGmhcER.png"/> |
-------------------------------------------
@ -75,7 +110,8 @@ Currently, the `ArgumentParser._actions` are mapped to the following `WX` compon
###Configuration
Configuration
------------
Gooey comes in three main flavors.
@ -88,7 +124,7 @@ And each with the following options:
| Parameter | Summary |
|-----------|---------|
| language | Gooey is (kind of) international ready. All program text is stored in an external `json` file. Translating to your host language only requires filling in the key/value pairs.|
| 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.|
|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]`. |
| program_description | Sets the text displayed in the top panel of the `Settings` screen. If `None` the decription is pulled from the `ArgumentParser`. |
@ -99,7 +135,7 @@ And each with the following options:
###Advanced
The default view is the "full" or "advanced" configuration screen, and is toggled via the `advanced` parameter in the `Gooey` decorator.
The default view is the "full" or "advanced" configuration screen. It can be toggled via the `advanced` parameter in the `Gooey` decorator.
@ -120,7 +156,7 @@ This view presents each action in the `Argument Parser` as a unique GUI componen
###Basic
The basic view is best for times when the user is familiar with Console Applications, or the options are very simple, 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`.
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`.
@gooey(advanced=False)
def main():
@ -152,12 +188,7 @@ Final Screen
----------------------------------------------
Installation instructions
------------------------
To install Gooey, simply clone the project to your local directory
git clone https://github.com/chriskiehl/Gooey.git
@ -167,22 +198,19 @@ TODO
* Add to pypi
* Themes
* 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`.
* update graphics
* robustify parser
* Update graphics
* Optparse support?
* Get OS X version working.
Wanna help?
-----------
* Do you art? I'd love to swap out the graphics to something more stylistically unified.
* 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.
Image Credits
-------------
[1]: http://i.imgur.com/7fKUvw9.png

4
gooey/mockapplications/example_argparse_souce_in_try.py

@ -89,8 +89,8 @@ USAGE
parser.add_argument("-v", "--verbose", dest="verbose", action="count",
help="set verbosity level [default: %(default)s]")
parser.add_argument("-i", "--include", action="append",
help="only include paths matching this regex pattern. Note: exclude is given preference over include. [default: %(default)s]",
parser.add_argument("-i", "--include", action="append", nargs='+',
help="only include paths matching this regex pattern. Note: exclude is given preference over include. ",
metavar="RE")
parser.add_argument("-m", "--mycoolargument", help="mycoolargument")

2
gooey/mockapplications/mockapp.py

@ -20,9 +20,11 @@ def main():
my_cool_parser.add_argument('-c', '--countdown', default=10, type=int, help='sets the time to count down from')
my_cool_parser.add_argument("-s", "--showtime", action="store_true", help="display the countdown timer")
my_cool_parser.add_argument("-d", "--delay", action="store_true", help="Delay execution for a bit")
my_cool_parser.add_argument('--verbose', '-v', action='count')
my_cool_parser.add_argument("-o", "--obfuscate", action="store_true", help="obfuscate the countdown timer!")
my_cool_parser.add_argument('-r', '--recursive', choices=['yes', 'no'], help='Recurse into subfolders')
my_cool_parser.add_argument("-w", "--writelog", default="No, NOT whatevs", help="write log to some file or something")
my_cool_parser.add_argument("-e", "--expandAll", action="store_true", help="expand all processes")
print 'inside of main(), my_cool_parser =', my_cool_parser
args = my_cool_parser.parse_args()

Loading…
Cancel
Save