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

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

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