Trees | Indices | Help |
|
---|
|
1 #!/usr/bin/env python 2 # -*- coding: UTF-8 -*- 3 # generated by wxGlade 0.4 on Sat Oct 29 16:44:23 2005 4 5 # standard library 6 import os.path 7 8 # 3rd party 9 try: 10 import wxversion 11 import wx 12 import wx.html 13 except ImportError: 14 from wxPython import wx 15 16 # GNUmed modules 17 import Gnumed.pycommon.gmGuiBroker as gmGuiBroker 18 from Gnumed.pycommon import gmI18N 19 20 #===================================================================151 152 154 data = self.disease_list.GetClientData (self.disease_list.GetSelection ()) 155 self.disease_text.SetPage (data['text']) 156 self.image_credit.SetValue (data['source']) 157 fname = os.path.join (self.path, data['basename'] + '.jpg') 158 if os.path.exists (fname): 159 self.jpeg = wx.Image (fname) 160 self.bind_image () 161 else: 162 print "No image available" 16323 # begin wxGlade: DermToolDialog.__init__ 24 kwds["style"] = wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER|wx.MAXIMIZE_BOX|wx.MINIMIZE_BOX|wx.THICK_FRAME 25 wx.Dialog.__init__(self, *args, **kwds) 26 self.population = wx.RadioBox(self, -1, _("Population"), choices=[_("Child"), _("Adult"), _("Elderly")], majorDimension=0, style=wx.RA_SPECIFY_ROWS) 27 self.distribution = wx.RadioBox(self, -1, _("Distribution"), choices=[_("Truncal"), _("Generalised"), _("Face"), _("Hands"), _("Flexural"), _("Sun-exposed")], majorDimension=0, style=wx.RA_SPECIFY_ROWS) 28 self.colouring = wx.RadioBox(self, -1, _("Colouring"), choices=[_("Normal"), _("Pigmented"), _("Depigmented"), _("Erthyema"), _("Purpura")], majorDimension=0, style=wx.RA_SPECIFY_ROWS) 29 self.pattern = wx.RadioBox(self, -1, _("Pattern"), choices=[_("Confluent"), _("Macular"), _("Maculo-Papular"), _("Papular"), _("Bullous")], majorDimension=0, style=wx.RA_SPECIFY_ROWS) 30 self.surface = wx.RadioBox(self, -1, _("Surface"), choices=[_("Skin level"), _("Eroded"), _("Crust"), _("Scale"), _("Exudate")], majorDimension=0, style=wx.RA_SPECIFY_ROWS) 31 self.sensation = wx.RadioBox(self, -1, _("Sensation"), choices=[_("Normal"), _("Itchy"), _("Painful")], majorDimension=0, style=wx.RA_SPECIFY_ROWS) 32 self.time_course = wx.RadioBox(self, -1, _("Occurrence"), choices=[_("Evolving"), _("Sudden")], majorDimension=0, style=wx.RA_SPECIFY_ROWS) 33 self.disease_name = wx.TextCtrl(self, -1, "") 34 self.disease_list = wx.ListBox(self, -1, choices=[]) 35 self.image = wx.Panel(self, -1) 36 self.image_credit = wx.TextCtrl(self, -1, "", style=wx.TE_READONLY) 37 self.disease_text = wx.html.HtmlWindow(self, -1) 38 self.btn_save = wx.Button(self, -1, _("Save")) 39 self.btn_close = wx.Button(self, -1, _("Close")) 40 41 self.__set_properties() 42 self.__do_layout() 43 44 self.Bind(wx.EVT_RADIOBOX, self.search_type, self.population) 45 self.Bind(wx.EVT_RADIOBOX, self.search_type, self.distribution) 46 self.Bind(wx.EVT_RADIOBOX, self.search_type, self.colouring) 47 self.Bind(wx.EVT_RADIOBOX, self.search_type, self.pattern) 48 self.Bind(wx.EVT_RADIOBOX, self.search_type, self.surface) 49 self.Bind(wx.EVT_RADIOBOX, self.search_type, self.sensation) 50 self.Bind(wx.EVT_RADIOBOX, self.search_type, self.time_course) 51 self.Bind(wx.EVT_TEXT, self.search_text, self.disease_name) 52 self.Bind(wx.EVT_LISTBOX, self.open_disease, self.disease_list) 53 self.Bind(wx.EVT_BUTTON, self.save, self.btn_save) 54 self.Bind(wx.EVT_BUTTON, self.close, self.btn_close) 55 # end wxGlade 56 self.Bind(wx.EVT_CLOSE, self.close, self) 57 self.Bind(wx.EVT_SIZE, self.bind_image, self.image) 58 self.gb = gmGuiBroker.GuiBroker () 59 self.diseases = [] 60 self.path = os.path.join (self.gb['resource dir'], 'data', 'derm') 61 for l in file (os.path.join (self.path, 'INDEX')).readlines (): 62 row = l.split () 63 d = {} 64 lang = gmI18N.system_locale_level['language'] 65 n = 0 66 for i in ['basename', 'code', 'population', 'distribution', 'colouring', 'pattern', 'surface', 'sensation','time_course']: 67 d[i] = row[n] 68 n += 1 69 try: 70 txt = file (os.path.join (self.gb['resource dir'], 'data', 'derm', '%s.%s.txt' % (row[0], lang))) 71 except IOError: 72 txt = file (os.path.join (self.gb['resource dir'], 'data', 'derm', '%s.en.txt' % row[0])) 73 # FIXME: should not this be done by Cheetah ? 74 d['title'] = txt.readline () 75 d['source'], d['text'] = tuple (txt.read ().split ('\n\n', 1)) 76 d['text'] = d['text'].replace ('&', '&') 77 d['text'] = d['text'].replace ('<', '<') 78 d['text'] = d['text'].replace ('>', '>') 79 d['text'] = d['text'].replace ('\n\n', '<p>') 80 d['source'] = d['source'].split (',')[0] 81 self.diseases.append (d)82 8385 # begin wxGlade: DermToolDialog.__set_properties 86 self.SetTitle("DermTool") 87 self.population.SetSelection(1) 88 self.distribution.SetSelection(0) 89 self.colouring.SetSelection(0) 90 self.pattern.SetSelection(0) 91 self.surface.SetSelection(0) 92 self.sensation.SetSelection(0) 93 self.time_course.SetSelection(0) 94 self.disease_name.SetToolTipString(_("Type name of disease")) 95 self.btn_save.SetDefault()96 # end wxGlade 9799 # begin wxGlade: DermToolDialog.__do_layout 100 sizer_1 = wx.BoxSizer(wx.VERTICAL) 101 sizer_3 = wx.BoxSizer(wx.HORIZONTAL) 102 sizer_6 = wx.BoxSizer(wx.HORIZONTAL) 103 sizer_7 = wx.BoxSizer(wx.VERTICAL) 104 sizer_8 = wx.BoxSizer(wx.HORIZONTAL) 105 sizer_5 = wx.BoxSizer(wx.VERTICAL) 106 sizer_4 = wx.BoxSizer(wx.VERTICAL) 107 sizer_2 = wx.BoxSizer(wx.HORIZONTAL) 108 sizer_2.Add(self.population, 1, 0, 0) 109 sizer_2.Add(self.distribution, 1, wx.ADJUST_MINSIZE, 0) 110 sizer_2.Add(self.colouring, 1, wx.ADJUST_MINSIZE, 0) 111 sizer_2.Add(self.pattern, 1, wx.ADJUST_MINSIZE, 0) 112 sizer_2.Add(self.surface, 1, wx.ADJUST_MINSIZE, 0) 113 sizer_2.Add(self.sensation, 1, wx.ADJUST_MINSIZE, 0) 114 sizer_2.Add(self.time_course, 1, wx.ADJUST_MINSIZE, 0) 115 sizer_1.Add(sizer_2, 1, wx.EXPAND, 0) 116 sizer_4.Add(self.disease_name, 0, wx.EXPAND|wx.ADJUST_MINSIZE, 0) 117 sizer_4.Add(self.disease_list, 1, wx.ALL|wx.EXPAND, 0) 118 sizer_3.Add(sizer_4, 1, wx.EXPAND, 0) 119 sizer_5.Add(self.image, 1, wx.EXPAND, 0) 120 sizer_5.Add(self.image_credit, 0, wx.EXPAND|wx.ADJUST_MINSIZE, 0) 121 sizer_3.Add(sizer_5, 3, wx.EXPAND, 0) 122 sizer_7.Add(self.disease_text, 1, wx.EXPAND, 0) 123 sizer_8.Add(self.btn_save, 0, wx.ADJUST_MINSIZE, 0) 124 sizer_8.Add(self.btn_close, 0, wx.ADJUST_MINSIZE, 0) 125 sizer_7.Add(sizer_8, 0, wx.EXPAND, 0) 126 sizer_6.Add(sizer_7, 2, wx.EXPAND, 0) 127 sizer_3.Add(sizer_6, 2, wx.EXPAND, 0) 128 sizer_1.Add(sizer_3, 2, wx.EXPAND, 0) 129 self.SetAutoLayout(True) 130 self.SetSizer(sizer_1) 131 sizer_1.Fit(self) 132 sizer_1.SetSizeHints(self) 133 self.Layout()134 # end wxGlade 135 137 self.disease_name.Clear () 138 maps = [('population', ['P', 'A', 'E']), ('distribution', ['T', 'G', 'F', 'H', 'L', 'S']), ('colouring', ['N', 'P', 'D', 'E', 'P']), ('pattern', ['C', 'M', 'MP', 'P', 'B']), ('surface', ['F', 'E', 'C', 'S', 'X']), ('sensation', ['N', 'I', 'P']), ('time_course', ['E', 'S'])] 139 vals = dict ([(i,j[getattr (self, i).GetSelection ()]) for i, j in maps]) 140 for i in self.diseases: 141 n = 0 142 for j in vals: 143 if vals[j] == i[j]: 144 n += 1 145 i['matches'] = n 146 self.diseases.sort (lambda x,y: cmp (x['matches'], y['matches'])) 147 self.disease_list.Clear () 148 for i in self.diseases[:10]: 149 if i['matches'] > 4: 150 self.disease_list.Append (i['title'], i)165 jpg_width = self.jpeg.GetWidth () 166 jpg_height = self.jpeg.GetHeight () 167 pnl_width,pnl_height = self.image.GetSizeTuple () 168 self.image.DestroyChildren () 169 jpg_aspect = jpg_width/float (jpg_height) 170 pnl_aspect = pnl_width/float (pnl_height) 171 if jpg_aspect > pnl_aspect: 172 desired_width = pnl_width 173 desired_height = int (pnl_width/jpg_aspect) 174 x = 0 175 y = (pnl_height-desired_height)/2 176 else: 177 desired_height = pnl_height 178 desired_width = int (pnl_height*jpg_aspect) 179 x = (pnl_width-desired_width)/2 180 y = 0 181 njpeg = self.jpeg.Scale (desired_width, desired_height) 182 bmp = wx.BitmapFromImage (njpeg) 183 sbmp = wx.StaticBitmap (self.image, -1, bmp, pos=wx.Point (x, y)) 184 sbmp.Show ()185 187 print "Event handler `save' not implemented" 188 event.Skip() 189 191 self.Destroy () 192 194 self.disease_list.Clear () 195 s = self.disease_name.GetValue ().upper () 196 if len (s) > 3: 197 for i in self.diseases: 198 if s in i['title'].upper (): 199 self.disease_list.Append (i['title'], i) 200 201 202 # end of class DermToolDialog 203 204 205 #== if run as standalone ======================================================= 206 if __name__ == '__main__': 207 # set up dummy app 213 #--------------------- 214 wx.InitAllImageHandlers() 215 app = TestApp() 216 app.MainLoop() 217
Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Tue Feb 9 04:01:45 2010 | http://epydoc.sourceforge.net |