Package Gnumed :: Package wxpython :: Package gui :: Module gmExportAreaPlugin |
[frames] | no frames]

# Source Code for Module Gnumed.wxpython.gui.gmExportAreaPlugin

      1  # -*- coding: utf-8 -*-
      2  """ This is the Export Area plugin."""
      3
      4  __author__ = "karsten.hilbert@gmx.net"
      5  __license__ = "GPL v2 or later"
      6
      7  #================================================================
      8  import logging
      9
     10
     11  import wx
     12
     13
     14  from Gnumed.wxpython import gmPlugin, gmExportAreaWidgets
     15  from Gnumed.wxpython import gmAccessPermissionWidgets
     16
     17
     18  _log = logging.getLogger('gm.ui')
     19  #================================================================
     20 -class gmExportAreaPlugin(gmPlugin.cNotebookPlugin):
     21          tab_name = _("Export Area")
     22          required_minimum_role = 'limited clinical access'
     23
     24          @gmAccessPermissionWidgets.verify_minimum_required_role (
     25                  required_minimum_role,
     26                  activity = _('loading plugin <%s>') % tab_name,
     27                  return_value_on_failure = False,
     28                  fail_silently = False
     29          )
     30 -        def register(self):
     31                  gmPlugin.cNotebookPlugin.register(self)
     32          #-------------------------------------------------
     33 -        def name (self):
     34                  return gmExportAreaPlugin.tab_name
     35          #--------------------------------------------------------
     36 -        def GetWidget (self, parent):
     37                  self._widget = gmExportAreaWidgets.cExportAreaPluginPnl(parent, -1)
     38                  return self._widget
     39          #--------------------------------------------------------
     40 -        def MenuInfo (self):
     41                  return ('emr', _('E&xport area'))
     42          #--------------------------------------------------------
     43 -        def can_receive_focus(self):
     44                  if not self._verify_patient_avail():
     45                          return None
     46                  return 1
     47          #--------------------------------------------------------
     48 -        def _on_raise_by_signal(self, **kwds):
     49                  if not gmPlugin.cNotebookPlugin._on_raise_by_signal(self, **kwds):
     50                          return False
     51                  try:
     52                          pass
     53                  except KeyError:
     54                          pass
     55                  return True
     56  #================================================================
     57  # MAIN
     58  #----------------------------------------------------------------
     59  if __name__ == '__main__':
     60
     61          # stdlib
     62          import sys
     63          sys.path.insert(0, '../../../')
     64
     65          from Gnumed.pycommon import gmI18N
     66          gmI18N.activate_locale()
     67          gmI18N.install_domain()
     68
     69          # GNUmed
     70          from Gnumed.business import gmPersonSearch
     71          from Gnumed.wxpython import gmPatSearchWidgets
     72
     73          _log.info("starting template plugin...")
     74
     75          try:
     76                  # obtain patient
     77                  patient = gmPersonSearch.ask_for_patient()
     78                  if patient is None:
     79                          print("None patient. Exiting gracefully...")
     80                          sys.exit(0)
     81                  gmPatSearchWidgets.set_active_patient(patient=patient)
     82
     83                  # display the plugin standalone
     84                  application = wx.wx.PyWidgetTester(size = (800,600))
     85                  widgets = gmExamplePluginWidgets.cExamplePluginPnl(application.frame, -1)
     86
     87                  application.frame.Show(True)
     88                  application.MainLoop()
     89
     90                  # clean up
     91                  if patient is not None:
     92                          try:
     93                                  patient.cleanup()
     94                          except:
     95                                  print("error cleaning up patient")
     96          except Exception:
     97                  _log.exception("unhandled exception caught !")
     98                  # but re-raise them
     99                  raise
    100
    101          _log.info("closing example plugin...")
    102