Thursday, July 01, 2010

GNUmed plugin development - easy testing of plugin

Developing a plugin is no magic. We have received a report by a university student that he was able to get a plugin developed and running from the documentation we provide. He intentionally does not ask any questions but tries to dig through the documentation (blog, wiki, source code comments) to find out how everything plays together.

In one of the last articles it was demonstrated how to display a plugin. While it is nice to see your plugin in GNUmed often you don't want to start up all of GNUmed just to test your plugin.

Python comes with batteries included. Each client plugin can be started standalone through a helper called pywidgettester. This is implemented in the ExamplePlugin aleready.

Just start the plugin like this
cd ./client/wxpython/gui
It will ask for the server it should connect to, the database it should connect to, the username and the password. Once it has connected it lets you search for a patient. Then it will display this:

These lines in a plugin make this possible
if __name__ == '__main__':

        # GNUmed
        from import gmPerson
        from Gnumed.wxpython import gmPatSearchWidgets"starting template plugin...")

                # obtain patient
                patient = gmPerson.ask_for_patient()
                if patient is None:
                        print "None patient. Exiting gracefully..."

                # display the plugin standalone
                application = wx.wx.PyWidgetTester(size = (800,600))
                widgets = gmExamplePluginWidgets.cExamplePluginPnl(application.frame, -1)


Happy coding

No comments: