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

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

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