gnumed-devel
[Top][All Lists]
Advanced

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

[Gnumed-devel] GNUmed plugin development - part 6


From: Sebastian Hilbert
Subject: [Gnumed-devel] GNUmed plugin development - part 6
Date: Thu, 9 Apr 2009 12:52:32 +0200
User-agent: KMail/1.11.1 (Linux/2.6.22.19-0.2-default; KDE/4.2.1; i686; ; )

The goal for today is to get our mockup GUI displayed within GNUmed. There 
will be no database connection but at least it will display (hopefully).

I selected 
/home/user/sources/gnumed/gnumed/client/wxGladeWidgets/wxgCardiacDevicePluginPnl.py
 
and pressed 'generate code'.

This code cannot be simply run inside GNUmed so I need to find out how GNUmed 
makes use of the code inside its plugins. There is a slight chance that this 
is documented in the development section of the GNUmed wiki. There seems to be 
no relevant information so I will try to piece it togehter and document it.

There are example plugins. Let's take a look and learn from there. The names 
of the plugins to load are stored in the database.

see attachement

I reason since I got some code from existing plugins I should look there. The 
file is called gmShowMedDocs.py. I copied that file to 
gmCardiacDevicePlugin.py.

Now it is time to run a local instance of GNUmed and a local database. You 
should really install it now. Do not try to cut corners by not bootstraping a 
local database. We need that to work on our plugin.

I recommend you run GNUmed via the script gm-from-cvs.sh in the CVS source 
tree and bootstrap a database from the CVS tree as well. Change to the 
server/bootstrap directory and run bootstrap-latest.sh. Extensive information 
is available here and here.

Be aware that the source code in a CVS tree is a moving target. You might want 
to consider getting the source for the stable version 0.4.2 and server v10. 
All files mentioned before like the wxg files and the renamed plugin file 
should be created in that cvs directory then. The benefit is that your plugin 
will be developed against the latest stable version.

However if your plugin requires database changes there is no way around using 
the latest development code since changes to the database made against the 
stable version might not work with the latest development code.

I did not run into trouble but if you do don't hesitate to contact gnumed-
address@hidden

I started GNUmed (from CVS) with the local database (v11) and added my new 
plugin (still containing the SOAP stuff) to the database. GNUmed evidently 
scans the directory foo/gnumed/client/wxpython/gui for available plugins. If 
the file is there it will show up for activiation. I activated it from within 
GNUmed via 'Office' > 'manage master data' > 'Workplace profiles'.

GNUmed does not show it immediately. A restart of GNUmed is neccessary. The 
plugin does does not show up and throws an error in the log file.

    Traceback (most recent call last):
    File "/home/basti/sources/gnumed/gnumed/Gnumed/wxpython/gmHorstSpace.py", 
line 121, in __load_plugins
    plugin = gmPlugin.instantiate_plugin('gui', curr_plugin)
    File "/home/basti/sources/gnumed/gnumed/Gnumed/wxpython/gmPlugin.py", line 
333, in instantiate_plugin
    plugin_class = module_from_package.__dict__[plugin_name]
    KeyError: u'gmCardiacDevicePlugin'

This is due to the fact that the class name and the file name 
(gmCardiacDevicePlugin) due not match. Open the file and change the class 
name.

    class gmCardiacDevicePlugin(gmPlugin.cNotebookPlugin):
    """Plugin to encapsulate document tree."""

    tab_name = _("Documents")

    def name (self):
    return gmCardiacDevicePlugin.tab_name

The section 'Menu Info' is responsible for the name of the plugin in the 
GNUmed menu. I changed it like this.

    class gmCardiacDevicePlugin(gmPlugin.cNotebookPlugin):
    """Plugin to encapsulate document tree."""

    tab_name = _("Documents")

    def name (self):
    return gmCardiacDevicePlugin.tab_name
    #--------------------------------------------------------
    def GetWidget (self, parent):
    self._widget = gmMedDocWidgets.cSelectablySortedDocTreePnl(parent, -1)
    return self._widget
    #--------------------------------------------------------
    def MenuInfo (self):
    return ('tools', _('Show &cardiac devices'))


I restarted GNUmed and saw two Document plugins. Next step is to load my GUI 
instead of the Document archive stuff. The line starting self._widget = ' ' 
needs to be changed.

But this will be the next part of our journey towards a GNUmed plugin. So far 
it wasn't that hard and I learned quite a bit where files are located in the 
source tree , what files are involved in creating a plugin and how to add a 
plugin to the workplace in a database.

Attachment: cfg_str_array.png
Description: PNG image


reply via email to

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