I have something like this right now:
import wx
class QuickAddBox(wx.TextCtrl):
def __init__(self, parent, viewer):
self.quick_add_text = wx.TextCtrl.__init__(self, parent, -1, '', size=(300,20), style=wx.TE_PROCESS_ENTER)
self.Bind(wx.EVT_TEXT_ENTER, self.OnPress, self.quick_add_text)
def OnPress(self, evt):
print self.quick_add_text.GetValue()
And I want to get the value of the textbox when I click enter. But when I do click enter, I get the following error:
AttributeError: 'NoneType' object has no attribute 'GetValue'
Any advice?
_________________________________________-
Nevermind I solved it by doing the following:
def OnPress(self, evt):
print self.GetValue()
Looks like you're storing the return value of TextCtrl's
__init__
(which isNone
) instead of the actual class instance. Your__init__
should likely look like this: