Gnumed.wxpython.gmGP_HabitsRiskFactors

Package Gnumed :: Package wxpython :: Module gmGP_HabitsRiskFactors |
[frames] | no frames]

# Source Code for Module Gnumed.wxpython.gmGP_HabitsRiskFactors

     1  import wx
     2
     3 -class HabitsRiskFactors(wx.Panel):
     4 -    def __init__(self, parent,id):
     5          wx.Panel.__init__(self, parent, id, wx.DefaultPosition, wx.DefaultSize, 0 )
     6          sizer = wx.BoxSizer(wx.VERTICAL)
     7
     8          #captions for the two columns
     9          #habit_caption = gmTerryGuiParts..cDividerCaption(self,-1,"Habits")
    10          #risk_caption = gmTerryGuiParts.cDividerCaption(self,-1,"Risk Factors")
    11
    12          #text controls for each column
    13          txt_habits = wx.TextCtrl(self, 30,
    14                          "Smoker - 30/day.\n"
    15                          "Alcohol - 30gm/day (Previously very heavy.\n",
    16                                wx.DefaultPosition,wx.DefaultSize, style=wxTE_MULTILINE|wx.NO_3D|wx.SIMPLE_BORDER)
    17          txt_habits.SetInsertionPoint(0)
    18
    19          txt_riskfactors = wx.TextCtrl(self,30,
    20                               "Hypercholesterolaemia \n"
    21                               "Current Smoker \n"
    22                               "NIDDM \n"
    23                               "No exercise data recorded\n",
    24                                wx.DefaultPosition,wx.DefaultSize, style = wx.TE_MULTILINE)
    25          txt_riskfactors.SetInsertionPoint(0)
    26          #heading sizer- add headings
    27          #heading_sizer = wx.BoxSizer(wxHORIZONTAL)
    28          #heading_sizer.Add(habit_caption,1,wxEXPAND)
    29          #heading_sizer.Add(risk_caption,1,wxEXPAND)
    30          #self.SetSizer(heading_sizer)  #set the sizer
    31          #heading_sizer.Fit(self)             #set
    32          ##text sizer - add text
    33          text_sizer = wx.BoxSizer(wx.HORIZONTAL)
    34          text_sizer.Add(txt_habits,1,wx.EXPAND)
    35          text_sizer.Add(txt_riskfactors,1,wx.EXPAND)
    36          self.SetSizer(text_sizer)  #set the sizer
    37          text_sizer.Fit(self)             #set
    38          self.SetAutoLayout(True)                 #tell frame to use the sizer
    39          #self.Show(True)
    40
    41          self.lists = { 'habit': txt_habits, 'risk': txt_riskfactors }
    42
    43          print self.GetData()
    44
    45          self.SetData( { 'habit': ['smoker', 'drinks 20/day'] , 'risk': [ 'cholesterol', 'diabetes'] } )
    46
    47 -    def getTextCtrl(self, which):
    48                  return self.lists.get(which, "risk")
    49
    50 -    def SetData(self, map):
    51                  for which, data in map.items():
    52                          if type(data) == type(""):
    53                                  self.lists.get(which, 'risk').SetValue(data)
    54
    55                          if type(data) in [ type([]), type ( () ) ]:
    56                                  self.lists.get(which, 'risk').SetValue("\n".join(data))
    57
    58 -    def GetData(self):
    59                  map = {}
    60                  for k in self.lists:
    61                          map[k] = self.lists[k].GetValue().split('\n')
    62                  return map
    63
    64
    65  if __name__ == "__main__":
    66          app = wxPyWidgetTester(size = (400, 200))
    67          app.SetWidget(HabitsRiskFactors, -1)
    68          app.MainLoop()
    69