Simplified usage of https://github.com/chriskiehl/Gooey that turns argparse-based Python CLIs into GUI apps
ezgooey is a Python utility that adds a GUI to argparse-based CLI applications. It uses Gooey under the hood, switching between GUI and CLI modes automatically based on whether command-line arguments are provided.
It also includes a logging module with colored output that works in both terminal and GUI environments.
ezgooey for?Python developers who:
argparse for CLI apps@ezgooey to your parser functionargparse codepip install ezgooey
Installs Gooey, wxPython, and colored as dependencies.
ezgooey.ez: Adding GUI to your CLIAdd the @ezgooey decorator to your ArgumentParser function:
from argparse import ArgumentParser
from ezgooey.ez import ezgooey
@ezgooey
def create_my_parser():
parser = ArgumentParser(
prog='my_app',
description='This is a demonstration app.'
)
parser.add_argument(
'filename',
help='Path to the input file',
widget='FileChooser'
)
parser.add_argument(
'-v', '--verbose',
action='store_true',
help='Enable verbose output'
)
return parser
if __name__ == '__main__':
parser = create_my_parser()
args = parser.parse_args()
if args.verbose:
print("Verbose mode enabled.")
print(f"Processing file: {args.filename}")
Behavior:
python script.py → Opens GUIpython script.py file.txt -v → Runs as CLIAdvanced example with Gooey options:
from argparse import ArgumentParser
from ezgooey.ez import ezgooey
GUI_NAME = 'My Advanced GUI App'
CLI_NAME = 'mycli'
@ezgooey(
program_name=GUI_NAME,
default_size=(800, 600),
navigation='Tabbed',
menu=[{
'name' : 'Help',
'items': [{
'type': 'AboutDialog',
'menuTitle': 'About',
'name': GUI_NAME,
'description': 'An example application using ezgooey.',
'website': 'https://github.com/twardoch/ezgooey',
'license': 'MIT'
}]
}]
)
def get_advanced_parser():
parser = ArgumentParser(
prog=CLI_NAME,
description='An advanced application with multiple options.'
)
group1 = parser.add_argument_group(
'Input/Output',
gooey_options={'columns': 1, 'show_border': True}
)
group1.add_argument(
'--input-file',
widget='FileChooser',
help='File to process',
gooey_options={'wildcard': "Text files (*.txt)|*.txt"}
)
group1.add_argument(
'--output-dir',
widget='DirChooser',
help='Directory to save results'
)
group2 = parser.add_argument_group(
'Settings',
gooey_options={'columns': 2}
)
group2.add_argument(
'--iterations',
type=int,
default=10,
help='Number of iterations to run'
)
group2.add_argument(
'--mode',
choices=['fast', 'slow', 'balanced'],
default='balanced',
help='Processing mode'
)
return parser
if __name__ == '__main__':
parser = get_advanced_parser()
args = parser.parse_args()
print(f"Input: {getattr(args, 'input_file', 'N/A')}, Output Dir: {getattr(args, 'output_dir', 'N/A')}")
print(f"Iterations: {args.iterations}, Mode: {args.mode}")
See Gooey documentation for all decorator options.
ezgooey.logging: Colored, GUI-friendly logs# Initialize once at app start
import ezgooey.logging as logging
logging.init(level=logging.INFO)
# Use anywhere in your code
import logging
logging.info('This is an info message.')
logging.warning('This is a warning.')
logging.error('This is an error!')
logging.success('Operation completed successfully!') # Custom level
Named loggers for larger applications:
# At app start
import ezgooey.logging as ez_logging
ez_logging.init(level=ez_logging.INFO)
# In other modules
import ezgooey.logging as ez_logging
log = ez_logging.logger('my_module_name')
log.info('Info message from my_module.')
log.warning('Warning from my_module.')
log.success('Task in my_module succeeded.')
Log levels:
Standard levels plus SUCCESS for positive feedback. Output is color-coded by severity.
ezgooey.ezgooey only when neededargparse methods to accept Gooey-specific options (widget, gooey_options) without breaking CLI modeExample: parser.add_argument(..., widget='FileChooser') works in both modes.
ezgooey.loggingConfigures Python’s standard logging with:
colored librarySUCCESS level with green textinit() function for one-time setuplogger() function that adds success() method to loggersezgooey/
├── ezgooey/
│ ├── __init__.py # Package initialisation, version
│ ├── ez.py # Core decorator logic, monkey-patching
│ └── logging.py # Colored logging setup
├── tests/
│ ├── test_ez.py
│ ├── test_integration.py
│ ├── test_logging.py
│ └── test_version.py
├── docs/
│ └── index.md # Jekyll documentation site
├── pyproject.toml # Build (hatchling + hatch-vcs), ruff, mypy, pytest config
├── README.md # This file
├── CHANGELOG.md # Version history
└── LICENSE # MIT license
Installed automatically with pip.
Issues and pull requests welcome at GitHub repository.
pip install hatch
hatch env create
hatch run pytest # run test suite (29 tests)
hatch run ruff check . # lint
hatch run mypy ezgooey/ # type-check
hatch build # produces sdist + wheel in dist/
See CHANGELOG.md and GitHub Releases.
MIT License. Copyright © 2020-2023 Adam Twardoch.