Trees | Indices | Help |
|
---|
|
1 """gmPlugin_Patient - base classes for GNUMed's patient plugin architecture. 2 3 @copyright: author 4 @license: GPL (details at http://www.gnu.org) 5 """ 6 ############################################################################ 7 # $Source: /cvsroot/gnumed/gnumed/gnumed/client/wxpython/gmPlugin_Patient.py,v $ 8 # $Id: gmPlugin_Patient.py,v 1.12 2009/07/17 09:26:53 ncq Exp $ 9 __version__ = "$Revision: 1.12 $" 10 __author__ = "H.Herb, I.Haywood, K.Hilbert" 11 12 import os, sys, re, cPickle, zlib 13 14 import wx 15 16 from Gnumed.pycommon import gmExceptions, gmGuiBroker, gmCfg 17 from Gnumed.wxpython import gmShadow 18 19 gmPerson = None 20 _log = gmLog.gmDefLog 21 _log.Log(gmLog.lInfo, __version__) 22 23 #------------------------------------------------------------------25 """Base class for all plugins providing wxPython widgets. 26 27 Plugins must have a class descending of this class in 28 their file, which MUST HAVE THE SAME NAME AS THE FILE. 29 30 The file must be in a directory which is loaded by 31 LoadPluginSet (gui/ for the moment, others may be 32 added for different plugin types) 33 """ 34 # NOTE: I anticipate that all plugins will in fact be derived 35 # from this class. Without the brokers a plugin is useless (IH)118 #------------------------------------------------------------------37 self.gb = guibroker 38 self.cb = callbackbroker 39 if self.gb is None: 40 self.gb = gmGuiBroker.GuiBroker() 41 self.set = set42 #-----------------------------------------------------44 """Return icon representing page on the toolbar. 45 46 This is the default behaviour. GetIconData should return 47 pickled, compressed and escaped string with the icon data. 48 49 If you want to change the behaviour (because you want to load 50 plugin icons from overseas via a satellite link or something 51 you need to override this function in your plugin (class). 52 53 Using this standard code also allows us to only import cPickle 54 and zlib here and not in each and every plugin module which 55 should speed up plugin load time :-) 56 """ 57 # FIXME: load from config which plugin we want 58 # which_icon is a cookie stored on the backend by a config manager, 59 # it tells the plugin which icon to return data for, 60 which_icon = None 61 icon_data = self.GetIconData(which_icon) 62 if icon_data is None: 63 return None 64 else: 65 return wx.BitmapFromXPMData(cPickle.loads(zlib.decompress(icon_data)))66 #-----------------------------------------------------68 # FIXME: in overriding methods need to be very careful about the 69 # type of the icon ID since if we read it back from the database we 70 # may not know what type it was 71 return None72 #-----------------------------------------------------74 """ 75 Return the widget to display. Usually called from 76 register(). The instance returned is the 77 active object for event handling purposes. 78 """ 79 raise gmExceptions.PureVirtualFunction()80 #-----------------------------------------------------82 """Return tuple of (menuname, menuitem). 83 84 menuname can be 85 "tools", 86 "view", 87 "help", 88 "file" 89 90 If you return "None" no entry will be placed 91 in any menu. 92 """ 93 raise gmExceptions.PureVirtualFunction()94 #-----------------------------------------------------96 """Raises this plugin to the top level if not visible. 97 """ 98 raise gmExceptions.PureVirtualFunction()99 #----------------------------------------------------- 104 #-----------------------------------------------------106 # register ANY type of plugin, regardless of where plugged in 107 # we may be able to do away with this once we don't do 108 # several types of plugins anymore, as we should 109 self.gb['modules.%s' % self.set][self.__class__.__name__] = self # split/renamed 'horstspace.notebook.%s' 110 _log.Log(gmLog.lInfo, "plugin: [%s] (class: [%s]) set: [%s]" % (self.name(), self.__class__.__name__, self.set))111 #-----------------------------------------------------113 del self.gb['modules.%s' % self.set][self.__class__.__name__] # split/renamed 'horstspace.notebook.%s' 114 _log.Log(gmLog.lInfo, "plugin: [%s] (class: [%s]) set: [%s]" % (self.name(), self.__class__.__name__, self.set))115 #-----------------------------------------------------120 """ 121 A 'small page', sits inside the patient view, with the side visible 122 """170 171 #================================================================== 172 # Main 173 #------------------------------------------------------------------ 174 if __name__ == '__main__': 175 print "please write a unit test" 176 177 #================================================================== 178 # $Log: gmPlugin_Patient.py,v $ 179 # Revision 1.12 2009/07/17 09:26:53 ncq 180 # - no more main.frame in gui broker 181 # 182 # Revision 1.11 2008/03/06 18:29:29 ncq 183 # - standard lib logging only 184 # 185 # Revision 1.10 2006/10/08 11:07:20 ncq 186 # - wean off gmPG 187 # 188 # Revision 1.9 2006/08/04 05:44:12 ncq 189 # - fix class name wx.BasePlugin 190 # 191 # Revision 1.8 2006/07/19 20:29:50 ncq 192 # - import cleanup 193 # 194 # Revision 1.7 2006/05/12 12:18:11 ncq 195 # - whoami -> whereami cleanup 196 # - use gmCurrentProvider() 197 # 198 # Revision 1.6 2005/09/28 21:27:30 ncq 199 # - a lot of wx2.6-ification 200 # 201 # Revision 1.5 2005/09/28 15:57:48 ncq 202 # - a whole bunch of wx.Foo -> wx.Foo 203 # 204 # Revision 1.4 2005/09/26 18:01:51 ncq 205 # - use proper way to import wx26 vs wx2.4 206 # - note: THIS WILL BREAK RUNNING THE CLIENT IN SOME PLACES 207 # - time for fixup 208 # 209 # Revision 1.3 2005/01/31 10:37:26 ncq 210 # - gmPatient.py -> gmPerson.py 211 # 212 # Revision 1.2 2004/07/24 17:21:49 ncq 213 # - some cleanup, also re from wxPython import wx 214 # - factored out Horst space layout manager into it's own 215 # wx.Panel child class 216 # - subsequently renamed 217 # 'main.notebook.plugins' -> 'horstspace.notebook.pages' 218 # 'modules.gui' -> 'horstspace.notebook.gui' (to be renamed horstspace.notebook.plugins later) 219 # - adapt to said changes 220 # 221 # Revision 1.1 2004/06/25 13:28:00 ncq 222 # - logically separate notebook and clinical window plugins completely 223 # 224124 BasePlugin.register (self) 125 self.mwm = self.gb['clinical.manager'] 126 127 # FIXME: do proper config check for shadowing 128 # FIXME: do we always want shadows and set it to 0 width via themes ? 129 shadow = gmShadow.Shadow (self.mwm, -1) 130 widget = self.GetWidget (shadow) 131 shadow.SetContents (widget) 132 self.mwm.RegisterLeftSide (self.__class__.__name__, shadow) 133 134 icon = self.GetIcon () 135 if icon is not None: 136 tb2 = self.gb['toolbar.%s' % 'gmClinicalWindowManager'] 137 #tb2.AddSeparator() 138 self.tool_id = wx.NewId () 139 tool1 = tb2.AddTool( 140 self.tool_id, 141 icon, 142 shortHelpString = self.name() 143 ) 144 wx.EVT_TOOL (tb2, self.tool_id, self.OnTool) 145 menuname = self.name () 146 menu = self.gb['clinical.submenu'] 147 self.menu_id = wx.NewId () 148 menu.Append (self.menu_id, menuname)149 #wx.EVT_MENU (..., self.menu_id, self.OnTool) 150 #----------------------------------------------------- 154 # redundant as cannot access toolbar unless mwm raised 155 #self.gb['modules.gui']['Patient'].Raise () # split/renamed 'horstspace.notebook.%s' 156 #-----------------------------------------------------158 self.gb['modules.gui']['Patient'].Raise() # split/renamed 'horstspace.notebook.%s' 159 self.mwm.Display (self.__class__.__name__)160 #-----------------------------------------------------162 BasePlugin.unregister (self) 163 self.mwm.Unregister (self.__class__.__name__) 164 menu = self.gb['main.submenu'] 165 menu.Delete (menu_id) 166 if self.GetIcon () is not None: 167 tb2 = self.gb['toolbar.%s' % 'gmClinicalWindowManager'] 168 tb2.DeleteTool (self.tool_id) 169 del self.gb['modules.patient'][self.__class__.__name__]
Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Tue Feb 9 04:01:57 2010 | http://epydoc.sourceforge.net |