All Projects → shimpe → argparseui

shimpe / argparseui

Licence: GPL-3.0 license
automagically add a PyQt based UI to setup options to an argparse based command-line tool

Programming Languages

python
139335 projects - #7 most used programming language
shell
77523 projects

Projects that are alternatives of or similar to argparseui

autoprogram
Documenting CLI programs
Stars: ✭ 37 (+60.87%)
Mutual labels:  argparse
ida migrator
IDA Migrator is an IDA Pro plugin which helps migrate existing work from one database instance to another. It Conveniently migrates function names, structures and enums.
Stars: ✭ 65 (+182.61%)
Mutual labels:  pyqt
python-qt-live-coding
Live coding environment for Python, Qt and QML.
Stars: ✭ 35 (+52.17%)
Mutual labels:  pyqt
pyqtkeybind
Global hotkey bindings for Windows and Linux for PyQt apps
Stars: ✭ 43 (+86.96%)
Mutual labels:  pyqt
VaspStudio
An useful tool to submit your VASP job on HPC, manage your jobs and extract eneries...自动化VASP任务提交、计算结果提取,任务文件管理的工具
Stars: ✭ 63 (+173.91%)
Mutual labels:  pyqt
docopt-ng
Humane command line arguments parser. Now with maintenance, typehints, and complete test coverage.
Stars: ✭ 94 (+308.7%)
Mutual labels:  argparse
SystemMonitor
Python script and a PyQt5 program to monitor ram and cpu usage along with disk usage.
Stars: ✭ 22 (-4.35%)
Mutual labels:  pyqt
beeref
BeeRef Reference Image Viewer
Stars: ✭ 201 (+773.91%)
Mutual labels:  pyqt
argparse-to-class
Transform argparse into class format for Jupyter Notebook execution
Stars: ✭ 20 (-13.04%)
Mutual labels:  argparse
Grabber
A wrapper for Youtube-dl for Windows.
Stars: ✭ 22 (-4.35%)
Mutual labels:  pyqt
QtPyConvert
An automatic Python Qt binding transpiler to the Qt.py abstraction layer.
Stars: ✭ 66 (+186.96%)
Mutual labels:  pyqt
pdfdir
PDF导航(大纲/目录)添加工具
Stars: ✭ 195 (+747.83%)
Mutual labels:  pyqt
meShaderEd
The RenderMan Shader Editor
Stars: ✭ 21 (-8.7%)
Mutual labels:  pyqt
qmxgraph
A Qt graph drawing widget using JavaScript's mxGraph library.
Stars: ✭ 22 (-4.35%)
Mutual labels:  pyqt
declarative-parser
Modern, declarative argument parser for Python 3.6+
Stars: ✭ 31 (+34.78%)
Mutual labels:  argparse
argparse dataclass
Declarative CLIs with argparse and dataclasses
Stars: ✭ 30 (+30.43%)
Mutual labels:  argparse
plottr
A flexible plotting and data analysis tool.
Stars: ✭ 32 (+39.13%)
Mutual labels:  pyqt
venvipy
A GUI for managing Python virtual environments
Stars: ✭ 24 (+4.35%)
Mutual labels:  pyqt
qt-tile-layout
A tile layout for PyQt5
Stars: ✭ 18 (-21.74%)
Mutual labels:  pyqt
neural-network-sandbox
A toy about fundamental neural network algorithms and Qt Quick 2 interface.
Stars: ✭ 69 (+200%)
Mutual labels:  pyqt
  This file is part of argparseui.

  argparseui is free software: you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation, either version 3 of the License, or
  (at your option) any later version.

  argparseui is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with argparseui.  If not, see <http://www.gnu.org/licenses/>.

argparseui

Purpose of argparseui

argparseui can be used to quickly auto-generate a UI from an argparse based command line tool

the UI has widgets that allow to set up the command line options

argparseui depends on PyQt

State of argparseui

argparseui is a scratch-my-own-itch tool

as such it doesn't support all possibilities of argparse

use at your own risk, but feel free to log a bug/request

Basic Parser Usage

import argparse
import sys
try:
    from PyQt5 import QtWidgets as GtGui
except ImportError:
    from PyQt4 import GtGui
import argparseui

# EXPERIMENT USING BASIC PARSER     
parser = argparse.ArgumentParser()
parser.add_argument("-m", "--make-argument-true", help="optional boolean argument", action="store_true")
parser.add_argument("-o","--make-other-argument-true", help="optional boolean argument 2", action="store_true",  default=True)
parser.add_argument("-n","--number", help="an optional number", type=int)
parser.add_argument("-r","--restricted-number", help="one of a few possible numbers", type=int, choices=[1,2,3],  default=2)
parser.add_argument("-c", "--counting-argument", help="counting #occurrences", action="count")
parser.add_argument("-d", "--default-value-argument", help="default value argument", type=float, default="3.14")
group = parser.add_mutually_exclusive_group()
group.add_argument("-v", "--verbose", action="store_true")
group.add_argument("-q", "--quiet", action="store_true")
parser.add_argument("posarg", help="positional argument", type=str)

app = QtGui.QApplication(sys.argv)
a = argparseui.ArgparseUi(parser)
a.show()
app.exec_()

if a.result() == 1: # Ok pressed
    parsed_args = a.parse_args() # ask argparse to parse the options
    print parsed_args            # print the parsed_options

# Do what you like with the arguments...

Example using save/load button and keeping the dialog open when pressing ok

import argparse
import sys
try:
    from PyQt5 import QtWidgets as GtGui
except ImportError:
    from PyQt4 import GtGui
import argparseui

def do_something(argparseuiinstance):
    options = argparseuiinstance.parse_args()
    print ("Options: ", options)
     
parser = argparse.ArgumentParser()
parser.add_argument("-m", "--make-argument-true", help="optional boolean argument", action="store_true")
parser.add_argument("-o","--make-other-argument-true", help="optional boolean argument 2", action="store_true",  default=True)

app = QtGui.QApplication(sys.argv)
a =     argparseui.ArgparseUi(parser,use_save_load_button=True,ok_button_handler=do_something)
a.show()
app.exec_()
if a.result() != 1:
    # Do what you like with the arguments...
    print ("Cancel pressed")

Extended features

You can pass some extra command line arguments to ArgparseUi:

helptext_default = string [default: ' [default=%(default)s]'] this argument can be used to customize the default value annotations in the ui

remove_defaults_from_helptext = True/False [default: False] if enabled, this option will remove the default value annotations from the labels in the ui

use_save_load_button = True/False [default: False] if set to True, three extra buttons [Load options, Save Options, Save Options As] appear the options are saved to (or loaded from) a command line option file in a file format compatible with argparse's built-in support for loading options from file

use_scrollbars = True/False [default: False] if set to True, the options are embedded in a scrollable panel

window_title = string [default: "Make your choice"] if set to a string, this string will be used as dialog title

left_label_alignment = True/False [default: None] if set to True, the checkboxes are left-aligned. This may be useful on platforms like KDE or MacOsx which by default use right-alignment

ok_button_handler = function taking one argument [default:None] if set to None, the dialog will close upon clicking the ok button and its result will be set to 1 if set to a function accepting an ArgparseUi instance as argument, clicking ok will call that function with "self" as argument

cancel_button_handler = function taking one argument [default:None] if set to None, the dialog will close upon clicking cancel and its result will be != 1 if set to a function accepting an ArgparseUi instance as argument, clicking cancel will call that function with "self" as argument

Contributors

The following people have contributed to argparseui

  • Stefaan Himpe (github user shimpe)
  • Thomas Hisch (github user thisch)
  • Graham (github user 4gra)
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].