optparse_required module
Module to extend optparse, it add required options and new types to use
into gui module.
Classes:
-
class pymodis.optparse_required.OptionParser(**kwargs)[source]
Bases: optparse.OptionParser
Extend optparse.OptionParser
-
check_values(values, args)[source]
Check if value is required for an option
-
class pymodis.optparse_required.OptionWithDefault(*opts, **attrs)[source]
Bases: optparse.Option
Extend optparse.Option add required to the attributes and some new
types for the GUI
-
ATTRS = ['action', 'type', 'dest', 'default', 'nargs', 'const', 'choices', 'callback', 'callback_args', 'callback_kwargs', 'help', 'metavar', 'required']
-
TYPES = ('string', 'int', 'long', 'float', 'complex', 'choice', 'file', 'output', 'directory')
optparse_gui module
A drop-in replacement for optparse (“import optparse_gui as optparse”)
Provides an identical interface to optparse(.OptionParser),
But displays an automatically generated wx dialog in order to enter the
options/args, instead of parsing command line arguments
Classes:
Functions:
-
class pymodis.optparse_gui.Option(*opts, **attrs)[source]
Bases: optparse.Option
Extended optparse.Option class
-
ACTIONS = ('store', 'store_const', 'store_true', 'store_false', 'append', 'append_const', 'count', 'callback', 'help', 'version', 'group_name')
-
ATTRS = ['action', 'type', 'dest', 'default', 'nargs', 'const', 'choices', 'callback', 'callback_args', 'callback_kwargs', 'help', 'metavar', 'required']
-
SUPER
alias of Option
-
TYPED_ACTIONS = ('store', 'append', 'callback', 'group_name')
-
TYPES = ('string', 'int', 'long', 'float', 'complex', 'choice', 'file', 'output', 'directory', 'group_name')
-
class pymodis.optparse_gui.OptionParser(*args, **kwargs)[source]
Bases: optparse.OptionParser
Extended optparse.OptionParser to create the GUI for the module
-
SUPER
alias of OptionParser
-
error(msg)[source]
Return an error message with wx.MessageDialog
Parameters: | msg (str) – is the error string to pass to message dialog |
-
parse_args(args=None, values=None)[source]
This is the heart of it all overrides
optparse.OptionParser.parse_args
Parameters: |
- arg – is irrelevant and thus ignored, it’s here only for
interface compatibility
- values – is irrelevant and thus ignored, it’s here only for
interface compatibility
|
-
class pymodis.optparse_gui.OptparseDialog(optParser, title, parent=None, ID=0, pos=wx.Point(-1, -1), size=wx.Size(-1, -1), style=536877120)[source]
Bases: wx._windows.Dialog
The dialog presented to the user with dynamically generated controls,
to fill in the required options.
Parameters: |
- optParser – the optparse object
- title (str) – the title to add in the GUI
- parent – the parent GUI
- ID (int) – the ID of GUI
- pos – the position of GUI
- size – the dimension of GUI
- style – the style of GUI
|
Based on the wx.Dialog sample from wx Docs & Demos
-
getOptionsAndArgs()[source]
Parse the options and args
Returns: | a dictionary of option names and values, a sequence of args |
-
onBrowse(event)[source]
Choose file
-
onText(event)[source]
File changed
-
exception pymodis.optparse_gui.UserCancelledError[source]
Bases: exceptions.Exception
??
-
pymodis.optparse_gui.checkLabel(option)[source]
Create the label for an option, it add the required string if needed
Parameters: | option – and Option object |