Hello,
I have written this code, deleting those parts which are no needed to reproduce the error:

#! /usr/bin/env python
# TestDialogs.py

import wx, MySQLdb, wx.lib.intctrl, wx.grid
ID_SPECIES=1

class SearchDlg(wx.Dialog):
	def __init__(self):
		wx.Dialog.__init__(self, None, -1, 'Search species', size=(400,400))
		panel = wx.Panel(self, -1)
		vbox = wx.BoxSizer(wx.VERTICAL)
		hbox1 = wx.BoxSizer(wx.HORIZONTAL)
		hbox2 = wx.BoxSizer(wx.HORIZONTAL)
		hbox3 = wx.BoxSizer(wx.HORIZONTAL)
		hbox4 = wx.BoxSizer(wx.HORIZONTAL)
		hbox5 = wx.BoxSizer(wx.HORIZONTAL)
		hbox6 = wx.BoxSizer(wx.HORIZONTAL)

		#Define buttons and controls
		SearchBy = wx.StaticText(panel, -1, 'Search species by:')
		CommonName = wx.StaticText(panel, -1, 'English name:')
		self.CommonNameTXT = wx.TextCtrl(panel, -1, size = (200,-1))
		ScientificName = wx.StaticText(panel, -1, 'Scientific name:')
		self.ScientificNameTXT = wx.TextCtrl(panel, -1, size = (200,-1))
		Genus = wx.StaticText(panel, -1, 'Genus:')
		self.GenusTXT = wx.TextCtrl(panel, -1, size = (200,-1))
		Species = wx.StaticText(panel, -1, 'Species:')
		self.SpeciesTXT = wx.TextCtrl(panel, -1, size = (200,-1))
		searchBtn = wx.Button(panel, -1, 'Search')
		searchBtn.Bind(wx.EVT_BUTTON, self.OnSearch, searchBtn)

		#Merge sizers
		hbox1.Add(SearchBy, 0, wx.ALL, 5)
		hbox2.Add(CommonName, 0, wx.ALL, 5)
		hbox2.Add(self.CommonNameTXT, 0, wx.ALL, 5)
		hbox3.Add(ScientificName, 0, wx.ALL, 5)
		hbox3.Add(self.ScientificNameTXT, 0, wx.ALL, 5)
		hbox4.Add(Genus, 0, wx.ALL, 5)
		hbox4.Add(self.GenusTXT, 0, wx.ALL, 5)
		hbox5.Add(Species, 0, wx.ALL, 5)
		hbox5.Add(self.SpeciesTXT, 0, wx.ALL, 5)
		hbox6.Add(searchBtn, 0, wx.ALL, 5)
		vbox.Add(hbox1, 0, wx.ALIGN_CENTER | wx.ALL, 5)
		vbox.Add(hbox2, 0, wx.ALIGN_CENTER | wx.ALL, 5)
		vbox.Add(hbox3, 0, wx.ALIGN_CENTER | wx.ALL, 5)
		vbox.Add(hbox4, 0, wx.ALIGN_CENTER | wx.ALL, 5)
		vbox.Add(hbox5, 0, wx.ALIGN_CENTER | wx.ALL, 5)
		vbox.Add(hbox6, 0, wx.ALIGN_CENTER | wx.ALL, 5)
		panel.SetSizer(vbox)
		self.Centre()
		self.Show(True)

	def OnSearch(self, event):
		CommonName = self.CommonNameTXT.GetValue()
		if CommonName != '':
			ind = self.EnglishNameList.find(CommonName)
			print ind

class SpeciesGrid(wx.Frame):
	def __init__(self, parent, id, title = 'Select species'):
		self.InitialSpecies = 4
		Index = ['1','2','3','4']

		self.OrderList = ['Passeriformes', 'Passeriformes', 'Passeriformes', 'Passeriformes']
		self.FamilyList = ['Paridae', 'Paridae', 'Paridae', 'Paridae']
		self.GenusList = ['Parus','Poecile','Periparus','Lophophane']
		self.SpeciesList = ['major','palustris','ater','cristatus']
		self.EnglishNameList = ['Great Tit','Marsh Tit','Coal Tot','Crested Tit']
		wx.Frame.__init__(self, parent, id, title, size=(900,650))
#Define main panel
		panel = wx.Panel(self, -1)
		vbox = wx.BoxSizer(wx.VERTICAL)
	#Define sizers
		#Horizontal sizers
		SpeciesTableSizer = wx.BoxSizer(wx.HORIZONTAL)
		BtnSizer = wx.BoxSizer(wx.HORIZONTAL)

	#Add species table widget
		self.SpeciesGrid = wx.grid.Grid(panel, -1, size=(826,550))
		self.SpeciesGrid.CreateGrid(10396,4, wx.grid.Grid.SelectRows)
		self.SpeciesGrid.Bind(wx.grid.EVT_GRID_SELECT_CELL, self.OnSelectCell)
		self.SpeciesGrid.SetColLabelValue(0, 'Order')
		self.SpeciesGrid.SetColLabelValue(1, 'Family')
		self.SpeciesGrid.SetColLabelValue(2, 'Scientific name')
		self.SpeciesGrid.SetColLabelValue(3, 'English name')
		self.SpeciesGrid.SetRowLabelSize(0)
		for i in range(0,len(self.OrderList)):
			self.SpeciesGrid.SetCellValue(i,0,self.OrderList[i])
		for i in range(0,len(self.FamilyList)):
			self.SpeciesGrid.SetCellValue(i,1,self.FamilyList[i])
		for i in range(0,len(self.GenusList)):
			self.SpeciesGrid.SetCellValue(i,2,self.GenusList[i]+' '+self.SpeciesList[i])
		for i in range(0,len(self.EnglishNameList)):
			self.SpeciesGrid.SetCellValue(i,3,self.EnglishNameList[i])
		for i in range(0, len(self.OrderList)):
			for j in range(0,4):
				self.SpeciesGrid.SetReadOnly(i,j)
		for i in range(0, len(Index)):
			for j in range(0,4):
				self.SpeciesGrid.SetCellBackgroundColour(int(Index[i])-1,j,wx.LIGHT_GREY)
		self.SpeciesGrid.SetColSize(0,172)
		self.SpeciesGrid.SetColSize(1,143)
		self.SpeciesGrid.SetColSize(2,250)
		self.SpeciesGrid.SetColSize(3,245)
		SpeciesTableSizer.Add(self.SpeciesGrid, wx.ALIGN_CENTER | wx.ALL,0 )
		
	#Add buttons
		searchBtn = wx.Button(panel, -1, 'Search')
		searchBtn.Bind(wx.EVT_BUTTON, self.OnSearch, searchBtn)
		useBtn = wx.Button(panel, -1, 'Use')
		useBtn.Bind(wx.EVT_BUTTON, self.OnUse, useBtn)
		rmvBtn = wx.Button(panel, -1, 'Remove')
		doneBtn = wx.Button(panel, -1, 'Done')
		doneBtn.Bind(wx.EVT_BUTTON, self.OnDone, doneBtn)
		BtnSizer.Add(searchBtn, 0, wx.ALL, 5)
		BtnSizer.Add(useBtn, 0, wx.ALL, 5)
		BtnSizer.Add(rmvBtn, 0, wx.ALL, 5)
		BtnSizer.Add(doneBtn, 0, wx.ALL, 5)
		vbox.Add(SpeciesTableSizer, 0, wx.ALIGN_CENTER | wx.ALL, 5)
		vbox.Add(BtnSizer, 0, wx.ALIGN_CENTER | wx.ALL, 5)

		panel.SetSizer(vbox)
		self.Centre()
		self.Show(True)

	def OnSelectCell(self, event):
		self.row = event.GetRow()
		event.Skip()
		return self.row

	def OnUse(self, event):
		row = self.row+1
		def GetCurrentUser():
			sql = 'select substring_index(CURRENT_USER(),"@",1)'
			self.cursor.execute(sql)
			result = self.cursor.fetchall()
			textResult = str('')
			for record in result:
				for field in record:
					CurrentUser = str(field)
					return CurrentUser
		Username = GetCurrentUser()

		def GetOrder():
			sql = 'select OrderScientific from Species where idSpecies = %s'
			self.cursor.execute(sql, (row))
			result = self.cursor.fetchall()
			textResult = str('')
			for record in result:
				for field in record:
					Order = str(field)
					return Order
		Order = GetOrder()

		def GetFamily():
			sql = 'select Family from Species where idSpecies = %s'
			self.cursor.execute(sql, (row))
			result = self.cursor.fetchall()
			textResult = str('')
			for record in result:
				for field in record:
					Family = str(field)
					return Family
		Family = GetFamily()

		def GetGenus():
			sql = 'select Genus from Species where idSpecies = %s'
			self.cursor.execute(sql, (row))
			result = self.cursor.fetchall()
			textResult = str('')
			for record in result:
				for field in record:
					Genus = str(field)
					return Genus
		Genus = GetGenus()

		def GetSpecies():
			sql = 'select Species from Species where idSpecies = %s'
			self.cursor.execute(sql, (row))
			result = self.cursor.fetchall()
			textResult = str('')
			for record in result:
				for field in record:
					Species = str(field)
					return Species
		Latin = GetSpecies()

		def GetEnglishName():
			sql = 'select EnglishName from Species where idSpecies = %s'
			self.cursor.execute(sql, (row))
			result = self.cursor.fetchall()
			textResult = str('')
			for record in result:
				for field in record:
					EnglishName = str(field)
					return EnglishName
		EnglishName = GetEnglishName()
		sql = 'INSERT INTO LifeList(OrderScientific, Genus, Family, Species, EnglishName, Username) VALUES (%s, %s, %s, %s, %s, %s)'
		self.cursor.execute(sql, (Order, Genus, Family, Latin, EnglishName, Username))
		self.db.commit()
		def GetIndex():
			sql = 'select idSpecies from Species where (Genus, Species) in (select Genus,Species from LifeList)'
			self.cursor.execute(sql)
			result = self.cursor.fetchall()
			result2 = []
			for record in result:
				for field in record:
					Index = str(field)
					result2.append(Index)
			return result2
		Index = GetIndex()
		for i in range(0, len(Index)):
			for j in range(0,4):
				self.SpeciesGrid.SetCellBackgroundColour(int(Index[i])-1,j,wx.LIGHT_GREY)

	def OnDone(self, event):
		def CountSpecies():
			sql = 'select idSpecies from Species where (Genus, Species) in (select Genus,Species from LifeList)'
			self.cursor.execute(sql)
			result = self.cursor.fetchall()
			result2 = []
			for record in result:
				for field in record:
					Index = str(field)
					result2.append(Index)
			return int(len(result2))
		TotalSpecies = CountSpecies()
		AddedSpecies = TotalSpecies - self.InitialSpecies
		Message = 'You have added ' + str(AddedSpecies) + ' species ' + 'and your life list has ' + str(TotalSpecies) + ' species.'
		DoneDlg = wx.MessageDialog(None, Message, 'Info', wx.OK)
		DoneDlg.ShowModal()
		self.Destroy()
	
	def OnSearch(self, event):
		dlg = SearchDlg()
		dlg.ShowModal()

app = wx.App()
SpeciesGrid(None, -1)
app.MainLoop()

When you press the search button, it opens a search dialog. Then, you type into the English name text control (right now this is the only one which works) and press search, it should return the index of the string within the EnglisNameList object. However, I get this error

AttributeError: 'SearchDlg' object has no attribute 'EnglishNameList'

I know what the error means but I don't know how to solve it.
Cheers!

Dani

class SpeciesGrid(wx.Frame):

    self.EnglishNameList = ['Great Tit','Marsh Tit','Coal Tot','Crested Tit']

Your code defines EnglishNameList as a attribute of the SpeciesGrid class, so you must change the

self.EnglishNameList

on the SearchDlg class by something like

SpeciesGrid.EnglishNameList

.

Cheers and Happy coding

Hello,
I have tried your suggestion but I get this error

AttributeError: type object 'SpeciesGrid' has no attribute 'EnglishNameList'

Dani

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.