import wx class build (wx.Dialog): def __init__ (self,parent,id): wx.Dialog.__init__(self,parent,id,"Dictionary", size= (700,500)) dialog=wx.Dialog(self) button = wx.Button(self,label="Search",pos=(460,40),size=(50,20)) self.Bind(wx.EVT_BUTTON, self.SearchDictionary, button) TextBox = wx.TextCtrl (self, -1, "Search Dictionary (Lower-Case)", (250,40), (200,20)) def SearchDictionary (self,event): answer = TextBox.GetValue if self.answer() == "1": print "1" if __name__=="__main__": app=wx.PySimpleApp() dialog=build(parent=None,id=-1) dialog.Show() app.MainLoop()
so what happens here is I have a wx.TextCtrl widget with a button in a dialog. What should happen is when you press the button it extracts the word that the user has put into TextCtrl widget but instead I get an error saying that global name 'TextBox' is undefined
ps. I think the reason it's saying that it is undefined is because 'TextBox' is getting defined in a different function so what I want to know is if there's a way to make python know that I am talking about TextBox.