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.

Saturday, June 7, 2008

Widget Identifier Refactor

The widget identification code was getting to be a bit messy... and was in a place that it really didn't fit.  All of that code has been refactored into a seperate class (and subclasses).  The code is much cleaner now.  Ideally, widget identification would be simple if the set_name() method was called on each and every widget --- but that's a bit much to expect.  

That aside, sugarbot can now identify every individual widget in Calculate.activity.  Unfortunately, there are multiple ways of naming some of the widgets.  For example, Calculate.activity's toolbars.py is responsible for drawing all of the toolbar widgets.  However, some of these have (potentially) multiple names.  In the below example, there are five identifiers that could potentially be used (the five strings used).  Currently, the first one is used, but only because I have not found a way to get at the second one.  It is probably better that the second one is not used, as internationalized text could cause issues with widget identification (the "_()" operator is used in lieu of gettext()).

toolbars.py excerpt:
        self.insert(IconToolButton('algebra-square', _('Square'),
            lambda x: calc.button_pressed(calc.TYPE_OP_POST, '^2'),
            lambda x: calc.button_pressed(calc.TYPE_TEXT, 'help(square)'),
            alt_html='x2'), -1)

Log excerpt showing identified widgets:
Tracking widget id 146431428 by identifier sugarbot Activity
Tracking widget id 146431748 by identifier sugar+graphics+toolcombobox+ToolComboBox
Tracking widget id 146431908 by identifier Keep
Tracking widget id 146474524 by identifier Stop
Tracking widget id 146475644 by identifier edit-copy
Tracking widget id 146476964 by identifier edit-paste
Tracking widget id 146482316 by identifier edit-cut
Tracking widget id 146483516 by identifier x2
Tracking widget id 146483636 by identifier √x
Tracking widget id 146484876 by identifier x-1
Tracking widget id 146484916 by identifier ex
Tracking widget id 147261556 by identifier xy
Tracking widget id 147262876 by identifier algebra-ln
Tracking widget id 147262916 by identifier algebra-fac
Tracking widget id 147272364 by identifier trigonometry-sin
Tracking widget id 147273604 by identifier trigonometry-cos
Tracking widget id 147274964 by identifier trigonometry-tan
Tracking widget id 147285612 by identifier trigonometry-asin
Tracking widget id 147286892 by identifier trigonometry-acos
Tracking widget id 147286852 by identifier trigonometry-atan
Tracking widget id 147297620 by identifier trigonometry-sinh
Tracking widget id 147298900 by identifier trigonometry-cosh
Tracking widget id 147300220 by identifier trigonometry-tanh
Tracking widget id 147300180 by identifier boolean-and
Tracking widget id 147310948 by identifier boolean-or
Tracking widget id 147312228 by identifier boolean-eq
Tracking widget id 147312268 by identifier boolean-neq
Tracking widget id 147322876 by identifier π
Tracking widget id 147324116 by identifier constants-e
Tracking widget id 147330788 by identifier Deg
Tracking widget id 147337740 by identifier enter
Tracking widget id 147337660 by identifier )
Tracking widget id 147337580 by identifier /
Tracking widget id 147337500 by identifier *
Tracking widget id 147337420 by identifier (
Tracking widget id 147332148 by identifier -
Tracking widget id 147332228 by identifier +
Tracking widget id 147333028 by identifier clear
Tracking widget id 147332948 by identifier .
Tracking widget id 147332868 by identifier 0
Tracking widget id 147332788 by identifier 3
Tracking widget id 147332708 by identifier 2
Tracking widget id 147332628 by identifier 1
Tracking widget id 147332548 by identifier 6
Tracking widget id 147332468 by identifier 5
Tracking widget id 147332388 by identifier 4
Tracking widget id 147332308 by identifier 9
Tracking widget id 147331988 by identifier 8
Tracking widget id 147332188 by identifier 7
Tracking widget id 147331828 by identifier calcMainEntry
Tracking widget id 147332028 by identifier Label
Tracking widget id 147337820 by identifier All equations
Tracking widget id 147337900 by identifier Show history
Tracking widget id 139099748 by identifier SugarActivity

No comments: