def on_find(self, event_): # wxGlade: Finder.<event_handler> self.predicate = CompoundPredicate() if self.notebook.GetCurrentPage() == self.find_by_text_panel: if self.text_object_type_choice.GetCurrentSelection() == 1: self.predicate.addStatement( lambda x: x.__class__ == network.region.Region) elif self.text_object_type_choice.GetCurrentSelection() == 2: self.predicate.addStatement( lambda x: x.__class__ == network.pathway.Pathway) elif self.text_object_type_choice.GetCurrentSelection() == 3: self.predicate.addStatement( lambda x: x.__class__ == network.neuron.Neuron) elif self.text_object_type_choice.GetCurrentSelection() == 4: self.predicate.addStatement( lambda x: x.__class__ == network.neurite.Neurite) elif self.text_object_type_choice.GetCurrentSelection() == 5: self.predicate.addStatement( lambda x: x.__class__ == network.synapse.Synapse) elif self.text_object_type_choice.GetCurrentSelection() == 6: self.predicate.addStatement( lambda x: x.__class__ == network.gap_junction.GapJunction) elif self.text_object_type_choice.GetCurrentSelection() == 7: self.predicate.addStatement( lambda x: x.__class__ == network.muscle.Muscle) elif self.text_object_type_choice.GetCurrentSelection() == 8: self.predicate.addStatement( lambda x: x.__class__ == network.arborization.Arborization) elif self.text_object_type_choice.GetCurrentSelection() == 9: self.predicate.addStatement( lambda x: x.__class__ == network.innervation.Innervation) elif self.text_object_type_choice.GetCurrentSelection() == 10: self.predicate.addStatement( lambda x: x.__class__ == network.stimulus.Stimulus) findText = self.find_text.GetValue().upper() if self.text_operator_choice.GetCurrentSelection() == 0: namePredicate = Predicate( lambda x: (x.name is None and findText == '') or (x.name != None and x.name.upper().find(findText) != -1)) abbreviationPredicate = Predicate( lambda x: (x.abbreviation is None and findText == '') or (x.abbreviation != None and x.abbreviation.upper().find( self.find_text.GetValue().upper()) != -1)) elif self.text_operator_choice.GetCurrentSelection() == 1: namePredicate = Predicate(lambda x: x.name != None and x.name. upper().startswith(findText)) abbreviationPredicate = Predicate( lambda x: x.abbreviation != None and x.abbreviation.upper( ).startswith(self.find_text.GetValue().upper())) elif self.text_operator_choice.GetCurrentSelection() == 2: namePredicate = Predicate(lambda x: x.name != None and x.name. upper().endswith(findText)) abbreviationPredicate = Predicate( lambda x: x.abbreviation != None and x.abbreviation.upper( ).endswith(findText)) if self.text_field_choice.GetCurrentSelection( ) == 0: # name or abbreviation fieldPredicate = CompoundPredicate() fieldPredicate.matchAll = False fieldPredicate.predicates.append(namePredicate) fieldPredicate.predicates.append(abbreviationPredicate) self.predicate.predicates.append(fieldPredicate) elif self.text_field_choice.GetCurrentSelection( ) == 1: # just name self.predicate.predicates.append(namePredicate) elif self.text_field_choice.GetCurrentSelection( ) == 2: # just abbreviation self.predicate.predicates.append(abbreviationPredicate) elif self.notebook.GetCurrentPage() == self.find_by_io_panel: if self.io_connection_type_choice.GetCurrentSelection() == 1: self.predicate.addStatement( lambda x: x.__class__ == network.pathway.Pathway) elif self.text_object_type_choice.GetCurrentSelection() == 2: self.predicate.addStatement( lambda x: x.__class__ == network.neuron.Neuron) sourceObject = self.io_object_choice.GetClientData( self.io_object_choice.GetCurrentSelection()) inputs = sourceObject.inputs() outputs = sourceObject.outputs() if self.input_output_choice.GetCurrentSelection( ) == 0: # just send self.predicate.addStatement(lambda x: x in inputs) elif self.input_output_choice.GetCurrentSelection( ) == 1: # just receive self.predicate.addStatement(lambda x: x in outputs) elif self.input_output_choice.GetCurrentSelection( ) == 2: # send or receive self.predicate.addStatement( lambda x: x in inputs or x in outputs) self.EndModal(wx.ID_OK)
def on_find(self, event_): # wxGlade: Finder.<event_handler> self.predicate = CompoundPredicate() if self.notebook.GetCurrentPage() == self.find_by_text_panel: if self.text_object_type_choice.GetCurrentSelection() == 1: self.predicate.addStatement(lambda x: x.__class__ == network.region.Region) elif self.text_object_type_choice.GetCurrentSelection() == 2: self.predicate.addStatement(lambda x: x.__class__ == network.pathway.Pathway) elif self.text_object_type_choice.GetCurrentSelection() == 3: self.predicate.addStatement(lambda x: x.__class__ == network.neuron.Neuron) elif self.text_object_type_choice.GetCurrentSelection() == 4: self.predicate.addStatement(lambda x: x.__class__ == network.neurite.Neurite) elif self.text_object_type_choice.GetCurrentSelection() == 5: self.predicate.addStatement(lambda x: x.__class__ == network.synapse.Synapse) elif self.text_object_type_choice.GetCurrentSelection() == 6: self.predicate.addStatement(lambda x: x.__class__ == network.gap_junction.GapJunction) elif self.text_object_type_choice.GetCurrentSelection() == 7: self.predicate.addStatement(lambda x: x.__class__ == network.muscle.Muscle) elif self.text_object_type_choice.GetCurrentSelection() == 8: self.predicate.addStatement(lambda x: x.__class__ == network.arborization.Arborization) elif self.text_object_type_choice.GetCurrentSelection() == 9: self.predicate.addStatement(lambda x: x.__class__ == network.innervation.Innervation) elif self.text_object_type_choice.GetCurrentSelection() == 10: self.predicate.addStatement(lambda x: x.__class__ == network.stimulus.Stimulus) findText = self.find_text.GetValue().upper() if self.text_operator_choice.GetCurrentSelection() == 0: namePredicate = Predicate(lambda x: (x.name is None and findText == '') or (x.name != None and x.name.upper().find(findText) != -1)) abbreviationPredicate = Predicate(lambda x: (x.abbreviation is None and findText == '') or (x.abbreviation != None and x.abbreviation.upper().find(self.find_text.GetValue().upper()) != -1)) elif self.text_operator_choice.GetCurrentSelection() == 1: namePredicate = Predicate(lambda x: x.name != None and x.name.upper().startswith(findText)) abbreviationPredicate = Predicate(lambda x: x.abbreviation != None and x.abbreviation.upper().startswith(self.find_text.GetValue().upper())) elif self.text_operator_choice.GetCurrentSelection() == 2: namePredicate = Predicate(lambda x: x.name != None and x.name.upper().endswith(findText)) abbreviationPredicate = Predicate(lambda x: x.abbreviation != None and x.abbreviation.upper().endswith(findText)) if self.text_field_choice.GetCurrentSelection() == 0: # name or abbreviation fieldPredicate = CompoundPredicate() fieldPredicate.matchAll = False fieldPredicate.predicates.append(namePredicate) fieldPredicate.predicates.append(abbreviationPredicate) self.predicate.predicates.append(fieldPredicate) elif self.text_field_choice.GetCurrentSelection() == 1: # just name self.predicate.predicates.append(namePredicate) elif self.text_field_choice.GetCurrentSelection() == 2: # just abbreviation self.predicate.predicates.append(abbreviationPredicate) elif self.notebook.GetCurrentPage() == self.find_by_io_panel: if self.io_connection_type_choice.GetCurrentSelection() == 1: self.predicate.addStatement(lambda x: x.__class__ == network.pathway.Pathway) elif self.text_object_type_choice.GetCurrentSelection() == 2: self.predicate.addStatement(lambda x: x.__class__ == network.neuron.Neuron) sourceObject = self.io_object_choice.GetClientData(self.io_object_choice.GetCurrentSelection()) inputs = sourceObject.inputs() outputs = sourceObject.outputs() if self.input_output_choice.GetCurrentSelection() == 0: # just send self.predicate.addStatement(lambda x: x in inputs) elif self.input_output_choice.GetCurrentSelection() == 1: # just receive self.predicate.addStatement(lambda x: x in outputs) elif self.input_output_choice.GetCurrentSelection() == 2: # send or receive self.predicate.addStatement(lambda x: x in inputs or x in outputs) self.EndModal(wx.ID_OK)