Cookbook Example

How can I...?

Example 6: How to build a network controllable graph viewer. Components used: TopologyViewerServer


    from Kamaelia.Visualisation.PhysicsGraph.TopologyViewerServer import TopologyViewerServer

    def parseArgs(argv, extraShortArgs="", extraLongArgs=[]):
    import getopt

    shortargs = "fh" + extraShortArgs
    longargs = list("help","fullscreen","resolution=","port=") + extraLongArgs

    optlist, remargs = getopt.getopt(argv, shortargs, longargs)

    dictArgs = {}
    for o,a in optlist:
    if o in ("-h","--help"):
    dictArgs['help'] = "Arguments:\n" + \
    " -h, --help\n" + \
    " This help message\n\n" + \
    " -f, --fullscreen\n" + \
    " Full screen mode\n\n" + \
    " --resolution=WxH\n" + \
    " Set window size to W by H pixels\n\n" + \
    " --port=N\n" + \
    " Listen on port N (default is 1500)\n\n"

    elif o in ("-f","--fullscreen"):
    dictArgs['fullscreen'] = True

    elif o in ("--resolution"):
    match = re.match(r"^(\d+)[x,-](\d+)$", a)
    dictArgs['screensize'] = (x,y)

    elif o in ("--port"):
    dictArgs['serverPort'] = int(a)

    return dictArgs, optlist, remargs

    if __name__=="__main__":
    import sys
    dictArgs, remargs, junk = parseArgs(sys.argv[1:])

    if "help" in dictArgs:
    print dictArgs["help"]

    Source: Examples/example6/


Kamaelia is an open source project originated from and guided by BBC Research. For more information browse the site or get in contact.

This is an ongoing community based development site. As a result the contents of this page is the opinions of the contributors of the pages involved not the organisations involved. Specificially, this page may contain personal views which are not the views of the BBC. (the site is powered by a wiki engine)

(C) Copyright 2008 Kamaelia Contributors, including the British Broadcasting Corporation, All Rights Reserved

This web site is powered by the same code created for the bicker manor project. For more details, contact Michael Sparks at BBC Research directly (cf contact)