def __init__(self, parent, size=(800,-1), **kwargs): wx.Frame.__init__(self, parent, -1, size=size, title='Plate Viewer', **kwargs) CPATool.__init__(self) self.SetName(self.tool_name) self.SetBackgroundColour("white") # Fixing the color # Check for required properties fields. fail = False for field in required_fields: if not p.field_defined(field): fail = True raise Exception('Properties field "%s" is required for PlateViewer.'%(field)) if fail: self.Destroy() return self.chMap = p.image_channel_colors[:] self.menuBar = wx.MenuBar() self.SetMenuBar(self.menuBar) self.fileMenu = wx.Menu() self.exitMenuItem = self.fileMenu.Append(id=wx.ID_EXIT, text='Exit\tCtrl+Q', help='Close Plate Viewer') self.GetMenuBar().Append(self.fileMenu, 'File') self.menuBar.Append(cpa.helpmenu.make_help_menu(self), 'Help') save_csv_menu_item = self.fileMenu.Append(-1, 'Save table to CSV\tCtrl+S') self.Bind(wx.EVT_MENU, self.on_save_csv, save_csv_menu_item) wx.EVT_MENU(self, wx.ID_EXIT, lambda _:self.Close()) dataSourceSizer = wx.StaticBoxSizer(wx.StaticBox(self, label='Source:'), wx.VERTICAL) dataSourceSizer.Add(wx.StaticText(self, label='Data source:')) self.sourceChoice = TableComboBox(self, -1, size=fixed_width) dataSourceSizer.Add(self.sourceChoice) dataSourceSizer.AddSpacer((-1,3)) dataSourceSizer.Add(wx.StaticText(self, label='Measurement:')) measurements = get_non_blob_types_from_table(p.image_table) self.measurementsChoice = ComboBox(self, choices=measurements, size=fixed_width) self.measurementsChoice.Select(0) dataSourceSizer.Add(self.measurementsChoice) dataSourceSizer.Add(wx.StaticText(self, label='Filter:')) self.filterChoice = FilterComboBox(self, size=fixed_width) dataSourceSizer.Add(self.filterChoice) groupingSizer = wx.StaticBoxSizer(wx.StaticBox(self, label='Data aggregation:'), wx.VERTICAL) groupingSizer.Add(wx.StaticText(self, label='Aggregation method:')) aggregation = ['mean', 'sum', 'median', 'stdev', 'cv%', 'min', 'max'] self.aggregationMethodsChoice = ComboBox(self, choices=aggregation, size=fixed_width) self.aggregationMethodsChoice.Select(0) groupingSizer.Add(self.aggregationMethodsChoice) viewSizer = wx.StaticBoxSizer(wx.StaticBox(self, label='View options:'), wx.VERTICAL) viewSizer.Add(wx.StaticText(self, label='Color map:')) maps = [m for m in matplotlib.cm.datad.keys() if not m.endswith("_r")] maps.sort() self.colorMapsChoice = ComboBox(self, choices=maps, size=fixed_width) self.colorMapsChoice.SetSelection(maps.index('jet')) viewSizer.Add(self.colorMapsChoice) viewSizer.AddSpacer((-1,3)) viewSizer.Add(wx.StaticText(self, label='Well display:')) if p.image_thumbnail_cols: choices = pmp.all_well_shapes else: choices = list(pmp.all_well_shapes) choices.remove(pmp.THUMBNAIL) self.wellDisplayChoice = ComboBox(self, choices=choices, size=fixed_width) self.wellDisplayChoice.Select(0) viewSizer.Add(self.wellDisplayChoice) viewSizer.AddSpacer((-1,3)) viewSizer.Add(wx.StaticText(self, label='Number of plates:')) self.numberOfPlatesTE = wx.TextCtrl(self, -1, '1', style=wx.TE_PROCESS_ENTER) viewSizer.Add(self.numberOfPlatesTE) if not p.plate_id: self.numberOfPlatesTE.Disable() annotationSizer = wx.StaticBoxSizer(wx.StaticBox(self, label='Annotation:'), wx.VERTICAL) annotationSizer.Add(wx.StaticText(self, label='Annotation column:')) annotationColSizer = wx.BoxSizer(wx.HORIZONTAL) self.annotation_cols = dict([(col, db.GetColumnType(p.image_table, col)) for col in db.GetUserColumnNames(p.image_table)]) self.annotationCol = ComboBox(self, choices=self.annotation_cols.keys(), size=(120,-1)) if len(self.annotation_cols) > 0: self.annotationCol.SetSelection(0) annotationColSizer.Add(self.annotationCol, flag=wx.ALIGN_CENTER_VERTICAL) annotationColSizer.AddSpacer((3,-1)) self.addAnnotationColBtn = wx.Button(self, -1, 'Add', size=(44,-1)) annotationColSizer.Add(self.addAnnotationColBtn, flag=wx.ALIGN_CENTER_VERTICAL) annotationSizer.Add(annotationColSizer) annotationSizer.AddSpacer((-1,3)) annotationSizer.Add(wx.StaticText(self, label='Label:')) self.annotationLabel = wx.TextCtrl(self, -1, 'Select wells')#, style=wx.TE_PROCESS_ENTER) self.annotationLabel.Disable() self.annotationLabel.SetForegroundColour(wx.Colour(80,80,80)) self.annotationLabel.SetBackgroundColour(wx.LIGHT_GREY) annotationSizer.Add(self.annotationLabel) annotationSizer.AddSpacer((-1,3)) self.outlineMarked = wx.CheckBox(self, -1, label='Outline annotated wells') annotationSizer.Add(self.outlineMarked) annotationSizer.AddSpacer((-1,3)) self.annotationShowVals = wx.CheckBox(self, -1, label='Show values on plate') annotationSizer.Add(self.annotationShowVals) if len(db.GetUserColumnNames(p.image_table)) == 0: self.outlineMarked.Disable() self.annotationShowVals.Disable() controlSizer = wx.BoxSizer(wx.VERTICAL) controlSizer.Add(dataSourceSizer, 0, wx.EXPAND) controlSizer.AddSpacer((-1,3)) controlSizer.Add(groupingSizer, 0, wx.EXPAND) controlSizer.AddSpacer((-1,3)) controlSizer.Add(viewSizer, 0, wx.EXPAND) controlSizer.AddSpacer((-1,3)) controlSizer.Add(annotationSizer, 0 , wx.EXPAND) self.plateMapSizer = wx.GridSizer(1,1,5,5) self.plateMaps = [] self.plateMapChoices = [] self.rightSizer = wx.BoxSizer(wx.VERTICAL) self.rightSizer.Add(self.plateMapSizer, 1, wx.EXPAND|wx.BOTTOM, 10) self.colorBar = ColorBarPanel(self, 'jet', size=(-1,25)) self.rightSizer.Add(self.colorBar, 0, wx.EXPAND|wx.ALIGN_CENTER_HORIZONTAL) mainSizer = wx.BoxSizer(wx.HORIZONTAL) mainSizer.Add(controlSizer, 0, wx.LEFT|wx.TOP|wx.BOTTOM, 10) mainSizer.Add(self.rightSizer, 1, wx.EXPAND|wx.ALL, 10) self.SetSizer(mainSizer) self.SetClientSize((self.Size[0],self.Sizer.CalcMin()[1])) self.sourceChoice.Bind(wx.EVT_COMBOBOX, self.UpdateMeasurementChoice) self.measurementsChoice.Bind(wx.EVT_COMBOBOX, self.OnSelectMeasurement) self.measurementsChoice.Select(0) self.aggregationMethodsChoice.Bind(wx.EVT_COMBOBOX, self.OnSelectAggregationMethod) self.colorMapsChoice.Bind(wx.EVT_COMBOBOX, self.OnSelectColorMap) self.numberOfPlatesTE.Bind(wx.EVT_TEXT_ENTER, self.OnEnterNumberOfPlates) self.wellDisplayChoice.Bind(wx.EVT_COMBOBOX, self.OnSelectWellDisplay) self.annotationCol.Bind(wx.EVT_COMBOBOX, self.OnSelectAnnotationCol) self.addAnnotationColBtn.Bind(wx.EVT_BUTTON, self.OnAddAnnotationCol) self.annotationLabel.Bind(wx.EVT_KEY_UP, self.OnEnterAnnotation) self.outlineMarked.Bind(wx.EVT_CHECKBOX, self.OnOutlineMarked) self.annotationShowVals.Bind(wx.EVT_CHECKBOX, self.OnShowAnnotationValues) self.filterChoice.Bind(wx.EVT_COMBOBOX, self.OnSelectFilter) self.AddPlateMap() self.OnSelectMeasurement()