StoryText naturally only provides support for widgets supported
by the generic frameworks. If your application makes use of custom widgets you will need
to write Python code to tell it what to do with them.
The basic idea is to
provide a file called customwidgetevents.py and set the PYTHONPATH
environment variable to include the directory where it is. (For Java GUIs you need to
set JYTHONPATH instead). You then provide a member called "customEventTypes",
which is a list of pairs of widget types and lists of event classes that can be
applied on them. You then define these event classes in a similar way to the way
they are defined for the standard widgets, and the best approach in the absence
of complete API documentation is to look for something similar in the source and
try to do likewise.
Here's a (very stupid) example for PyGTK:
from usecase.gtktoolkit.simulator.baseevents import SignalEvent
def generate(self, *args):
print "We faked a button click!"
def shouldRecord(self, *args):
print "Refusing to record the button click!"
signalName = "row-inserted"
def connectRecord(self, method):
# Standard name for module containing custom widget events
customEventTypes = [(gtk.Button, [ MyButtonEvent ]),
(gtk.TreeView, [ InsertEvent])]
This code will mess about with how Buttons are handled: it will print a message
every time the replayer generates a click on it, and it will refuse to ever
record such a click.
Meanwhile an additional event monitoring has been
set up for rows being inserted in tree views, which StoryText will ordinarily
ignore as it's done by the program itself rather than the user.
If all you need to do is listen to and generate a signal, just inherit
from SignalEvent and set the signalName. (In this case as the signal was on
the gtk.Model rather than the widget itself we also had to adjust how
to monitor it)
Basically, adding support for custom widgets is much like extending StoryText
itself, beyond the basic hook mechanism above to connect it.