#!/usr/bin/python #------------------------------------------------------------ # Family History gui for gnuMed gui-demo # Richard Terry 01March05 #------------------------------------------------------------- import wx import gmGuiElement_DividerCaptionPanelwx25 #panel class to display sub-headings or divider headings import editarealabel richards_blue = wx.Colour(0,0,131) richards_aqua = wx.Colour(0,194,197) ID_PRINTPI = wx.NewId() ID_CLOSEPI = wx.NewId() ID_MEMBERCONDITIONSLIST = wx.NewId() ID_FAMILYMEMBERSLIST = wx.NewId() ID_IMMUNISATIONS = wx.NewId() ID_ALL_MENU = wx.NewId() gmSECTION_FAMILYHISTORY = 4 familymemberdata = { 1 : ("Mother",""), 2 : ("General Family History",""), 3 : ("Freda -Aunt",""), } membersconditionsdata = { 1 : ("Acute myocardial infarction aged 73, caused death 73",""), 2 : ("Hypertension age onset 40",""), } class FamilyHistoryEditAreaPanel (wx.Panel): def __init__(self, parent, id): wx.Panel.__init__(self, parent, id,wx.DefaultPosition,wx.DefaultSize,wx.RAISED_BORDER) #--------------------------------------------------------------------------------------------------------------------------------------- #Creates labels, textboxes etc for the data entry area of the family and social history module #consists of heading panel # family history editing area for data entry # heading of family history members # lists of family members and disease # heading for social history # social history text box entry #---------------------------------------------------------------------------------------------------------------------------------------- self.sizer_line1 = wx.BoxSizer(wx.HORIZONTAL) self.sizer_line2 = wx.BoxSizer(wx.HORIZONTAL) self.sizer_line3 = wx.BoxSizer(wx.HORIZONTAL) self.sizer_line4 = wx.BoxSizer(wx.HORIZONTAL) self.sizer_line5 = wx.BoxSizer(wx.HORIZONTAL) self.sizer_line6 = wx.BoxSizer(wx.HORIZONTAL) self.sizer_line7 = wx.BoxSizer(wx.HORIZONTAL) self.label1 = editarealabel.Label(self,-1," Person's name",richards_aqua) self.label1.SetForegroundColour(richards_blue) self.label2 = editarealabel.Label(self,-1," Relationship",richards_blue) self.label3 = editarealabel.Label(self,-1," Condition",richards_blue) self.label4 = editarealabel.Label(self,-1," Comment",richards_blue) self.label5 = editarealabel.Label(self,-1," Age Noted",richards_blue) self.label6 = editarealabel.Label(self,-1," Died of this",richards_blue) self.label7 = editarealabel.Label(self,-1," Progress Notes",richards_blue) self.label8 = editarealabel.Label(self,-1," Date of Birth",richards_blue) self.label9 = editarealabel.Label(self,-1," Age of Death",richards_blue) self.label10 = wx.StaticText(self,-1,"") self.txt_name = wx.TextCtrl(self,-1) self.txt_relationship = wx.TextCtrl(self,-1) self.txt_condition = wx.TextCtrl(self,-1) self.txt_comment = wx.TextCtrl(self,-1) self.txt_agenoted = wx.TextCtrl(self,-1) self.txt_causeofdeath = wx.TextCtrl(self,-1) self.txt_ageofdeath = wx.TextCtrl(self,-1) self.txt_progressnotes = wx.TextCtrl(self,-1) self.txt_dateofbirth = wx.TextCtrl(self,-1) self.rb_conditionconfidential = wx.RadioButton(self, 32, " Confidential ", wx.DefaultPosition,wx.DefaultSize) self.sizer_line1.Add(self.label1,3,wx.EXPAND|wx.LEFT,2) #family member name + DOB self.sizer_line1.Add((5,1),0) self.sizer_line1.Add(self.txt_name,5,wx.EXPAND) self.sizer_line1.Add((2,1),0) self.sizer_line1.Add(self.label8,3,wx.EXPAND|wx.TOP,2) self.sizer_line1.Add((2,1),0) self.sizer_line1.Add(self.txt_dateofbirth,2,wx.EXPAND) self.sizer_line2.Add(self.label2,3,wx.EXPAND|wx.LEFT,2) #family relationship and age of death self.sizer_line2.Add((5,1),0) self.sizer_line2.Add(self.txt_relationship,5,wx.EXPAND) self.sizer_line2.Add((2,1),0) self.sizer_line2.Add(self.label9,3,wx.EXPAND) self.sizer_line2.Add((2,1),0) self.sizer_line2.Add(self.txt_ageofdeath,2,wx.EXPAND) self.sizer_line3.Add(self.label3,3,wx.EXPAND|wx.LEFT,2) #condition and confidential radiobutton self.sizer_line3.Add((5,1),0) self.sizer_line3.Add(self.txt_condition,5,wx.EXPAND) self.sizer_line3.Add((2,1),0) self.sizer_line3.Add(self.rb_conditionconfidential,5,wx.EXPAND) self.sizer_line3.Add((2,1),0) self.sizer_line4.Add(self.label4,3,wx.EXPAND|wx.LEFT,2) #comment self.sizer_line4.Add((5,1),0) self.sizer_line4.Add(self.txt_comment,10,wx.EXPAND) self.sizer_line4.Add((2,1),0) self.sizer_line5.Add(self.label5,3,wx.EXPAND|wx.LEFT,2) #age noted self.sizer_line5.Add((5,1),0) self.sizer_line5.Add(self.txt_agenoted,2,wx.EXPAND) self.sizer_line5.Add((1,1),8) self.sizer_line6.Add(self.label6,3,wx.EXPAND|wx.LEFT,2) #died of this self.sizer_line6.Add((5,1),0) self.sizer_line6.Add(self.txt_causeofdeath,2,wx.EXPAND) self.sizer_line6.Add((1,1),8) self.sizer_line7.Add(self.label7,3,wx.EXPAND|wx.LEFT,2) #progress notes textbox self.sizer_line7.Add((5,1),0) self.sizer_line7.Add(self.txt_progressnotes,10,wx.EXPAND) self.sizer_line7.Add((2,1),0) #---------------------------------------------------------------------------------- #Underneath the editing area add buttons OK and Clear #---------------------------------------------------------------------------------- self.btn_nextcondition = wx.Button(self,-1,"Next Condition") self.btnOK = wx.Button(self,-1,"Ok") self.btnClear = wx.Button(self,-1,"Clear") self.sizer_buttons = wx.BoxSizer(wx.HORIZONTAL) #holds all buttons on last line self.sizer_buttons.Add(self.btn_nextcondition,1,wx.EXPAND) self.sizer_buttons.Add((100,1),0) self.sizer_buttons.Add(self.btnOK,1,wx.EXPAND) #|wx.ALL,1) self.sizer_buttons.Add((10,1),0) self.sizer_buttons.Add(self.btnClear,1,wx.EXPAND) #|wx.ALL,1) self.sizer_lastline = wx.BoxSizer(wx.HORIZONTAL) self.sizer_lastline.Add(self.label10, 3,wx.EXPAND) self.sizer_lastline.Add((10,1),0) self.sizer_lastline.Add(self.sizer_buttons,10,wx.EXPAND)#|wx.ALL,2) #add all lines to the 8 row grid sizer self.gs = wx.GridSizer(6,1,0,0) self.gs.Add(self.sizer_line1,0,wx.EXPAND) self.gs.Add(self.sizer_line2,0,wx.EXPAND) self.gs.Add(self.sizer_line3,0,wx.EXPAND) self.gs.Add(self.sizer_line4,0,wx.EXPAND) self.gs.Add(self.sizer_line5,0,wx.EXPAND) self.gs.Add(self.sizer_line6,0,wx.EXPAND) self.gs.Add(self.sizer_line7,0,wx.EXPAND) #to the main background sizer, add the gridsizer + row of buttons self.mainsizer = wx.BoxSizer(wx.VERTICAL) self.mainsizer.Add(self.gs,6,wx.EXPAND) self.mainsizer.Add(self.sizer_lastline,1,wx.EXPAND|wx.TOP|wx.BOTTOM,2) self.SetSizer(self.mainsizer) self.Fit() self.Show(True) class FamilyHistoryPanel(wx.Panel): """ This is the central panel for the vaccination section The gui contains section heading vaccination editing area for data entry heading for vaccine lists lists of vaccine schedules and corresponding vaccines heading for missing immunisations description of missing immunisations """ def __init__(self, parent,id): wx.Panel.__init__(self, parent, id,wx.DefaultPosition,wx.DefaultSize,wx.NO_BORDER) self.SetBackgroundColour(wx.Color(230,230,230)) self.InitGui() self.BindEvents() self.Show(True) def InitGui(self): self.sizer_main = wx.BoxSizer(wx.VERTICAL) self.InitGui_PanelHeading() self.InitGui_DataEntryArea() self.InitGui_FamilyMemberList() self.InitGui_SocialHistory() self.InitGui_DummyData() self.SetAutoLayout(True) self.SetSizer(self.sizer_main) self.sizer_main.Fit(self) def BindEvents(self): pass def InitGui_DummyData(self): pass def InitGui_PanelHeading(self): self.sectionheading = gmGuiElement_DividerCaptionPanelwx25.DividerCaptionPanel(self,-1,"Family and Social History") self.sizer_main.Add(self.sectionheading,0,wx.EXPAND) def InitGui_DataEntryArea(self): """ Create the top part of the GUI containg the editing area prompts and data entry textboxes """ self.editarea = FamilyHistoryEditAreaPanel(self,-1) self.sizer_main.Add((0,10),0) self.sizer_main.Add(self.editarea,4,wx.EXPAND) def InitGui_FamilyMemberList(self): """ Build the list of family members and their conditions """ self.family_member_heading = gmGuiElement_DividerCaptionPanelwx25.DividerCaptionPanel(self,-1,"Family Member") self.members_condition_heading = gmGuiElement_DividerCaptionPanelwx25.DividerCaptionPanel(self,-1,"Condition") self.sizer_divider_member_condition_heading = wx.BoxSizer(wx.HORIZONTAL) self.sizer_divider_member_condition_heading.Add(self.family_member_heading,1, wx.EXPAND) self.sizer_divider_member_condition_heading.Add( self.members_condition_heading,1, wx.EXPAND) #------------------------------------------------------------------------------------------------- #add the lists to contain the vaccine schedules and vaccines given #------------------------------------------------------------------------------------------------- self.family_member_list = wx.ListCtrl(self, ID_FAMILYMEMBERSLIST, wx.DefaultPosition, wx.DefaultSize,wx.LC_REPORT|wx.LC_NO_HEADER|wx.SUNKEN_BORDER) self.family_member_list.SetFont(wx.Font(10,wx.SWISS, wx.NORMAL, wx.NORMAL, False, '')) self.members_condition_list = wx.ListCtrl(self, ID_MEMBERCONDITIONSLIST, wx.DefaultPosition, wx.DefaultSize,wx.LC_REPORT|wx.LC_NO_HEADER|wx.SUNKEN_BORDER) self.members_condition_list.SetFont(wx.Font(10,wx.SWISS, wx.NORMAL, wx.NORMAL, False, '')) self.sizer_member_condition = wx.BoxSizer(wx.HORIZONTAL) self.sizer_member_condition.Add(self.family_member_list,4,wx.EXPAND) self.sizer_member_condition.Add(self.members_condition_list,6, wx.EXPAND) #---------------------------------------------------------------- # add some dummy data to the Schedule list #---------------------------------------------------------------- self.family_member_list.InsertColumn(0, "Member") self.family_member_list.InsertColumn(1, "null") #------------------------------------------------------------- #loop through the familymemberdata array and add to the list control #note the different syntax for the first coloum of each row #i.e. here > self.family_member_list.InsertStringItem(x, data[0])!! #------------------------------------------------------------- items = familymemberdata.items() for x in range(len(items)): key, data = items[x] print items[x] self.family_member_list.InsertStringItem(x, data[0]) self.family_member_list.SetItemData(x, key) self.family_member_list.SetColumnWidth(0, wx.LIST_AUTOSIZE) #---------------------------------------------------------------- # add some dummy data to the vaccines list #---------------------------------------------------------------- self.members_condition_list.InsertColumn(0, "Condition") self.members_condition_list.InsertColumn(1, "null") #------------------------------------------------------------- #loop through the familymemberdata array and add to the list control #note the different syntax for the first coloum of each row #i.e. here > self.family_member_list.InsertStringItem(x, data[0])!! #------------------------------------------------------------- items = membersconditionsdata.items() for x in range(len(items)): key, data = items[x] print items[x] self.members_condition_list.InsertStringItem(x, data[0]) self.members_condition_list.SetStringItem(x, 1, data[1]) self.members_condition_list.SetItemData(x, key) self.members_condition_list.SetColumnWidth(0, wx.LIST_AUTOSIZE) self.members_condition_list.SetColumnWidth(1, wx.LIST_AUTOSIZE) #--------------------------------------------------------------------------- #finally add all the gui components to the back sizer #--------------------------------------------------------------------------- self.sizer_vaccines = wx.BoxSizer(wx.VERTICAL) self.sizer_vaccines.Add(self.sizer_divider_member_condition_heading,0,wx.EXPAND) #heading- Schedules/vaccines self.sizer_vaccines.Add(self.sizer_member_condition,4,wx.EXPAND) #lists schedules/vaccines self.sizer_main.Add(self.sizer_vaccines,4,wx.EXPAND) #add to main panel sizer def InitGui_SocialHistory(self): #-------------------------------------------------------------------------------------- #add a richtext control or a wx.TextCtrl multiline to display the class text information #e.g. would contain say information re the penicillins #-------------------------------------------------------------------------------------- self.social_history_subheading = gmGuiElement_DividerCaptionPanelwx25.DividerCaptionPanel(self,-1,"Social History") self.txt_social_history = wx.TextCtrl(self, 30, "Born in QLD, son of an itinerant drover. Mother worked as a bush nurse. " "Two brothers, Fred and Peter. Left school aged 15yrs, apprentice fitter " "then worked in industry for 10ys. At 22yrs age married Joan, two children" "Peter b1980 and Rachaelb1981. Retired in 1990 due to receiving a fortune.", wx.DefaultPosition,wx.DefaultSize, style=wx.TE_MULTILINE|wx.NO_3D|wx.SIMPLE_BORDER) self.txt_social_history.SetInsertionPoint(0) self.txt_social_history.SetFont(wx.Font(10,wx.SWISS, wx.NORMAL, wx.NORMAL, False, '')) self.mainsizer = wx.BoxSizer(wx.VERTICAL) self.mainsizer.Add(self.social_history_subheading,0,wx.EXPAND) self.mainsizer.Add(self.txt_social_history,4,wx.EXPAND) self.sizer_main.Add(self.mainsizer,4,wx.EXPAND) def EditArea_btnClear_Clicked(self,evt): self.editarea.txt_member.Clear() # etc print 'Im clearing the edit area' def EditArea_btnOK_Clicked(self,evt): newvaccineitem = {} pass if __name__ == "__main__": app = wx.PyWidgetTester(size = (600, 600)) app.SetWidget(FamilyHistoryPanel, -1) app.MainLoop()