#! /usr/bin/env python
"""LLazy 

Usage: python llazy.py [options] 
Options:
  -g ..., --gui=...       use specified gui backend, default Qt4
  -h, --help              show this help
  -d                      show debugging information while parsing

        print self.sender.__class__
Examples:
  python llazy.py -g Qt
"""

from optparse import OptionParser

import sys
import LLazyView
import LLazyModel
import LLazyModules
import Core


class LLazy:
    """
    The LLazy class.
    """
    def __init__(self, options):
        self.guiClient = None
        
        "instanciate the widget factory with option GUI passed in command line parameters"
        LLazyView.WidgetFactory.Widget_factory().set_backend(options.gui)
        
        "create the application widget"
        self.guiClient = LLazyView.WidgetFactory.Widget_factory().create("Main")        
        
    def run(self):
        self.guiClient.draw()

def parseCommandLine():
    """
    Parse command line parameters.
    """
    usage = "usage: %prog [options] arg"
    parser = OptionParser(usage)
    parser.add_option("-g", "--gui", dest="gui",
                      help="use specified gui backend, default Qt4", metavar="GUI",
                      default = "Qt4")

    (options, args) = parser.parse_args()
    return options

def main(argv):
    """
    The main class,
    create an instance of LLazy with command line parameters in parameter
    """
    
    LLazy(parseCommandLine()).run()

if __name__ == "__main__":
    main(sys.argv[1:])

