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.
chriskiehl 0ce9085831 Fixed program_name not working (issue #88). Corrected default name to pull from sys.argv 9 years ago
gooey Fixed program_name not working (issue #88). Corrected default name to pull from sys.argv 9 years ago
resources Updated README 10 years ago
.gitignore clean the project directory 10 years ago
LICENSE.txt last big push before packaging 10 years ago
MANIFEST.in clean the project directory 10 years ago
README.md updated README.md 9 years ago
TODO.md todo extended 10 years ago
gooey_config.json Version bump 9 years ago
pip_deploy.py Added deploy tools 9 years ago
setup.py Added deploy tools 9 years ago

README.md

Gooey (Beta)

Turn (almost) any Python Console Program into a GUI application with one line

Table of Contents


###Artist Wanted!

Want to contribute to Gooey? We need icons/logos!

Drop me an email if you want to help out!


##Quick Start

###Installation instructions

The easiest way to install Gooey is via pip

pip install Gooey 

Alternatively, you can install Gooey by cloning the project to your local directory

git clone https://github.com/chriskiehl/Gooey.git

run setup.py

python setup.py install

###Usage

Gooey is attached to your code via a simple decorator on whichever method has your argparse declarations (usually main).

from gooey import Gooey

@Gooey      <--- all it takes! :)
def main():
  parser = ArgumentParser(...)
  # 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
       show_config=True,          # skip config screens all together
       program_name='name',       # Defaults to script name
       program_description,       # Defaults to ArgParse Description
       default_size=(610, 530),   # starting size of the GUI
       required_cols=1,           # number of columns in the "Required" section
       optional_cols=2,           # number of columbs in the "Optional" section
       dump_build_config=False)   # Dump the JSON Gooey uses to configure itself
)
def main():
  parser = ArgumentParser(...)
  # rest of code

See: How does it Work section for details on each option.

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

from gooey import Gooey, GooeyParser

@Gooey
def main():
  parser = GooeyParser(description="My Cool GUI Program!") 
  parser.add_argument('Filename', widget="FileChooser")
  parser.add_argument('Date', widget="DateChooser")
  ...

What is it?

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.

Why?

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!

Who is this for?

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.

How does it work?

Gooey is attached to your code via a simple decorator on whichever method has your argparse declarations.

@Gooey
def my_run_func():
  parser = ArgumentParser(...)
  # rest of code

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.

####Mappings:

Gooey does its best to choose sensible defaults based on the options it finds. Currently, ArgumentParser._actions are mapped to the following WX components.

Parser Action Widget Example
store TextCtrl
store_const CheckBox
store_true CheckBox
store_False CheckBox
append TextCtrl
count DropDown                 
Mutually Exclusive Group RadioGroup
choice                                              DropDown

###GooeyParser

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.

Example:

from argparse import ArgumentParser
....

def main(): 
    parser = ArgumentParser(description="My Cool Gooey App!")
    parser.add_argument('filename', help="name of the file to process") 

Given then above, Gooey would select a normal TextField as the widget type like this:

However, by dropping in GooeyParser and supplying a widget name, you can display a much more user friendly FileChooser

from gooey import GooeyParser
....

def main(): 
    parser = GooeyParser(description="My Cool Gooey App!")
    parser.add_argument('filename', help="name of the file to process", widget='FileChooser') 

Custom Widgets:

Widget Example
Directory/FileChooser

DateChooser                                             


Configuration

Gooey comes in three main flavors.

  • Full/Advanced
  • Basic
  • No config

Each has the following options:

Parameter Summary
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 description is pulled from the ArgumentParser.

###Advanced

The default view is the "full" or "advanced" configuration screen. It can be toggled via the advanced parameter in the Gooey decorator.

@gooey(advanced=True)
def main():
    # rest of code   

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.


###Basic

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():
    # rest of code  


###No Config

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.


Final Screen


###Change Log

  • Removed parsing code, replaced it with @SylvainDe patch
  • Fixed issue #87
  • Fixed issue #85
  • Argparse no longer required to me in main (issue 84)
  • Drag and Drop support (Issue #28)

Tada!

  • Added drag and drop support
  • Added new widget packs: DateChooser, FileChooser, DirChooser
  • fixed several parsing related issues.
  • Gooey now has a sane setup.py (thanks to hero user LudoVio)
  • Gooey now builds from json for easy configurability
    • Side Note: This was done with big strides towards making Gooey language agnostic. Coming Soon!
  • Fixed GUI layout so that resizing works better

###Planned Features:

  • Language agnostic!
  • Stop/cancel button on run screen

TODO

  • Add to pypi
  • Update graphics
  • Get OS X version working.

Wanna help?

Code, translation, graphics? Pull requests are welcome.