Softpedia
 


LINUX CATEGORIES:



GLOBAL PAGES >>
NEWS ARCHIVE >>
SOFTPEDIA REVIEWS >>
MEET THE EDITORS >>
WEEK'S BEST
  • Linux Kernel 3.9.3 / 3....
  • LibreOffice 3.6.6 / 4.0.3
  • MPlayer 1.1.1
  • systemd 204
  • Arch Linux 2013.05.01
  • Blender 2.67a
  • KDE Software Compilatio...
  • CrunchBang Linux Stable...
  • Elementary OS 0.1 / 0.2...
  • SystemRescueCd 3.6.0
  • Home > Linux > Programming > Libraries

    optparse_gui 0.1

    Download button

    No screenshots available
    Downloads: 558  View global page NEW!  Tell us about an update
    User Rating:
    Rated by:
    Fair (2.6/5)
    18 user(s)
    Developer:

    License / Price:

    Last Updated:

    Category:
    Slider Fry | More programs
    GPL / FREE
    April 17th, 2008, 09:15 GMT
    ROOT / Programming / Libraries

     Read user reviews (0)  Refer to a friend  Subscribe

    optparse_gui description

    optparse_gui is a python module which can be described simply by: import optparse_gui as optparse.

    optparse_gui is a python module which can be described simply by: import optparse_gui as optparse.

    optparse_gui is a drop-in replacement for optparse. It allows entering command line arguments in a dynamically generated wx-based dialog.

    optparse_gui generates the dialog depending on the provided optparse options: CheckBox for boolean options, ComboBox for "choice" options, TextCtrl for all other options. An extra TextCtrl for entering non-option command line arguments. Also, the dialog contains context-sensitive help for every option.

    How to use it?

    Like the title says - simply "import optparse_gui as optparse"

    A more elaborate use case might be to use optparse_gui when the application is ran with no command line arguments ( i.e. a double-click on the module's icon ), but use the original optparse to handle the command line arguments if they are given.

    That way, a user can drive your app using a GUI, and yet - the app can be automated by passing command line arguments.

    Here is a sample( this is what you see in the screen-shot above ):

    import sys
    import optparse
    import optparse_gui

    def main():
    usage = "usage: %prog [options] args"
    if 1 == len( sys.argv ):
    option_parser_class = optparse_gui.OptionParser
    else:
    option_parser_class = optparse.OptionParser

    parser = option_parser_class( usage = usage, version='0.1' )
    parser.add_option("-f", "--file", dest="filename", default = r'c:sample.txt',
    help="read data from FILENAME")
    parser.add_option("-a", "--action", dest="action",
    choices = ['delete', 'copy', 'move'],
    help="Which action do you wish to take?!")
    parser.add_option("-n", "--number", dest="number", default = 23,
    type = 'int',
    help="Just a number")
    parser.add_option("-v", "--verbose",
    action="store_true", dest="verbose",
    help = 'To be or not to be? ( verbose )')

    options, args = parser.parse_args()

    print 'args: %s' % args
    print 'options: %s' % options

    if '__main__' == __name__:
    main()


    Product's homepage

      


    TAGS:

    python module | optparse GUI | import optparse_gui | optparse | GUI | Python

    Go to top

    WindowsGamesDriversMacLinuxScriptsMobileHandheldNews

    SUBMIT PROGRAM   |   ADVERTISE   |   GET HELP   |   SEND US FEEDBACK   |   RSS FEEDS   |   UPDATE YOUR SOFTWARE   |   ROMANIAN FORUM