gnumed-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gnumed-devel] GNUmed plugin development - easy testing of plugin


From: Sebastian Hilbert
Subject: [Gnumed-devel] GNUmed plugin development - easy testing of plugin
Date: Thu, 1 Jul 2010 15:13:26 +0200
User-agent: KMail/1.13.3 (Linux/2.6.33-6-desktop; KDE/4.4.3; i686; ; )

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
python gmExamplePlugin.py

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:

see attachement

These lines in a plugin make this possible

#================================================================
# MAIN
#----------------------------------------------------------------
if __name__ == '__main__':

        # GNUmed
        from Gnumed.business import gmPerson
        from Gnumed.wxpython import gmPatSearchWidgets

        _log.info("starting template plugin...")

        try:
                # obtain patient
                patient = gmPerson.ask_for_patient()
                if patient is None:
                        print "None patient. Exiting gracefully..."
                        sys.exit(0)
                gmPatSearchWidgets.set_active_patient(patient=patient)

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

                application.frame.Show(True)
                application.MainLoop()


Happy coding

Attachment: pywidgettester.png
Description: PNG image


reply via email to

[Prev in Thread] Current Thread [Next in Thread]