def toPixels( tkCoord ):
      '''Convenience function for inches, cm, mm and pointsToPixels().
      Convert a tkCoord (string appended by 'i', 'c', 'm' or 'p') to pixels.'''
      if isinstance( tkCoord, str ):
         if tkCoord[-1] == 'i':
            return tkMath.inchesToPixels( float(tkCoord[:-1]) )
         elif tkCoord[-1] == 'c':
            return tkMath.cmToPixels( float(tkCoord[:-1]) )
         elif tkCoord[-1] == 'm':
            return tkMath.mmToPixels( float(tkCoord[:-1]) )
         elif tkCoord[-1] == 'p':
            return tkMath.pointsToPixels( float(tkCoord[:-1]) )
         else:
            return float(tkCoord)
      else:
         return tkCoord
Convenience function for inches, cm, mm and pointsToPixels().
      Convert a tkCoord (string appended by 'i', 'c', 'm' or 'p') to pixels.
recipes/Python/552745_tkMath_convert_between_pixels_inches_cm/recipe-552745.py