Gnumed.wxpython.patient.gmGP_AnteNatal_3

Package Gnumed :: Package wxpython :: Package patient :: Module gmGP_AnteNatal_3 |
[frames] | no frames]

# Source Code for Module Gnumed.wxpython.patient.gmGP_AnteNatal_3

      1  try:
      2          import wxversion
      3          import wx
      4  except ImportError:
      5          from wxPython import wx
      6          from wxPython import grid
      7
      8  import string
      9
     10  from Gnumed.wxpython import gmGuiElement_HeadingCaptionPanel        #panel class to display top headings
     11  from Gnumed.wxpython import gmGuiElement_DividerCaptionPanel        #panel class to display sub-headings or divider headings
     12  from Gnumed.wxpython import gmGuiElement_AlertCaptionPanel          #panel to hold flashing alert messages
     13  from Gnumed.wxpython import gmPlugin_Patient, gmEditArea
     14
     15  from Gnumed.wxpython.gmPatientHolder import PatientHolder
     16  ID_ANCNOTEBOOK =wxNewId()
     17  #---------------------------------------------------------------------------
     18
     19 -class CustomDataTable(wxPyGridTableBase):
     20      """
     21      """
     22
     23 -    def __init__(self):
     24          wxPyGridTableBase.__init__(self)
     25          #self.log = log
     26
     27          self.colLabels = ['Date', 'Gest','Fundus', 'Girth', 'Presentation', ' FH ',
     28                            '  Urine  ', '  BP  ', 'Weight','       Comment       ']
     29          self.dataTypes = [wxGRID_VALUE_STRING,
     30                            wxGRID_VALUE_STRING,
     31                            wxGRID_VALUE_STRING,
     32                            wxGRID_VALUE_STRING,
     33                            wxGRID_VALUE_CHOICE + ':cephalic,breech,transverse',
     34                            wxGRID_VALUE_CHOICE + ':FMF,FHH',
     35                            wxGRID_VALUE_STRING,
     36                            wxGRID_VALUE_STRING,
     37                            wxGRID_VALUE_STRING,
     38                            wxGRID_VALUE_STRING]
     39
     40          self.data = [
     41              ['20/10/2001', "31", '32',"", 'cephalic', 'FHH', 'NAD', '120/70', '77kg','?UTI msu sent'],
     42              #[1011, "I've got a wicket in my wocket", "wish list", 2, 'other', 0, 0, 0,0],
     43              #[1012, "Rectangle() returns a triangle", "critical", 5, 'all', 0, 0, 0,0]
     44
     45              ]
     46
     47
     48      #--------------------------------------------------
     49      # required methods for the wxPyGridTableBase interface
     50
     51 -    def GetNumberRows(self):
     52          return len(self.data) + 1
     53
     54 -    def GetNumberCols(self):
     55          return len(self.data[0])
     56
     57 -    def IsEmptyCell(self, row, col):
     58          return not self.data[row][col]
     59
     60      # Get/Set values in the table.  The Python version of these
     61      # methods can handle any data-type, (as long as the Editor and
     62      # Renderer understands the type too,) not just strings as in the
     63      # C++ version.
     64 -    def GetValue(self, row, col):
     65          try:
     66              return self.data[row][col]
     67          except IndexError:
     68              return ''
     69
     70 -    def SetValue(self, row, col, value):
     71          try:
     72              self.data[row][col] = value
     73          except IndexError:
     74              # add a new row
     75              self.data.append([''] * self.GetNumberCols())
     76              self.SetValue(row, col, value)
     77
     78              # tell the grid we've added a row
     79              msg = wxGridTableMessage(self,                             # The table
     80                                       wxGRIDTABLE_NOTIFY_ROWS_APPENDED, # what we did to it
     81                                       1)                                # how many
     82
     83              self.GetView().ProcessTableMessage(msg)
     84
     85
     86      #--------------------------------------------------
     87      # Some optional methods
     88
     89      # Called when the grid needs to display labels
     90 -    def GetColLabelValue(self, col):
     91          return self.colLabels[col]
     92
     93      # Called to determine the kind of editor/renderer to use by
     94      # default, doesn't necessarily have to be the same type used
     95      # nativly by the editor/renderer if they know how to convert.
     96 -    def GetTypeName(self, row, col):
     97          return self.dataTypes[col]
     98
     99      # Called to determine how the data can be fetched and stored by the
    100      # editor and renderer.  This allows you to enforce some type-safety
    101      # in the grid.
    102 -    def CanGetValueAs(self, row, col, typeName):
    103          colType = string.split(self.dataTypes[col], ':')[0]
    104          if typeName == colType:
    105              return True
    106          else:
    107              return False
    108
    109 -    def CanSetValueAs(self, row, col, typeName):
    110          return self.CanGetValueAs(row, col, typeName)
    111
    112
    113
    114
    115
    116  #---------------------------------------------------------------------------
    117
    118
    119
    120 -class CustTableGrid(wxGrid):
    121 -    def __init__(self, parent):
    122          wxGrid.__init__(self, parent, -1)
    123
    124          table = CustomDataTable()
    125
    126          # The second parameter means that the grid is to take ownership of the
    127          # table and will destroy it when done.  Otherwise you would need to keep
    128          # a reference to it and call it's Destroy method later.
    129          self.SetTable(table, True)
    130
    131          self.SetRowLabelSize(0)
    132          self.SetMargins(0,0)
    133          self.AutoSizeColumns(True)
    134
    135          EVT_GRID_CELL_LEFT_DCLICK(self, self.OnLeftDClick)
    136
    137
    138
    139      # I do this because I don't like the default behaviour of not starting the
    140      # cell editor on double clicks, but only a second click.
    141 -    def OnLeftDClick(self, evt):
    142          if self.CanEnableCellControl():
    143              self.EnableCellEditControl()
    144
    145
    146  #---------------------------------------------------------------------------
    147 -class AntenatalPanel (wxPanel , PatientHolder):
    148 -     def __init__(self,parent, id):
    149            wxPanel.__init__(self, parent, id,wxDefaultPosition,wxDefaultSize,wxNO_BORDER)
    150            PatientHolder.__init__(self)
    151            self.sizer = wxBoxSizer(wxHORIZONTAL)
    152            self.notebook1 = wxNotebook(self, -1, wxDefaultPosition, wxDefaultSize, style =0)
    153            ListScript_ID = wxNewId()                                                         #can use wxLC_VRULES to put faint cols in list
    154            #self.List_Script = wxListCtrl(self.notebook1, ListScript_ID,  wxDefaultPosition, wxDefaultSize,wxLC_REPORT|wxSUNKEN_BORDER)
    155            #self.List_Script.SetForegroundColour(wxColor(131,129,131))
    156            self.firstvisitpanel = wxPanel(self.notebook1,-1)
    157            self.scanpanel = wxPanel(self.notebook1,-1)
    158            self.grid = CustTableGrid(self.notebook1)
    159            self.notebook1.AddPage(self.firstvisitpanel, "First Visit")
    160            self.notebook1.AddPage(self.grid, "Ante-natal Chart")
    161            self.notebook1.AddPage(self.scanpanel, "Scans")
    162            #self.notebook1.AddPage(self.grid, "Scans")
    163            self.notebook1.SetSelection(0)
    164            self.szr_notebook = wxNotebookSizer(self.notebook1)
    165            self.sizer.AddSizer(self.szr_notebook,1,wxEXPAND)
    166            self.SetSizer(self.sizer)
    167            self.sizer.Fit(self)
    168            self.SetAutoLayout(True)
    169            self.Show(True)
    170
    171
    172 -class gmGP_AnteNatal_3 (gmPlugin_Patient.wxPatientPlugin):
    173          """
    174          Plugin to encapsulate the antenatalcare window
    175          """
    176          __icons = {
    177  """icon-future_mom""":"x\xdam\x90?o\x830\x10\xc5\xf7|\nKNB\x15\x1cd\xc0\x80!\x7fDm`\xac\x87,\xacQ\
    178  \xd4\xa9Q\xe9\xf7\x9f\xea\xf3\xd9Uq\xeb[\xf8\xbd\xf7\xee\x0e\xfb\xe5\xf9\x95\
    179  onI^\x93\\\x92\xa2%y\xb2\xb9\xdf\x12I\x1eD=\xef\x8f\x0fG\xc6\x12-9\x94\xe3\
    180  \x12\xb8\xe5\x927\xc8\x15\xb0\xe6\x9ck\xe4\x03\xf0 \xb5P\xc8[\xe0\x89\x0f\
    181  \xda\xfb\x02\xf3*0G\xd6\xa1\xff\x8a\xfdP\x8e\x8f\xd8?\xea\t\xfd\xcc\xfb\xda\
    182  \xfb\x17\xd7/\x95xE?uy9r\x8d\xfe\x1e\xd8\x92V\xc8\xd4\xfb\xc2\xfb;\xcf\xd2s\
    183  \x1fx\xc0y'\x9c\xaf\x83?\xe3\xbcA\x8f\xe8\xd7\x98ox\x81\xdc\xa2\x0f\xe5\xb8\
    184  \xf1\xbe\xf0>\xb1\xfc\xb6|\xbe;`hNz\xc2\xe19\xb0\x94?\x8f\xdb\x01W\x12\xcaq\
    185  \x01\xac\xa4\n\x979\xbb\xc7\xe0P\x8e\x17\xcfb\x08\xcbH6g\xf3b\xec\xb1\xdf$\
    186  \x88pL\xda\xd3\xadY\x8b\x86R\xbas\xeao1\xa5=\xed\xf7&j?Pz\x89\xdaA\x86E\xd9:\
    187  i\x8e\xa7.^te\xe7\x8e\xe6\xab\x99\x861Vt\xb4\x8c\xb63&\xba\xfeo\x92EI\xc3\
    188  \xaa\xaab\xeb\xa4\xd5\xea\xba\x8a\x92 6\xff$mw\x94\x94\x19\xec\x89\xb7\x9b\
    189  \xd6\x8a<\xfeO\xe3\x0f^3\xfb\x06\xbe\xc9\xae+"
    190  }
    191
    192 -        def name (self):
    193                  return 'Ante-natal'
    194
    195 -        def MenuInfo (self):
    196                  return ('view', '&Ante-natal')
    197
    198 -        def GetIconData(self, anIconID = None):
    199                  if anIconID == None:
    200                          return self.__icons[_("""icon-future_mom""")]
    201                  else:
    202                          if self.__icons.has_key(anIconID):
    203                                  return self.__icons[anIconID]
    204                          else:
    205                                  return self.__icons[_("""icon-future_mom""")]
    206
    207 -        def GetWidget (self, parent):
    208                  return  AntenatalPanel (parent, -1)
    209
    210
    211  if __name__ == "__main__":
    212          app = wxPyWidgetTester(size = (600, 600))
    213          app.SetWidget(AntenatalPanel, -1)
    214          app.MainLoop()
    215