PanTilt  1.3.2
RoadNarrows Robotics Pan-Tilt Project
pantilt_console.application Class Reference

Laelaps control panel. More...

Public Member Functions

def __init__ (self)
 Constructor.
 
def printUsageErr (self, emsg)
 Print usage error. More...
 
def printUsage (self)
 Print Command-Line Usage Message. More...
 
def getOptions (self, argv=None, kwargs)
 Get command-line options. More...
 
def run (self, argv=None, kwargs)
 Run application. More...
 

Public Attributes

 m_win
 

Detailed Description

Laelaps control panel.

Definition at line 716 of file pantilt_console.py.

Member Function Documentation

def pantilt_console.application.getOptions (   self,
  argv = None,
  kwargs 
)

Get command-line options.

Parameters
argvArgument list. If not None, then overrides command-line arguments.
[out]kwargsKeyword argument list.
Returns
Parsed keyword arguments.

Definition at line 758 of file pantilt_console.py.

References pantilt_console.application._Argv0, and pantilt_console.application.printUsage().

Referenced by pantilt_console.application.run().

758  def getOptions(self, argv=None, **kwargs):
759  if argv is None:
760  argv = sys.argv
761 
762  self._Argv0 = kwargs.get('argv0', __file__)
763 
764  # defaults
765  kwargs['debug'] = False # Set to False when finished debugging.
766 
767  # parse command-line options
768  try:
769  opts, args = getopt.getopt(argv[1:], "?h",
770  ['help', ''])
771  except getopt.error, msg:
772  raise usage(msg)
773  for opt, optarg in opts:
774  if opt in ('-h', '--help', '-?'):
775  self.printUsage()
776  sys.exit(0)
777 
778  #if len(args) < 1:
779  # self.printUsageErr("No input xml file specified")
780  # sys.exit(2)
781  #else:
782  # kwargs['filename'] = args[0]
783 
784  return kwargs
785 
def getOptions(self, argv=None, kwargs)
Get command-line options.
def printUsage(self)
Print Command-Line Usage Message.
Unit test command-line exception class.
def pantilt_console.application.printUsage (   self)

Print Command-Line Usage Message.

Definition at line 738 of file pantilt_console.py.

References pantilt_console.application._Argv0.

Referenced by pantilt_console.application.getOptions().

738  def printUsage(self):
739  print \
740 """
741 usage: %s [OPTIONS]
742  %s --help
743 
744 Options and arguments:
745 
746 -h, --help : Display this help and exit.
747 """ % (self._Argv0, self._Argv0)
748 
def printUsage(self)
Print Command-Line Usage Message.
def pantilt_console.application.printUsageErr (   self,
  emsg 
)

Print usage error.

Parameters
emsgError message string.

Definition at line 730 of file pantilt_console.py.

References pantilt_console.application._Argv0.

730  def printUsageErr(self, emsg):
731  if emsg:
732  print "%s: %s" % (self._Argv0, emsg)
733  else:
734  print "%s: error" % (self._Argv0)
735  print "Try '%s --help' for more information." % (self._Argv0)
736 
def printUsageErr(self, emsg)
Print usage error.
def pantilt_console.application.run (   self,
  argv = None,
  kwargs 
)

Run application.

Parameters
argvOptional argument list to override command-line arguments.
kwargsOptional keyword argument list.
Returns
Exit code.

Definition at line 794 of file pantilt_console.py.

References pantilt_console.application.getOptions(), and pantilt_console.application.m_win.

794  def run(self, argv=None, **kwargs):
795 
796  # parse command-line options and arguments
797  try:
798  kwargs = self.getOptions(argv, **kwargs)
799  except usage, e:
800  print e.msg
801  return 2
802 
803  # create root
804  root = Tk()
805 
806  # create application window
807  self.m_win = window(master=root, **kwargs)
808 
809  root.protocol('WM_DELETE_WINDOW', root.destroy)
810 
811  # loop
812  self.m_win.mainloop()
813 
814  return 0
815 
816 
817 # ------------------------------------------------------------------------------
818 # main
819 # ------------------------------------------------------------------------------
def getOptions(self, argv=None, kwargs)
Get command-line options.
Window class supporting application.
def run(self, argv=None, kwargs)
Run application.

The documentation for this class was generated from the following file: