sugarbot's aim is to provide testing and automation facilities for the OLPC Project's Sugar GUI. The project must first identify and evaluate possible implementation options, and then implement the best choice. Although it has a Sugar focus, sugarbot should be easily extensible to other Python-based GUI's.

Tuesday, June 3, 2008

Damnit, Python

Just spent two hours trying to figure out why some code wouldn't do what I wanted to.

class sbTypeCmd(sbCommand):
"""
Types text into an Entry widget or similar widget with a set_text method.
"""
def __init__(self, sbgui, widgetName, params=None):
sbCommand.__init__(self, sbgui, widgetName, params)

def run(self):
print "sbTypeCmd"
widget = self.getWidget()
methodName = "set_text"
if hasattr(widget, methodName):
print "Hasattr"
text = (" ".join(self._params)).split("'")
print "Text: " + text
if len(text) <>
return False
textToType = "'".join(text[1:-2])
getattr(widget, methodName)(textToType)
return True
return False

Flipping indentation.

No comments: