When you create a DirectButton, you simply pass any function you like to its command= keyword parameter. This function will be called when the button is clicked.
For a more advanced feature, with any DirectGui object, you can use the DirectGui bind() method to associate functions with esoteric mouse operations. See this thread for more info on that.
David