[Introduction] : A tool for converting Python command line to GUI.
Introduction to the
Gooey is a tool for converting Python console programs into GUI applications, allowing developers to focus on building robust, configurable programs without worrying about how the application is presented and how it interacts with users.
Developers often love the command line, but it’s incomprehensible to the average user. Gooey does a good job of combining the two, allowing developers to focus on code, build complex applications at will, and provide user-friendly application interfaces.
Project address is:
https://github.com/chriskiehl…
Quick start
The installation
The easiest way to install Gooey is through PIP:
pip install Gooey
Alternatively, you can clone the project locally first:
git clone https://github.com/chriskiehl/Gooey.git
Then run the setup.py file:
python setup.py install
Note that users of Python 2 must manually install wxPython, download and install it from the official website.
usage
Gooey attaches to the code through a simple decorator, and any method has an argparse declaration (usually the main method).
from gooey import Gooey
@Gooey <--- all it takes! :)
def main():
parser = ArgumentParser(...)
# rest of code
Configuring different styles and functions by passing parameters to the decorator:
# option@gooey (advanced=Boolean, # whether to display advanced configuration language= LANGUAGE_STRING, # configure language, Json string auto_start=True, target=executable_cmd, program_name=' program_name ', The default script name is program_description. DEFAULT_SIZE =(610, 530), # GUI page size required_cols=1, # number of required columns optional_cols=2, Dump_build_config =False, save your own configuration JSON load_build_config=None, Def main(): parser = ArgumentParser(...) # rest of code
Instead of ArgumentParser, you can use GooeyParser, which provides some more detailed configuration and functionality, including specifying defined components:
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") ...
Here’s a more detailed example from the website:
""" Example program to demonstrate Gooey's presentation of subparsers """ import argparse from gooey import Gooey, GooeyParser from message import display_message running = True @Gooey(optional_cols=2, program_name="Subparser Layout Demo") def main(): settings_msg = 'Subparser example demonstating bundled configurations ' \ 'for Siege, Curl, and FFMPEG' parser = GooeyParser(description=settings_msg) parser.add_argument('--verbose', help='be verbose', dest='verbose', action='store_true', default=False) subs = parser.add_subparsers(help='commands', dest='command') curl_parser = subs.add_parser( 'curl', help='curl is a tool to transfer data from or to a server') curl_parser.add_argument('Path', help='URL to the remote server', type=str, widget='FileChooser') curl_parser.add_argument('--connect-timeout', help='Maximum time in seconds that you allow curl\'s connection to take') curl_parser.add_argument('--user-agent', help='Specify the User-Agent string ') curl_parser.add_argument('--cookie', help='Pass the data to the HTTP server as a cookie') curl_parser.add_argument('--dump-header', type=argparse.FileType(), help='Write the protocol headers to the specified file') curl_parser.add_argument('--progress-bar', action="store_true", help='Make curl display progress as a simple progress bar') curl_parser.add_argument('--http2', action="store_true", help='Tells curl to issue its requests using HTTP 2') curl_parser.add_argument('--ipv4', action="store_true", help=' resolve names to IPv4 addresses only') # ######################################################## siege_parser = subs.add_parser( 'siege', help='Siege is an http/https regression testing and benchmarking utility') siege_parser.add_argument('--get', help='Pull down headers from the server and display HTTP transaction', type=str) siege_parser.add_argument('--concurrent', help='Stress the web server with NUM number of simulated users', type=int) siege_parser.add_argument('--time', help='allows you to run the test for a selected period of time', type=int) siege_parser.add_argument('--delay', help='simulated user is delayed for a random number of seconds between one and NUM', type=int) siege_parser.add_argument('--message', help='mark the log file with a separator', type=int) # ######################################################## ffmpeg_parser = subs.add_parser( 'ffmpeg', help='A complete, cross-platform solution to record, convert and stream audio and video') ffmpeg_parser.add_argument('Output', help='Pull down headers from the server and display HTTP transaction', widget='FileSaver', type=argparse.FileType()) ffmpeg_parser.add_argument('--bitrate', help='set the video bitrate in kbit/s (default = 200 kb/s)', type=str) ffmpeg_parser.add_argument('--fps', help='set frame rate (default = 25)', type=str) ffmpeg_parser.add_argument('--size', help='set frame size. The format is WxH (default 160x128)', type=str) ffmpeg_parser.add_argument('--aspect', Help ='set aspect ratio (4:3, 16:9 or 1.3333, 1.7777)', type= STR) ffmpeg_parser.add_argument('--tolerance', help='set video bitrate tolerance (in kbit/s)', type=str) ffmpeg_parser.add_argument('--maxrate', help='set min video bitrate tolerance (in kbit/s)', type=str) ffmpeg_parser.add_argument('--bufsize', help='set ratecontrol buffere size (in kbit)', type=str) parser.parse_args() display_message() if __name__ == '__main__': main()
internationalization
Gooey supports internationalization and can be easily consistent into the target language. The language is controlled by the Gooey decorator:
@Gooey(language='russian')
def main():
...
controls
Gooey provides a lot of widgets out of the box that developers can introduce directly. Here are just a few of them.
- DirChooser, fileChooser, multifileChooser, fileChooser, fileChooser, fileChooser, fileChooser, fileChooser, fileChooser, fileChooser, fileChooser
.gif)
- Date/Time Picker:
.gif)
- Password text box:
- Color Picker:
.gif)
- Searchable drop-down box:
.gif)
Open source outpost
Daily sharing of popular, interesting and useful open source projects. Participated in the maintenance of 100,000 + STAR open source technology resource library, including: Python, Java, C/C++, Go, JS, CSS, Node.js, PHP,.NET, etc.