Turn (almost) any Python command line program into a full GUI application with one line

Overview

Gooey

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

Support this project

Table of Contents


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

NOTE: Python 2 users must manually install WxPython! Unfortunately, this cannot be done as part of the pip installation and should be manually downloaded from the wxPython website.

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
       auto_start=True,           # skip config screens all together
       target=executable_cmd,     # Explicitly set the subprocess executable arguments
       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 columns in the "Optional" section
       dump_build_config=False,   # Dump the JSON Gooey uses to configure itself
       load_build_config=None,    # Loads a JSON Gooey-generated configuration
       monospace_display=False)   # Uses a mono-spaced font in the output screen
)
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")
  ...

Examples

Gooey downloaded and installed? Great! Wanna see it in action? Head over the the Examples Repository to download a few ready-to-go example scripts. They'll give you a quick tour of all Gooey's various layouts, widgets, and features.

Direct Download

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
version 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
DirChooser, FileChooser, MultiFileChooser, FileSaver, MultiFileSaver

DateChooser/TimeChooser                                             

Please note that for both of these widgets the values passed to the application will always be in ISO format while localized values may appear in some parts of the GUI depending on end-user settings.

PasswordField

Listbox image
BlockCheckbox image
The default InlineCheck box can look less than ideal if a large help text block is present. BlockCheckbox moves the text block to the normal position and provides a short-form block_label for display next to the control. Use gooey_options.checkbox_label to control the label text
ColourChooser                                             

FilterableDropdown

IntegerField

DecimalField

Slider

Internationalization

Gooey is international ready and easily ported to your host language. Languages are controlled via an argument to the Gooey decorator.

@Gooey(language='russian')
def main(): 
    ... 

All program text is stored externally in json files. So adding new language support is as easy as pasting a few key/value pairs in the gooey/languages/ directory.

Thanks to some awesome contributers, Gooey currently comes pre-stocked with over 18 different translations!

Want to add another one? Submit a pull request!


Global Configuration

Just about everything in Gooey's overall look and feel can be customized by passing arguments to the decorator.

Parameter Summary
encoding Text encoding to use when displaying characters (default: 'utf-8')
use_legacy_titles Rewrites the default argparse group name from "Positional" to "Required". This is primarily for retaining backward compatibility with previous versions of Gooey (which had poor support/awareness of groups and did its own naive bucketing of arguments).
advanced Toggles whether to show the 'full' configuration screen, or a simplified version
auto_start Skips the configuration all together and runs the program immediately
language Tells Gooey which language set to load from the gooey/languages directory.
target Tells Gooey how to re-invoke itself. By default Gooey will find python, but this allows you to specify the program (and arguments if supplied).
suppress_gooey_flag Should be set when using a custom target. Prevent Gooey from injecting additional CLI params
program_name The name displayed in the title bar of the GUI window. If not supplied, the title defaults to the script name pulled from sys.argv[0].
program_description Sets the text displayed in the top panel of the Settings screen. Defaults to the description pulled from ArgumentParser.
default_size Initial size of the window
fullscreen start Gooey in fullscreen mode
required_cols Controls how many columns are in the Required Arguments section
⚠️ Deprecation notice: See Group Parameters for modern layout controls
optional_cols Controls how many columns are in the Optional Arguments section
⚠️ Deprecation notice: See Group Parameters for modern layout controls
dump_build_config Saves a json copy of its build configuration on disk for reuse/editing
load_build_config Loads a json copy of its build configuration from disk
monospace_display Uses a mono-spaced font in the output screen
⚠️ Deprecation notice: See Group Parameters for modern font configuration
image_dir Path to the directory in which Gooey should look for custom images/icons
language_dir Path to the directory in which Gooey should look for custom languages files
disable_stop_button Disable the Stop button when running
show_stop_warning Displays a warning modal before allowing the user to force termination of your program
force_stop_is_error Toggles whether an early termination by the shows the success or error screen
show_success_modal Toggles whether or not to show a summary modal after a successful run
show_failure_modal Toggles whether or not to show a summary modal on failure
show_restart_button Toggles whether or not to show the restart button at the end of execution
run_validators Controls whether or not to have Gooey perform validation before calling your program
poll_external_updates (Experimental!) When True, Gooey will call your code with a gooey-seed-ui CLI argument and use the response to fill out dynamic values in the UI (See: Using Dynamic Values)
use_cmd_args Substitute any command line arguments provided at run time for the default values specified in the Gooey configuration
return_to_config When True, Gooey will return to the configuration settings window upon successful run
progress_regex A text regex used to pattern match runtime progress information. See: Showing Progress for a detailed how-to
progress_expr A python expression applied to any matches found via the progress_regex. See: Showing Progress for a detailed how-to
hide_progress_msg Option to hide textual progress updates which match the progress_regex. See: Showing Progress for a detailed how-to
disable_progress_bar_animation Disable the progress bar
timing_options This contains the options for displaying time remaining and elapsed time, to be used with progress_regex and progress_expr. Elapsed / Remaining Time. Contained as a dictionary with the options show_time_remaining and hide_time_remaining_on_complete. Eg: timing_options={'show_time_remaining':True,'hide_time_remaining_on_complete':True}
show_time_remaining Disable the time remaining text see Elapsed / Remaining Time
hide_time_remaining_on_complete Hide time remaining on complete screen see Elapsed / Remaining Time
requires_shell Controls whether or not the shell argument is used when invoking your program. More info here
navigation Sets the "navigation" style of Gooey's top level window.
Options:
TABBED SIDEBAR
sidebar_title Controls the heading title above the SideBar's navigation pane. Defaults to: "Actions"
show_sidebar Show/Hide the sidebar in when navigation mode == SIDEBAR
body_bg_color HEX value of the main Gooey window
header_bg_color HEX value of the header background
header_height height in pixels of the header
header_show_title Show/Hide the header title
header_show_subtitle Show/Hide the header subtitle
footer_bg_color HEX value of the Footer background
sidebar_bg_color HEX value of the Sidebar's background
terminal_panel_color HEX value of the terminal's panel
terminal_font_color HEX value of the font displayed in Gooey's terminal
terminal_font_family Name of the Font Family to use in the terminal
terminal_font_weight Weight of the font (constants.FONTWEIGHT_NORMAL, constants.FONTWEIGHT_XXX)
terminal_font_size Point size of the font displayed in the terminal
error_color HEX value of the text displayed when a validation error occurs
richtext_controls Switch on/off the console support for terminal control sequences (limited support for font weight and color). Defaults to : False. See docs for additional details
menus Show custom menu groups and items (see: Menus
clear_before_run When true, previous output will be cleared from the terminal when running program again

Layout Customization

You can achieve fairly flexible layouts with Gooey by using a few simple customizations.

At the highest level, you have several overall layout options controllable via various arguments to the Gooey decorator.

show_sidebar=True show_sidebar=False navigation='TABBED' tabbed_groups=True

Grouping Inputs

By default, if you're using Argparse with Gooey, your inputs will be split into two buckets: positional and optional. However, these aren't always the most descriptive groups to present to your user. You can arbitrarily bucket inputs into logic groups and customize the layout of each.

With argparse this is done via add_argument_group()

parser = ArgumentParser()
search_group = parser.add_argument_group(
    "Search Options", 
    "Customize the search options"
)

You can add arguments to the group as normal

search_group.add_argument(
    '--query', 
    help='Base search string'
) 

Which will display them as part of the group within the UI.

Run Modes

Gooey has a handful of presentation modes so you can tailor its layout to your content type and user's level or experience.

Advanced

The default view is the "full" or "advanced" configuration screen. It has two different layouts depending on the type of command line interface it's wrapping. For most applications, the flat layout will be the one to go with, as its layout matches best to the familiar CLI schema of a primary command followed by many options (e.g. Curl, FFMPEG).

On the other side is the Column Layout. This one is best suited for CLIs that have multiple paths or are made up of multiple little tools each with their own arguments and options (think: git). It displays the primary paths along the left column, and their corresponding arguments in the right. This is a great way to package a lot of varied functionality into a single app.

Both views present each action in the Argument Parser as a unique GUI component. It makes it 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.

Setting the layout style:

Currently, the layouts can't be explicitly specified via a parameter (on the TODO!). The layouts are built depending on whether or not there are subparsers used in your code base. So, if you want to trigger the Column Layout, you'll need to add a subparser to your argparse code.

It can be toggled via the advanced parameter in the Gooey decorator.

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

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.


Menus

image

Added 1.0.2

You can add a Menu Bar to the top of Gooey with customized menu groups and items.

Menus are specified on the main @Gooey decorator as a list of maps.

@Gooey(menu=[{}, {}, ...])

Each map is made up of two key/value pairs

  1. name - the name for this menu group
  2. items - the individual menu items within this group

You can have as many menu groups as you want. They're passed as a list to the menu argument on the @Gooey decorator.

@Gooey(menu=[{'name': 'File', 'items: []},
             {'name': 'Tools', 'items': []},
             {'name': 'Help', 'items': []}])

Individual menu items in a group are also just maps of key / value pairs. Their exact key set varies based on their type, but two keys will always be present:

  • type - this controls the behavior that will be attached to the menu item as well as the keys it needs specified
  • menuTitle - the name for this MenuItem

Currently, three types of menu options are supported:

  • AboutDialog
  • MessageDialog
  • Link

About Dialog is your run-of-the-mill About Dialog. It displays program information such as name, version, and license info in a standard native AboutBox.

Schema

  • name - (optional)
  • description - (optional)
  • version - (optional)
  • copyright - (optional)
  • license - (optional)
  • website - (optional)
  • developer - (optional)

Example:

{
    'type': 'AboutDialog',
    'menuTitle': 'About',
    'name': 'Gooey Layout Demo',
    'description': 'An example of Gooey\'s layout flexibility',
    'version': '1.2.1',
    'copyright': '2018',
    'website': 'https://github.com/chriskiehl/Gooey',
    'developer': 'http://chriskiehl.com/',
    'license': 'MIT'
}

MessageDialog is a generic informational dialog box. You can display anything from small alerts, to long-form informational text to the user.

Schema:

  • message - (required) the text to display in the body of the modal
  • caption - (optional) the caption in the title bar of the modal

Example:

{
    'type': 'MessageDialog',
    'menuTitle': 'Information',
    'message': 'Hey, here is some cool info for ya!',
    'caption': 'Stuff you should know'
}

Link is for sending the user to an external website. This will spawn their default browser at the URL you specify.

Schema:

  • url - (required) - the fully qualified URL to visit

Example:

{
    'type': 'Link',
    'menuTitle': 'Visit Out Site',
    'url': 'http://www.example.com'
}

A full example:

Two menu groups ("File" and "Help") with four menu items between them.

@Gooey(
    program_name='Advanced Layout Groups',
    menu=[{
        'name': 'File',
        'items': [{
                'type': 'AboutDialog',
                'menuTitle': 'About',
                'name': 'Gooey Layout Demo',
                'description': 'An example of Gooey\'s layout flexibility',
                'version': '1.2.1',
                'copyright': '2018',
                'website': 'https://github.com/chriskiehl/Gooey',
                'developer': 'http://chriskiehl.com/',
                'license': 'MIT'
            }, {
                'type': 'MessageDialog',
                'menuTitle': 'Information',
                'caption': 'My Message',
                'message': 'I am demoing an informational dialog!'
            }, {
                'type': 'Link',
                'menuTitle': 'Visit Our Site',
                'url': 'https://github.com/chriskiehl/Gooey'
            }]
        },{
        'name': 'Help',
        'items': [{
            'type': 'Link',
            'menuTitle': 'Documentation',
            'url': 'https://www.readthedocs.com/foo'
        }]
    }]
)

Input Validation

⚠️ Note! This functionality is experimental. Its API may be changed or removed altogether. Feedback/thoughts on this feature is welcome and encouraged!

Gooey can optionally do some basic pre-flight validation on user input. Internally, it uses these validator functions to check for the presence of required arguments. However, by using GooeyParser, you can extend these functions with your own validation rules. This allows Gooey to show much, much more user friendly feedback before it hands control off to your program.

Writing a validator:

Validators are specified as part of the gooey_options map available to GooeyParser. It's a simple map structure made up of a root key named validator and two internal pairs:

  • test The inner body of the validation test you wish to perform
  • message the error message that should display given a validation failure

e.g.

gooey_options={
    'validator':{
        'test': 'len(user_input) > 3',
        'message': 'some helpful message'
    }
}

The test function

Your test function can be made up of any valid Python expression. It receives the variable user_input as an argument against which to perform its validation. Note that all values coming from Gooey are in the form of a string, so you'll have to cast as needed in order to perform your validation.

Full Code Example

from gooey.python_bindings.gooey_decorator import Gooey
from gooey.python_bindings.gooey_parser import GooeyParser

@Gooey
def main():
    parser = GooeyParser(description='Example validator')
    parser.add_argument(
        'secret',
        metavar='Super Secret Number',
        help='A number specifically between 2 and 14',
        gooey_options={
            'validator': {
                'test': '2 <= int(user_input) <= 14',
                'message': 'Must be between 2 and 14'
            }
        })

    args = parser.parse_args()

    print("Cool! Your secret number is: ", args.secret)

With the validator in place, Gooey can present the error messages next to the relevant input field if any validators fail.


Using Dynamic Values

⚠️ Note! This functionality is experimental. Its API may be changed or removed altogether. Feedback on this feature is welcome and encouraged!

Gooey's Choice style fields (Dropdown, Listbox) can be fed a dynamic set of values at runtime by enabling the poll_external_updates option. This will cause Gooey to request updated values from your program every time the user visits the Configuration page. This can be used to, for instance, show the result of a previous execution on the config screen without requiring that the user restart the program.

How does it work?

At runtime, whenever the user hits the Configuration screen, Gooey will call your program with a single CLI argument: gooey-seed-ui. This is a request to your program for updated values for the UI. In response to this, on stdout, your program should return a JSON string mapping cli-inputs to a list of options.

For example, assuming a setup where you have a dropdown that lists user files:

 ...
 parser.add_argument(
        '--load',
        metavar='Load Previous Save',
        help='Load a Previous save file',
        dest='filename',
        widget='Dropdown',
        choices=list_savefiles(),
    )

Here the input we want to populate is --load. So, in response to the gooey-seed-ui request, you would return a JSON string with --load as the key, and a list of strings that you'd like to display to the user as the value. e.g.

{"--load": ["Filename_1.txt", "filename_2.txt", ..., "filename_n.txt]}

Checkout the full example code in the Examples Repository. Or checkout a larger example in the silly little tool that spawned this feature: SavingOverIt.


Showing Progress

Giving visual progress feedback with Gooey is easy! If you're already displaying textual progress updates, you can tell Gooey to hook into that existing output in order to power its Progress Bar.

For simple cases, output strings which resolve to a numeric representation of the completion percentage (e.g. Progress 83%) can be pattern matched and turned into a progress bar status with a simple regular expression (e.g. @Gooey(progress_regex=r"^progress: (\d+)%$")).

For more complicated outputs, you can pass in a custom evaluation expression (progress_expr) to transform regular expression matches as needed.

Output strings which satisfy the regular expression can be hidden from the console via the hide_progress_msg parameter (e.g. @Gooey(progress_regex=r"^progress: (\d+)%$", hide_progress_msg=True).

Regex and Processing Expression

@Gooey(progress_regex=r"^progress: (?P<current>\d+)/(?P<total>\d+)$",
       progress_expr="current / total * 100")

Program Output:

progress: 1/100
progress: 2/100
progress: 3/100
...

There are lots of options for telling Gooey about progress as your program is running. Checkout the Gooey Examples repository for more detailed usage and examples!

Elapsed / Remaining Time

Gooey also supports tracking elapsed / remaining time when progress is used! This is done in a similar manner to that of the project tqdm. This can be enabled with timing_options, the timing_options argument takes in a dictionary with the keys show_time_remaining and hide_time_remaining_on_complete. The default behavior is True for show_time_remaining and False for hide_time_remaining_on_complete. This will only work when progress_regex and progress_expr are used.

@Gooey(progress_regex=r"^progress: (?P<current>\d+)/(?P<total>\d+)$",
       progress_expr="current / total * 100",
       timing_options = {
        'show_time_remaining':True,
        'hide_time_remaining_on_complete':True,
    })

Elapsed/Remaining Time


Customizing Icons

Gooey comes with a set of six default icons. These can be overridden with your own custom images/icons by telling Gooey to search additional directories when initializing. This is done via the image_dir argument to the Gooey decorator.

@Gooey(program_name='Custom icon demo', image_dir='/path/to/my/image/directory')
def main():
    # rest of program

Images are discovered by Gooey based on their filenames. So, for example, in order to supply a custom configuration icon, simply place an image with the filename config_icon.png in your images directory. These are the filenames which can be overridden:

  • program_icon.png
  • success_icon.png
  • running_icon.png
  • loading_icon.gif
  • config_icon.png
  • error_icon.png

Packaging

Thanks to some awesome contributers, packaging Gooey as an executable is super easy.

The tl;dr pyinstaller version is to drop this build.spec into the root directory of your application. Edit its contents so that the application and name are relevant to your project, then execute pyinstaller build.spec to bundle your app into a ready-to-go executable.

Detailed step by step instructions can be found here.

Screenshots

Flat Layout Column Layout Success Screen Error Screen Warning Dialog
Custom Groups Tabbed Groups Tabbed Navigation Sidebar Navigation Input Validation

Wanna help?

Code, translation, documentation, or graphics? All pull requests are welcome. Just make sure to checkout the contributing guidelines first.

Issues
  • Python 3 compatibility

    Python 3 compatibility

    Hi, Gooey is a great idea, I was wondering is it possible to add Python 3 compatibility for this project?

    opened by akittas 43
  • Support Qt

    Support Qt

    Adding Qt support would greatly increase your userbase :-).

    wontfix 
    opened by dougthor42 24
  • Elapsed / Remaining Time Next to Progress Bar, closes #587

    Elapsed / Remaining Time Next to Progress Bar, closes #587

    Hello!

    This the pull request to go with recently raised https://github.com/chriskiehl/Gooey/issues/587.

    Changes are as follows:

    • New pub/sub event created for application in events.py for TIME_REMAINING_UPDATE.
    • StaticText label added in Footer adjacent to progress bar for displaying elapsed & remaining time.
    • Functions added to processor.py:
      • _get_current_time() either use time.perf_counter() in Python 3.3+ or timeit.default_timer() for Python 2.7 compatibility to get a current time in seconds as a float
      • _calculate_time_remaining(progress,start_time) estimate the time remaining by calculating the current rate of progress over elapsed time and extrapolate for the remainder of progress.
      • format_interval() This was taken from the tqdm project https://github.com/tqdm/tqdm/blob/0cd9448b2bc08125e74538a2aea6af42ee1a7b6f/tqdm/std.py#L228 for showing the elapsed & remaining time in [H]:MM:SS format.
    • _forward_stdout in processor.py has been altered to show time remaining when progress is greater than 0.
    • Relevant tests for all functions added can be found in test_processor.py.

    I absolutely love this package, thank you so much!

    This does not include a dependency of tqdm, as the functionality has been 'extracted'.

    Furthemore, I've created a working example to add to the examples repository as well! Which I have created a PR over at: https://github.com/chriskiehl/GooeyExamples/pull/31.

    fbHcpCAGD8

    Round 2 at pull request!

    opened by JackMcKew 16
  • fix for argopt / docopt

    fix for argopt / docopt

    Apparently didn't like the lambda. Fixes #4 (using argopt: https://pypi.python.org/pypi/argopt#usage or https://github.com/casperdcl/argopt#usage)

    opened by casperdcl 14
  • Terminal window jumps to top on job completion

    Terminal window jumps to top on job completion

    Is it possible to cause Gooey to keep the output window as-is on job completion? I don't want to jump back to the top of the output as what I am really interested in is at the bottom.

    opened by bje- 13
  • Crash after run with latest upgrade

    Crash after run with latest upgrade

    Hi,

    I installed gooey on a new machine. I also experienced the problem with the drop menus for the parameters. After upgrading a few minutes ago this was fix but now I got a crash end the main function ends:

    Pango:ERROR:/build/buildd/pango1.0-1.36.8/./pango/pango-layout.c:3916:pango_layout_check_lines: assertion failed: (!layout->log_attrs)

    The gooey window crashes completly before appearing the edit options. and then the system kills the process completly.

    Any idea?

    Thanks in advance, Sérgio

    opened by sousasag 12
  • Gooey with Click https://github.com/mitsuhiko/click ?

    Gooey with Click https://github.com/mitsuhiko/click ?

    How hard would it be to have Gooey work with Click https://github.com/mitsuhiko/click a popular CLI framework by @mitsuhiko maker of Flask among other super goodies?

    Note that Click uses neither argparse nor optparse but should provide introspection capabilities.

    opened by pombredanne 12
  • WX version compatibility for Gooey, Pip, Conda, and OS platforms

    WX version compatibility for Gooey, Pip, Conda, and OS platforms

    Placeholder for working out how best to structure Gooey's WX dep such that installs across different package managers, platforms, and OSs can all work (mostly) seamlessly, or at least have a useful escape hatch.

    Problems:

    Planned Solution:

    Gooey will loosen its grip on developing against a single known stable WX version, and work with a sliding window starting from 4.1.0 up to current 4.1.1 (and onward as relevant).

    opened by chriskiehl 11
  • [Feature request] Raise exception on Stop Task

    [Feature request] Raise exception on Stop Task

    I'm not sure if this is within the scope of the project, but would it be possible to raise an exception when the Stop button is clicked (much like you would have a KeyboardInterrupt when a user interrupts the program with Ctrl-C) so you can clean up?

    opened by fijam 11
  • RFC: Repo cleanup, py2/py3 compatibility

    RFC: Repo cleanup, py2/py3 compatibility

    This PR contains initial work towards a codebase simultaneously compatible with Python 2 and Python 3. Specifically, I used futurize to make the existing py2 codebase py3-compatible. I have split this into separate commits so that thematically separable changes can be reviewed separately.

    Note: If you want to review the changes without whitespace getting in the way, append ?w=1 to the relevant URL on Github to ignore whitespace changes, like this.

    Note: The changes in here also contain the changes from PR #129, as it was easier to include those changes in the line ending normalization.

    To start working with futurize, since I'm on Linux, I first had to normalize the line endings, otherwise all the files showed up as changed. This is because the repo contains CRLF (Windows-style) line endings, and no .gitattributes file to enable cross-platform line-ending compatibility. With the .gitattributes in place, this should now be transparent to all devs, without any special git settings, Windows users get CRLF endings on checkout, all the other get LF. (I already handled such a transition for a bigger project) This work is contained in commit 2216fa2.

    The next set of change is what future calls "stage 1", easy replacements with very low bug potential and no additional dependencies. cb1fc53 dfab1e6

    After those are the autogenerated stage 2 changes, which fix more incompatibilities, but add a dependency on the future package. A small amount of manual fixes, which the futurize heuristics didn't pick up, were also added. 342fe51 d5b9cbe

    FYI: I also have a branch with an initial set of pep8 fixes, but I have not included this here yet since I don't know how you folks feel about pep8. Also, as there is already a commit in here that touches _all the files, we might as well fix the style issues at the same time._

    I know that PR #120 is currently open, and not included in these changes. This is not ideal w.r.t the line ending normalization, but most of the changes in here happened with terminal commands, so it's easily replayable once that PR is merged (if it gets merged).

    All the tests pass, and all the examples that worked before, keep working with those changes. Tested only on py2, since there's no wxpython for py3 yet.

    On a TODO-list for this PR:

    • Fold in the pep8 changes if acceptable
    • (probably) set up a Travis-CI account to get started with at least some automated testing (pytest, plus maybe run some examples?).

    Ping @chriskiehl Relevant issue: #65

    opened by bilderbuchi 11
  • richtext_controls no working

    richtext_controls no working

    WX20211122-212433@2x

    OS:macOS 11.5.2 Python: 3.8.5 Gooey: 1.0.8.1

    opened by kuanghy 0
  • Gooey chooses single-select for option with choices and nargs='+' or '*'

    Gooey chooses single-select for option with choices and nargs='+' or '*'

    • OS: Windows 10/OSX
    • Python Version: 3.9.7
    • Gooey Version: 10.8.1
    • Thorough description of problem
      • Expected Behavior When an optional argument has nargs="+" or "*" and choices=list_of_choices, this means that several choices can be selected. I would expect either a multi-select or a way of repeating the whole widget (a + button that adds another instance of the argument or something)
      • Actual Behavior Any arg with choices seems to be given a single-select widget, and the text box treats everything as a single argument, preventing even manually passing multiple arguments.
    • A minimal code example -- preferably copy/pastable in the issue itself (less time figuring out how to run your code == more time debugging!)
    from gooey import Gooey, GooeyParser
    
    @Gooey
    def main():
       p = GooeyParser()
       p.add_argument('-e', '--example-arg', nargs='+', choices=["value", "other_value"])
       p.parse_args()
    
    main()
    
    opened by pobocks 0
  • Declaration order of ungrouped variables can cause misordering errors

    Declaration order of ungrouped variables can cause misordering errors

    Hello There, Future Issue Creator!

    README: Are you suddenly seeing errors related to Alignment flags when starting Gooey? Upgrade your gooey installation to the latest version (pip install -U gooey) to resolve the errors! See this issue for additional information.

    Found a bug? Just a friendly heads up, debugging it requires information from you! Make sure the template below is filled out in its entirety.

    • [x] OS: Windows 10 21H1
    • [x] Python Version: 3.7.6
    • [x] Gooey Version 1.0.8.1
    • [x] Thorough description of problem
      • Declaration of positional arguments after argument groups results in swapped inputs
      • [x] Expected Behavior: Variables defined in input boxes match variables parsed by argparse
      • [x] Actual Behavior: Variables get garbled and assigned to the wrong arguments
    • [x] A minimal code example -- preferably copy/pastable in the issue itself (less time figuring out how to run your code == more time debugging!)

    This works

    from gooey import GooeyParser, Gooey
    from pprint import pprint
    
    
    @Gooey
    def main():
     parser = GooeyParser(description="FFQ profile generation and auditing")
     parser.add_argument("hij", default="hij")
    
     g1 = parser.add_argument_group("g1", "Group 1")
     g2 = parser.add_argument_group("g2", "Group 2")
    
     g1.add_argument("abc", default="abc")
     g2.add_argument("def", default="def")
    
    
     args = parser.parse_args()
    
     pprint(vars(args))
    
    
    if __name__ == "__main__":
     main()
    

    But moving the parser.add_argument to after the grouped arguments doesnt

    from gooey import GooeyParser, Gooey
    from pprint import pprint
    
    
    @Gooey
    def main():
     parser = GooeyParser(description="FFQ profile generation and auditing")
    
     g1 = parser.add_argument_group("g1", "Group 1")
     g2 = parser.add_argument_group("g2", "Group 2")
    
     g1.add_argument("abc", default="abc")
     g2.add_argument("def", default="def")
     parser.add_argument("hij", default="hij")
    
     args = parser.parse_args()
    
     pprint(vars(args))
    
    
    if __name__ == "__main__":
     main()
    
    • [ ] Screenshot (if visual quirk)
    • [x] Anything else you may think will be helpful

    Suspicion is with some quirk of the CLIString generation. For the above program, in the case of parser.add_argument for the variable 'hij' preceding the groups, calling it with --ignore-gooey shows the following usage usage: test.py [-h] hij abc def The CLIString generated is as follows:

     ".\python.exe" -u "test.py" --ignore-gooey -- "hij" "abc" "def"
    

    Conversely, when hij is defined after the groups, usage becomes: usage: test.py [-h] abc def hij and the CLIstring is: ".\python.exe" -u "test.py" --ignore-gooey -- "hij" "abc" "def"

    Note the erroneous position of the variables resulting in said garbled output

    bug 
    opened by Klim314 1
  • MultiFileChooser/MultiDirChooser don't handle list default values correctly

    MultiFileChooser/MultiDirChooser don't handle list default values correctly

    • [x] OS : Windows 10
    • [x] Python Version : 3.9.6
    • [x] Gooey Version : 1.0.8.1
    • [x] Thorough description of problem
      • [x] Expected Behavior
      • [x] Actual Behavior

    This is a seperate issue to the one I previously raised (#756), but it also concerns the handling of list default/initial values.

    When paths are selected MultiFileChooser and MultiDirChooser, the selected paths are separated using the OS path separator in the input box. This concatenated string is split by formatter.multiFileChooser before being passed back to the client program, so the client program receives a list of paths. If a list of paths is used as a default value/initial value for the field, then I'd expect the inverse transformation to be applied: the paths should be joined by the OS path separator.

    At the moment, argparse_to_json.textinput_with_nargs_and_list_default only handles vanilla text inputs, and so the default list of paths is shown as a list in the input box. If the value isn't changed, it is passed back to the program as a singleton list with the only element being a stringified list of paths.

    • [x] A minimal code example -- preferably copy/pastable in the issue itself (less time figuring out how to run your code == more time debugging!)
    from gooey import Gooey, GooeyParser
    
    
    @Gooey
    def main():
        parser = GooeyParser(description='Test')
        parser.add_argument('multi_file_choice', nargs='+', default=['a.txt', 'b.txt'],
                            widget='MultiFileChooser')
        args = parser.parse_args()
        print(args.multi_file_choice)
    
    
    main()
    
    • [x] Screenshot (if visual quirk)

    image

    image

    opened by JozsefKutas 0
  • Issue 756 nargs initial values

    Issue 756 nargs initial values

    Closes #756. I've updated an existing test for default values to also check that initial values are handled correctly. The code example in the issue now works as expected.

    • [x] You're opening this PR against the current release branch
    • [x] Works on both Python 2.7 & Python 3.x
    • [x] Commits have been squashed and includes the relevant issue number
    • [x] Pull request description contains link to relevant issue or detailed notes on changes
    • [x] This must include example code demonstrating your feature or the bug being fixed
    • [x] All existing tests pass
    • [x] Your bug fix / feature has associated test coverage
    • [x] README.md is updated (if relevant)
    opened by JozsefKutas 2
  • Text inputs with nargs don't work properly with list initial values

    Text inputs with nargs don't work properly with list initial values

    • [x] OS : Windows 10
    • [x] Python Version : 3.9.6
    • [x] Gooey Version : 1.0.8.1
    • [x] Thorough description of problem
      • [x] Expected Behavior
      • [x] Actual Behavior

    List initial values for text inputs with nargs don't get caught by the argparse_to_json.textinput_with_nargs_and_list_default condition, and so aren't properly transformed. I would expect initial_values to be handled in the same way as default values.

    • [x] A minimal code example -- preferably copy/pastable in the issue itself (less time figuring out how to run your code == more time debugging!)
    import gooey
    from gooey import Gooey
    
    
    @Gooey
    def main():
        parser = gooey.GooeyParser(description='Sum some integers.')
        parser.add_argument('--integers', type=int, nargs='+', default=[2, 2])
        parser.add_argument('--integers2', type=int, nargs='+', gooey_options={'initial_value': [2, 2]})
        args = parser.parse_args()
        print(sum(args.integers) + sum(args.integers2))
    
    
    main()
    
    • [x] Screenshot (if visual quirk)

    image

    opened by JozsefKutas 0
  • RFC: Dynamic Updates and Validation

    RFC: Dynamic Updates and Validation

    Plans for an approach to unify both user-space validation and dynamic values behind the standard argparse interface.

    Problems with existing approaches:

    Dynamic Values" (i.e. loading additional data from into the config form dynamically)

    The current approach to Dynamic Values was quickly added to scratch an itch, and was super ill-thought out as a result.

    Problems:

    • Requires the user to specify data via an secondary code path entirely independent of their main argparse code
    • Requires the user to write code to handle the seed-gooey cli argument
    • Partial solution / implementation: only handles populating lists.

    Dynamic Validation:

    Currently there is no capability to offload validation to user code. All gooey validation is done via the validation gooey_options functionality, which exclusively runs independent of the user's code.

    Problems:

    • Validations are limited to a very restricted subset of what can be evaled in Python
    • Validations run in Gooey land, not in program land, thus putting a hard cap on how domain specific and useful they can be

    2.0 Features:

    Dynamic Updates 2.0 features:

    Validation:

    • validating the entire form in the client's code
    • validating individual fields 'as-you-go' via the client's code

    This will enable the much request ability to supply an arbitrary function to the parser in order to handle validation. Under the new dynamic values setup, we'll even be able to do it 'live' field-by-field as the user enters data!

    Lifecycle Hooks:

    • Seeding/modifying the UI in response to lifecycle events (onSuccess, onError)

    This will allow coarse grain UI control like clearing the current inputs as well as useful extra event for when you want to take some further action in response to the first run.

    Advanced Control (UI & Validation & Other):

    • low level events allowing client's code to control fine-grained UI states (i.e. enabled state, visibility, error state, current values, etc... forall form components)

    This is for people who want low-level control over the UI. The goal here is to enable absolute control over the state of Gooey's input form (which fields are visible, which are enabled, what data is shown, etc..).

    2.0 Design

    High level:

    • Current Dynamic Values API will be deprecated entirely
    • Piggyback all new dynamic features on the existing argparse API when possible, only falling back to GooeyParser when needed.

    image

    Details:

    Gooey will monkey patch the client code's to extent their existing CL interface. Must like the --ignore-gooey flag we already pass, Gooey will now pass additional flags along side the user's payload and use these to determine how to behave.

    New Events / Flags

    |Event|flag|dispatched| Client Handler| |-|-|-|-| |ValidateField | --gooey-validate-field [argId] [value]| onBlur per field| add_argument(..., type=handler)| |ValidateForm|--gooey-validate-form|Form onSubmit|all add_argument(..., type=handler)| |CompletedSuccessfully|--gooey-completed|After successful run|GooeyParser.on_success| |CompletedWithError|--gooey-error|After failed run|GooeyParser.on_failure| |Advanced Control: mutual exclusive with validate-x options | |CustomFieldAction|--gooey-field-action [argId] [ui-state]|onBlur per field|arg.gooey_options.on_update| |CustomFormAction|--gooey-validate-form [ui-state]|Form onSubmit|GooeyParser.onSubmit|

    New APIs:

    New Decorator argument

    Which events you want Gooey to send will be controlled via the Decorator. Tentative name: use_events. Alt: maybe... event_subscriptions..?

    @Gooey(use_events :: Array Event)
    

    Validation uses existing type argument

    Basic validation will all piggyback on Argparse's existing type functionality. Meaning, this vanilla argparse code will now dynamically verify that the user is supplying an int in the UI.

    parser.add_argument('-f', '--foo', type=int)
    

    Arbitrary functions are allowed, just like the regular argparse API.

    def my_bounded_int(x): 
      if x > 10 and x < 100:
        return x 
      else: 
        raise MyException('Must be between 10 and 100') 
    

    and are used in the type arg as usual:

    parser.add_argument('-f', '--foo', type=my_bounded_int)
    

    Any Exception type is allowed as long as it has a message property or useful __str__ method.

    New GooeyParser arguments

    parser = GooeyParser(
        # lifecycle handlers
        on_success :: Map ArgId FormData, 
        on_failure :: Map ArgId FormData, 
        # low-level form submit handler
        on_submit :: Map ArgId FormData, 
    )
    

    New gooey_option for low level control:

    parser.add_argument('-f', '--foo', gooey_options={
        'on_update' :: String -> Map ArgId FormData
    })
    

    This is for handling the low-level field action event.

    Internal Handling

    This is all powered by just monkey patching the hell out of parse_args even more than we already do. tl;dr: gooey passes extra CLI flags, which we detect at parse time, and act accordingly.

    Ugly rough sketch:

      
    ValidateField
    cli: gooey::positional-placeholder -f foo --validate-field f
    
    dispatch_on_flag() 
    ...
    lifted_args = parse_args
    if lifted_args.f.isLeft 
        print('gooey::validation{'-f': f.error_msg}')
    	sys.exit(233)
    	
    	
    ValidateForm 
    cli: gooey::positional-placeholder & args --validate-form
    
    dispatch_on_flag() 
    ...
    lifted_args = parser.parse_args()
    errors = collect_errors(lifted_args)
    if errors: 
        print(f'gooey::validation{errors}')
    	sys.exit(233)
    	
    
    CompletedSuccessfully & CompletedWithError 
    cli: --completed-successfully formStateAsJson
    
    ...
    # auto-magically added by GooeyParser 
    parser.add_argument('--gooey-completed-successfully', 
    	dest=gooey_form_state
    	type=parse_json)
    ...
    dispatch_on_flag() 
    ...
    lifted_args = parser.parse_args() 
    updates = parser.on_success(lifted_args.gooey_form_state))
    # or updates = parser.on_failure(lifted_args.gooey_form_state))
    print(f'gooey::update{updates}')
    
    
    
    
    CustomFieldAction
    cli: placeholders --gooey-custom-field-action field {formStateAsJson}
    
    parser.add_argument(
    	'--gooey-custom-field-action',
    	dest='gooey_field_value'
    	nargs=3,
    	type=str
    
    ...
    dispatch_on_flag() 
    ...
    name2arg = parser._mapping
    lifted_args = parser.parse_args() 
    (target, value, rawState) = lifted_args.gooey_field_value
    parsedUiState = parseUiState(rawState)
    update_fn = name2arg.get(target)
    updates = update_fn(value, parsedUiState)
    print(f'gooey::update{updates}')
    
    
    CustomFormAction
    cli: --gooey-form-action formStateAsJson
    
    parser.add_argument(
    	'--gooey-form-action',
    	nargs=1,
    	type=parse_json)
    
    ...
    lifted_args = parser.parse_args() 
    ui_state = lifted_args.gooey_form_action
    updates = parser.onSubmit(ui_state)
    print(f'gooey::update{updates}')
    
    1.0.9-release 
    opened by chriskiehl 3
  • Allow animated (.gif) icons

    Allow animated (.gif) icons

    Hey,

    I added support for animated (.gif) icons. https://github.com/chriskiehl/Gooey/issues/522

    The same name-based image search is occurring, but now if a .gif extension is found, the image is resized to fit the target dimension. All but the program_icon should now support animation. Resize performance might not be great for particularly large gifs, but seems appropriate for files I imagine would typically be used.

    There were a couple things I wouldn't mind a second opinion on.

    1. In order to resize the gif, I'm currently writing a temp file that just replaces the .gif with .___ I'm not sure if there is a better practice here. This should at least not exceed file path limits and it's unlikely a .___ file of the same name exists in the image folder. I did not see anything in wx that would do this directly.

    2. I'm not sure what type of tests would be best to write for this. Any similar test examples I could pull from in the current test suite.

    3. I added a valid_ext argument to the resolvePaths() function in order to ignore certain conflicts (program_icon.ico, program_icon.png). But I don't necessarily think this is the best approach, although that function is really only used in this one spot.

    4. I noticed some other changes present in the current 1.0.9 release branch don't work with python 2 (type hints, starred expressions). I didn't make the changes in this PR.

    5. I don't see the loading_icon used anywhere in the code, just referenced in the README. Perhaps we should drop that.

    Example:

    from gooey import GooeyParser, Gooey
    
    @Gooey(image_dir='./test_images', clear_before_run=True)
    def main():
        parser = GooeyParser()
        parser.add_argument('seconds', default=3, type=int)
        parser.add_argument('-error', action='store_true')
        args = parser.parse_args()
    
        print('running')
        time.sleep(args.seconds)
    
        if args.error:
            print('error about to occur')
            print(int('abc'))
    
    
    if __name__ == '__main__':
        main()
    

    image

    animation_example

    Checklist:

    • [x] You're opening this PR against the current release branch
    • [x] Works on both Python 2.7 & Python 3.x
    • [x] Commits have been squashed and includes the relevant issue number
    • [x] Pull request description contains link to relevant issue or detailed notes on changes
    • [x] This must include example code demonstrating your feature or the bug being fixed
    • [x] All existing tests pass
    • [ ] Your bug fix / feature has associated test coverage
    • [x] README.md is updated (if relevant)
    opened by conradhilley 0
  • Reduce width of Dropdown widget

    Reduce width of Dropdown widget

    This is not a bug. For each dropdown line I'm adding a very long command line. This causes the dropdown widget to not even show on screen. I'm sure I missed a setting to fix this. See image below. Here is my code for the dropdown

    ffmpeg.add_argument('Choose Command Line',
                            choices=["--avhw --cbr 6000 --codec h265 --multipass none --preset quality --profile main10 --tier high --level 4.1 --output-depth 10 --vpp-edgelevel strength=9,threshold=12 --bframes 2 --ref 4 --gop-len 150 --lookahead 32 --aq --qp-init 1 --cuda-schedule auto --mv-precision q-pel --colorrange auto --colormatrix auto --colorprim auto --transfer auto --max-cll copy --master-display copy --videoformat auto --chromaloc auto --vpp-unsharp weight=1.5,radius=3 --vpp-gauss 3 --crop 0,0,0,0 --seek 0:00:00.000", "two"],
                            default="two",
                            widget='Dropdown'
                            )
    
    2021-10-03_184836 . 1.0.9-release 
    opened by tyeeman 2
  • Tab key does not navigate between controls.

    Tab key does not navigate between controls.

    Description

    Gooey is currently not able to be propertly navigated via keyboard by tabbing through controls on any of the platforms I've tested it on. I know WXWidgets support for A11y in general is weak and due to be shored up soon, but I believe WXWidgets library, but tab navigation is implemented in it, and is a critical need for software that might be used by people with various vision and motor impairments.

    Issues:

    • If focus is on application but not on any field, tab key does nothing. Should move focus to first field.
    • Cancel and start buttons do not take focus. Should take focus after fields.
    • checkboxes do not appear to take focus (though they do in fact take it)

    This list may not be exhaustive.

    Replication environments

    • OS: Tested across Windows 10 Home and OSX
    • Python Version: 3.6.4
    • Gooey Version: 1.0.8.1

    Code example

    from gooey import Gooey
    from argparse import ArgumentParser
    
    @Gooey
    def main():
        ap = ArgumentParser("Test case program")
        ap.add_argument("foo")
        ap.add_argument("bar")
        ap.add_argument("baz")
        ap.add_argument("--bool", action="store_true")
        args = ap.parse_args()
        print(args)
    
    if __name__ == "__main__":
        main()
    

    Thanks for Gooey - it's a very useful and convenient tool!

    opened by pobocks 0
Releases(1.0.8.1)
  • 1.0.8.1(Jun 12, 2021)

  • 1.0.8(Dec 20, 2020)

    Gooey 1.0.8 Released!

    Another minor Gooey release! This one brings a new global Gooey Option for setting initial values in the UI, support for version action types, plus a few bug/linting fixes.

    Additionally, I continue to plug away at getting the test coverage to useful levels. We're now pushing 80% coverage which is making working on Gooey with confidence much easier!

    New Gooey Options: initial_value

    This option lets you specify the value present in the widget when Gooey starts.

    parser.add_argument('-my-arg', widget='Textarea', gooey_options={
        'initial_value': 'Hello world!'  
    })
    

    Or, using the new options helpers:

    from gooey import options 
    parser.add_argument('-my-arg', widget='Textarea', gooey_options=options.Textarea(
        initial_value='Hello World!'
    ))
    

    If you've been using Gooey awhile, you'll recognize that this overlaps with the current behavior of default. The new initial_value enables you to supply a truly optional seed value to the UI. When using default, even if the user clears your value out of the UI, argparse will add it back in when it parses the CLI string. While this is often useful behavior, it prevents certain workflows from being possible. initial_value let's you control the UI independent of argparse. This means you can now, for instance, set a checkbox to be checked by default in the UI, but optionally allow the user to deselect it without having argprase re-populate the 'checked' state (a behavior which comes up frequently in the issue tracker due to it being technically correct, but also very confusing!).

    action=version support

    When using action='version' Gooey will now map it a CheckBox widget type.

    Other Fixes / Changes:

    • Bug fix: add missing translation step for tabbed group titles (@neonbunny)
    • Linting: swap is not for != (@DrStrinky)

    Breaking Changes

    No breaking API changes from 1.0.7 to 1.0.8

    Thank you to the current Patreon supporters!

    • Sponsors:
      • Qteal
    • Individuals:
      • Joseph Rhodes
      • Nicholas
      • Joey
    Source code(tar.gz)
    Source code(zip)
    Gooey-1.0.8.tar.gz(584.98 KB)
  • 1.0.7(Nov 29, 2020)

    Gooey 1.0.7 Released!

    Lots of new stuff this release! We've got 3 new widget types, new gooey_options, as well as some quality of Life improvements for using Gooey Options.

    New Widgets: IntegerField, DecimalField, and Slider

    Gooey now has 3 inputs specifically geared towards accepting numeric inputs. Previously, all Gooey had were text fields which you could add validators to in order to enforce only numbers were entered, but now we have top level widgets which do all of that out of the box!

    Important Usage Note: since these numeric inputs don't allow any non-numeric characters to be entered, they do not give you the ability to blank them out. Unlike a TextField which can be left empty and thus have its value not passed to your program, the numeric inputs will always send a value. Thus, you have to have sane handling in user-land.

    Checkout the Options docs for more details.

    New Gooey Options: placeholder

    Widgets with text inputs now all accept a placeholder Gooey option.

    add_argument('--foo', widget='TextField', gooey_options=options.TextField(
        placeholder='Type some text here!'
    )
    
    # or without the options helper 
    add_argument('--foo', widget='TextField', gooey_options={
        'placeholder': 'Type some text here!'
    })
    

    New Validator option: RegexValidator

    add_argument('--foo', widget='TextField', gooey_options=options.TextField(
        placeholder='Type some text here!',
        validator=options.RegexValidator(
            test='\d{4}',
            message='Must be exactly 4 digits long!'
        )
    )
    
    # or without the options helper 
    add_argument('--foo', widget='TextField', gooey_options={
        'placeholder': 'Type some text here!',
        'validator': {
            'type': 'RegexValidator',
            'test': '\d{4}',
            'message': 'Must be exactly 4 digits long!'
        }
    })
    

    New feature: Options helpers

    Gooey now has a top-level options module which can be imported. Previously, Gooey Options have been an opaque map. While great for openness / extensibility, it's pretty terrible from a discoverability / "what does this actually take again..?" perspective. The new options module aims to make using gooey_options easier and more discoverable.

    from gooey import options
    

    The goal is to enable IDE's to provide better auto-completion help as well as more REPL driven usefulness via help() and docstrings.

    from gooey import options
    
    parser.add_argument(
        '--foo', 
        help='Some foo thing',
        widget='FilterableDropdown',
        gooey_options=options.FilterableDropdown(
            placeholder='Search for a Foo',
            search_strategy=options.PrefixSearchStrategy(
                ignore_case=True 
            )
        ))
    

    Note that these are just helpers for generating the right data shapes. They're still generating plain data behind the scenes and thus all existing gooey_options code remains 100% compatible.

    Better Docs:

    Which is to say, documentation which actually exists rather than not exist. You can inspect the docs live in the REPL or by hopping to the symbol in editors which support such things.

    >>> from gooey import options 
    >>> help(options.RadioGroup) 
    Help on function FileChooser in module __main__:
    
    FileChooser(wildcard=None, default_dir=None, default_file=None, message=None, **layout_options)
        :param wildcard: Sets the wildcard, which can contain multiple file types, for 
                         example: "BMP files (.bmp)|.bmp|GIF files (.gif)|.gif"
        :param message:  Sets the message that will be displayed on the dialog.
        :param default_dir: The default directory selected when the dialog spawns 
        :param default_file: The default filename used in the dialog
        
        Layout Options:
        ---------------
        
        Color options can be passed either as a hex string ('#ff0000') or as
        a collection of RGB values (e.g. `[255, 0, 0]` or `(255, 0, 0)`)
        
        :param label_color:    The foreground color of the label text
        :param label_bg_color: The background color of the label text.
        :param help_color:     The foreground color of the help text.
        :param help_bg_color:  The background color of the help text.
        :param error_color:    The foreground color of the error text (when visible).
        :param error_bg_color: The background color of the error text (when visible).
        :param show_label:     Toggles whether or not to display the label text
        :param show_help:      Toggles whether or not to display the help text
        :param visible:        Hides the entire widget when False. Note: the widget
                               is still present in the UI and will still send along any
                               default values that have been provided in code. This option
                               is here for when you want to hide certain advanced / dangerous
                               inputs from your GUI users.
        :param full_width:     This is a layout hint for this widget. When True the widget
                               will fill the entire available space within a given row.
                               Otherwise, it will be sized based on the column rules
                               provided elsewhere. 
    

    Ideally, and eventually, we'll be able to completely type these options to increase visibility / usability even more. However, for backwards compatibility reasons, Gooey will continue to be sans anything more than the most basic of type hinting for the time being.

    Breaking Changes

    No breaking API changes from 1.0.6 to 1.0.7. However, the strictness of existing Gooey Options has been increased, which could result in issues when upgrading from 1.0.6. In an attempt to be helpful, Gooey now throws an exception if invalid Gooey Options are supplied. This is to catch things like invalid types or ill-formed data. If you were passing bad data in 1.0.6, it will now be flagged as such in 1.0.7.

    Thank you to the current Patreon supporters!

    • Sponsors:
      • Qteal
    • Individuals:
      • Joseph Rhodes
      • Nicholas
    Source code(tar.gz)
    Source code(zip)
    Gooey-1.0.7.tar.gz(583.06 KB)
  • 1.0.6(Nov 15, 2020)

    Gooey 1.0.6 Released!

    This is a minor release beefing up the new FilterableDropdown's search capabilities and performance. In the previous release, the dropdown was backed by WX's ListBox widget. 1.0.6 replaces this for a fully virtualized version which allows Gooey to operate on massive datasets without taking a hit to UI performance. Additionally, how Gooey internally filters for matches has also been updated. Choice are now backed by a trie for super fast lookup even against large data sets. Tokenization and match strategies can be customized to support just about any lookup style.

    Head over to the Examples Repo to see the updated demo which now uses a datset consisting of about 25k unique items.

    New Gooey Options:

    FilterableDropdown now takes a search_strategy in its gooey_options.

    from gooey import Gooey, GooeyParser, PrefixTokenizers
    
    gooey_options={
        'label_color': (255, 100, 100),
        'placeholder': 'Start typing to view suggestions',
        'search_strategy': {
            'type': 'PrefixFilter',
            'choice_tokenizer': PrefixTokenizers.ENTIRE_PHRASE,
            'input_tokenizer': PrefixTokenizers.REGEX('\s'),
            'ignore_case': True,
            'operator': 'AND',
            'index_suffix': False
        }
    })
    

    This gives control over how the choices and user input get tokenized, as well as how those tokenized matches get treated (ANDed together vs ORd). Want to match on any part of any word? Enable the index_suffix option to index all of your candidate words by their individual parts. e.g.

    Word: 'Banana' 
    Suffixes: ['Banana', 'anana', 'nana', 'ana']
    

    These all get loaded into a trie for super fast lookup. Combine this with the WORDs tokenizer, and you get really fine grained search though your options!

    Thank you to the current Patreon supporters!

    • Qteal
    • Joseph Rhodes

    Breaking Changes

    No breaking changes from 1.0.5.

    Source code(tar.gz)
    Source code(zip)
    Gooey-1.0.6.tar.gz(574.04 KB)
  • 1.0.5(Nov 8, 2020)

    Gooey 1.0.5 Released!

    Gooey is now using WX 4.1.0!

    This change should resolve several issues in Ubuntu as well as the numerous other quirks which have been reported.

    Thank you to the current Patreon supporters!

    • Qteal
    • Joseph Rhodes

    New widgets:

    FilterableDropdown

    Filterable Dropdown

    You can checkout a runnable example in the GooeyExamples repo here

    Example Code:

    add_argument(
        choices=['a', 'b', 'c'],
        widget='FilterableDropdown',
        gooey_options={
            'no_match': 'No results found!',
            'placeholder': 'Type something!'
    })
    

    This introduces a new language translation key: "no_matches_found" to handle the case where the user's input doesn't match any of the choices. This is used by default, but can be overridden via gooey options

    Elapsed Time / Estimated time remaining

    fbHcpCAGD8

    @JackMcKew put in a herculean effort and introduced a new feature where elapsed and estimated remaining time can be shown in addition to the standard progress bar.

    You can checkout an example here

    Example Code:

    @Gooey(timing_options={
        'show_time_remaining':True,
        'hide_time_remaining_on_complete':True
    })
    

    Breaking Changes

    • (documentation breaking)terminal_font_weight's public documented API allowed the strings "NORMAL" and "BOLD" while its internal implementation relied on numeric font weights (light=200, normal=300, etc..). The documentation was updated to show the correct usage and a constants file was added to the public API.

    Functionality

    • @neonbunny enabled Parsers to use configuration from parents.
    • @eladeyal-intel updated RichTextConsole to allow control+scrollwheel to zoom the text

    Language Additions / Improvements

    • @soleil0-0 - Additional Chinese translation
    • @dancergraham - Additional French translation
    • @ajvirSingh1313 - Hindi translation

    Bug Fixes

    • Fixed bug where dynamic updates to a Dropdown would cause the selection to be lost
    • Fixed performance issues where dynamic updates with large items would cause Gooey to hang
    • @rotu fixed a bug in dynamic updates related to Popen usage.
    • @neonbunny - resolved warning cause by missing return statement
    • Fixed bug where terminal font and colors were not being set correctly
    • Fixed mysterious RadioGroup issue where underlying WxWidgets would 'forget' the current selection under certain circumstances
    Source code(tar.gz)
    Source code(zip)
    Gooey-1.0.5.tar.gz(571.46 KB)
  • 1.0.4(Jun 21, 2020)

    Gooey 1.0.4 Released!

    Gooey picked up some cool new widget types thanks to awesome contributions from @NathanRichard and @conradhilley.

    The rest of this release was focused on bug fixes and quality improvements. My commitment is to having Gooey be a stable, reliable project. This has required slowly shedding it's fast and loose hobby project past. Test coverage more than doubled between 1.0.3 and 1.0.4 and several bugs were fixed along the way as a result of this. The next few releases of Gooey will be similarly focused on bringing its codebase up to snuff so that wider changes can be made without introducing unexpected regressions.

    Upgrading from 1.0.3 to 1.0.4

    Translation notice! Yes/No options in confirmation modals are now backed by the language files. Previously, they were fixed to english regardless of the selected language. If the new language options aren't configured for your language, you will now see a translation request in the button label!

    What's new

    Widgets: TimeChooser

    Usage:

    parser = GooeyParser()
    parser.add_argument('--time', widget='TimeChooser')
    

    @NathanRichard added this one after an excellent deep dive into the complexities of dealing with time inside of WX. See the README for notes on usage.

    Widgets: ColourChooser

    Usage:

    parser = GooeyParser()
    parser.add_argument('--color', widget='ColourChooser')
    

    @conradhilley brought this one to life. You can now select colors from an awesome little chooser widget.

    CLI based defaults

    @jschultz added the ability to use arguments passed on the command line as defaults in Gooey. Enable this functionality by passing use_cmd_args to the Gooey decorator.

    @Gooey(use_cmd_args=True)
    def main():
        parser = ArgumentParser()
        parser.add_argument('--foo')
    

    Now any CLI args you pass when invoking your program will show up as defaults in Gooey.

    python my_program.py --foo "hello!" 
    

    Additional features

    • Added option to start Gooey in full screen mode

    Language Additions / Improvements

    • @foben - documentation fixes
    • @gediz - turkish translations
    • @dsardelic - bosnian & Croatian translations
    • @partrita - Korean translations

    Bug Fixes

    • Main README image had a typo "Command Lines Applications"
    • Truthy values
    • Fixed bug where nargs in textfields weren't being mapped correctly
    • Fixed bug where argparse's SUPPRESS flag was showing in the UI
    • Fixed missing i18n capabilities in modals
    • Fixed bug where program_description wasn't being honored
    • Fixed bug where gooey_options weren't being honored in the Header
    • Fixed bug where RadioGroup wasn't enabling it's child widget when initial_selection was set
    • Fixed bug where checkboxes weren't honoring visibility options
    • Fixed bug where gooey_options weren't being passed to footer
    Source code(tar.gz)
    Source code(zip)
  • 1.0.3.1-hotfix(Apr 25, 2020)

    This is a temporary hotfix downgrading the wxpython used by Gooey to 4.0.7.

    WxPython 4.10 introduced unexpected breaking changes. These changes caused Gooey to fail when starting up.

    If you are seeing errors such as this when running Gooey

    wx._core.wxAssertionError: C++ assertion "!(flags & wxALIGN_CENTRE_HORIZONTAL)" failed at ..\..\src\common\sizer.cpp(2106) in wxBoxSizer::DoInsert(): Horizontal alignment flags are ignored in horizontal sizers
    

    This release will resolve them.

    Longer term solution to follow pending additional research.

    Source code(tar.gz)
    Source code(zip)
  • 1.0.3(Sep 22, 2019)

    title card

    After cooking for far too long, Gooey 1.0.3 is released!

    Grab the latest version:

    Runnable demos for all the new features can be found in the Examples repo.

    Overview:

    A lot of focus was put on settling Gooey down into a more stable mature project. In addition to all of the new features, a lot of time was spent writing documentation, stamping down cross platform issues / quirks, and making numerous tweaks and additions to enable a smoother experience when packaging Gooey for distribution.

    What's new

    Fancy Layout controls!

    advanced layout

    The main goal of this release was enabling more complex real-world layouts and more customization of Gooey's UI. As of 1.1.0, you now have have control over every color, font, and display status within the application. You can now brand Gooey to your organization's colors, logically group related items under a central heading, and optionally show/hide all the individual components that make up an input widget.

    Menu Bars

    Gooey now includes a simple declarative system for creating top level menu bars and items.

    menu bar

    The menu option currently supports three flavors:

    AboutDialog

    This is an AboutDialog as rendered natively by your OS. It's a good place to show standard info like version info, descriptions, licenses, etc.. in a standard way across platforms.

    MessageDialogs

    Next up are general message dialogs. You can display any informational text inside of these.

    Link

    Finally, you can create fixed menu items that simply link to external resources, for instance, your site, documentation, pdfs, etc..

    Rich Text Controls

    Thanks to @NathanRichard, Gooey can now optionally honor terminal control sequences and display Rich Text in the output panel.

    rich text

    New Gooey Program Icon

    New icon provided by professional cool guy and crazy talented UX designer Justin Rhee.

    Additional features

    • OSX now shows program Icon in Dock
    • show_error_modal option to toggle whether or not failures additionally raise alert modals.
    • BlockCheckbox widget.
    • Hyperlinks written to the console appear as such and will launch a browser on click
    • clear_before_run option lets you control whether or not subsequent program runs start from a fresh terminal or preserve the previous output.
    • Conditionally show/hide restart button
    • requires_shell option - controls how Popen spawns your program. By default (and historically), this value is False.
    • Optionally silence textual progress updates when using the Progress widget (via @conradhilley)
    • Multi-Directory Choosers - these were accidentally dropped from the project. @HenrykHaniewicz added them back!
    • Additional explicit wx imports to make packaging on OSX easier
    • Textfields can now be made Readonly for informational purposes
    • better custom target support via suppress_gooey_flag which prevents the --ignore-gooey flag from being injected

    Breaking Changes

    No breaking changes between 1.0.0 and 1.1.0!

    Language Additions / Improvements

    • Completed Italian translation - @gison93

    • Updated French translation - @NathanRichard

    • Updated Hebrew translation - @eturkes

    Bug Fixes

    • Fixed 5 year old bug(!) where an errant lambda function wasn't passing through all of its arguments which caused frustratingly opaque failures under specific conditions.
    • Fixed bug where external updates weren't applied to ListBox
    • Fix bug where tuples weren't coerced to List which causes concatenation errors
    • Fixed bug where string coercion in argparse_to_json was too broad and caused type errors
    • Fixed bug where wrong validator was applied to Dropdown type causing preflight checks to always fail
    • Fixed bug where Radio Groups would apply too much vertical spacing between components
    • Fixed bug where subgroups with single items were attached to the wrong UI parent
    • Fixed bug where legacy default groups weren't being translated
    • Fixed bug where certain languages would sometimes cause components to be rendered off screen
    Source code(tar.gz)
    Source code(zip)
Owner
Chris
Full stack developer and general awesome person
Chris
A GUI for designing Python GUI's for PySimpleGUI.

SimpleGUIBuilder A GUI for designing Python GUI's for PySimpleGUI. Installation There is none :) just download the file from a release and run it. Don

Miguel Martins 52 Nov 23, 2021
Create shortcuts on Windows to your Python, EXE, Batch files or any other file using a GUI made with PySimpleGUI

shor Windows Shortcut Creation Create Windows Shortcuts to your python programs and any other file easily using this application created using PySimpl

PySimpleGUI 7 Nov 16, 2021
Build GUI for your Python program with JavaScript, HTML, and CSS

https://pywebview.flowrl.com pywebview is a lightweight cross-platform wrapper around a webview component that allows to display HTML content in its o

Roman 2.6k Nov 30, 2021
A Simple GUI application to organize and store accounts/passwords.

PyssView A Simple GUI application to organize and store accounts/passwords. Install/Run (Linux) Via script This way will install a binary version and

Jefferson Richard Dias 1 Nov 24, 2021
Learn to build a Python Desktop GUI app using pywebview, Python, JavaScript, HTML, & CSS.

Python Desktop App Learn how to make a desktop GUI application using Python, JavaScript, HTML, & CSS all thanks to pywebview. pywebview is essentially

Coding For Entrepreneurs 34 Oct 8, 2021
A little Python library for making simple Electron-like HTML/JS GUI apps

Eel Eel is a little Python library for making simple Electron-like offline HTML/JS GUI apps, with full access to Python capabilities and libraries. Ee

Chris Knott 4.7k Dec 1, 2021
A Python native, OS native GUI toolkit.

Toga A Python native, OS native GUI toolkit. Prerequisites Minimum requirements Toga requires Python 3. Python 2 is not supported. If you're on macOS,

BeeWare 2.8k Dec 2, 2021
Edifice: a declarative GUI library for Python

Edifice is a Python library for building reactive UI, inspired by modern Javascript libraries such as React.

David Ding 78 Nov 25, 2021
A Python native, OS native GUI toolkit.

Toga A Python native, OS native GUI toolkit. Prerequisites Minimum requirements Toga requires Python 3. Python 2 is not supported. If you're on macOS,

BeeWare 2.8k Nov 26, 2021
A small pomodoro GUI for Windows/Linux created in Python with PyQt5.

Pomodoro A small pomodoro GUI for Windows/Linux created with PyQt5. Features The "Timer" tab allows you to set your desired work and rest times aswell

Burak Martin 74 Nov 22, 2021
My Git GUI version made in Python and Tkinter.

Description My Git GUI version made in Python and Tkinter. How to use Basically, create a folder in your computer, open the software, select the path

Matheus Golzio 4 Oct 10, 2021
Aplicação GUI feita em Python para estudos de cadastro (forms).

Cadastro de DEVs GUI ?? A ideia original veio do repositório do https://github.com/PedroTomazeti nomeado 'Projetos-Independentes-HTML-CSS' Nele há um

Yago Goltara 3 Aug 15, 2021
Delphi's FireMonkey framework as a Python module for Windows, MacOS, Linux, and Android GUI development.

DelphiFMX4Python Delphi's FireMonkey framework as a Python module for Windows, MacOS, Linux, and Android GUI development. About: The delphifmx library

Embarcadero Technologies 30 Dec 3, 2021
Simple GUI python app to show a stocks graph performance. Made with Matplotlib and Tiingo.

stock-graph-python Simple GUI python app to show a stocks graph performance. Made with Matplotlib and Tiingo. Tiingo API Key You will need to add your

Toby 8 Nov 25, 2021
A Url Shortener with GUI made in Python.

Url-Shortener-with-GUI-in-python A Url Shortener with GUI made in Python. To Run this download the zip file and run the main file or Clone this repo.

SidTheMiner 1 Nov 12, 2021
Signin/Signup GUI form using tkinter in python

SignIn-SignUpFormRepo Hello there, I am Shahid and this is the Signin/Signup GUI form using tkinter in python if you want to use avatar images then pa

Shahid Akhtar 1 Nov 9, 2021
LittlePythonGUIGuide - This is a short GUI Guide with python

This is a short GUI Guide with python, learning how to use the simple and easy moduel built into python, named tkinter.

1cy50ng3b0b 1 Nov 21, 2021
GUI Python Auto text bot.

Bagel Text Bot Auto text bot. Written in Python. Contributing Pull requests are welcome. For major changes, please open an issue first to discuss what

Toby 2 Nov 21, 2021
Custom GUI for your Blender add-ons using Dear ImGui

Dear Imgui for Blender Use the infamous Dear ImGui library directly in your Blender scripts! This means custom GUI drawing in your operators: Normally

Elie Michel 58 Nov 12, 2021