July 26th, 2013, 10:44 PM
Help requested - AttributeError: 'Frame 1' object has no attribute 'bind'
Beginner with Python needing some guidance please. I am using Python 2.7.5.
I have two text boxes. Text_1 and Text_2. Text_1 is an input box and Text_2 should duplicate Text_1 as a string is entered into Text_1. The problem I have with my code is I keep getting this error: AttributeError: 'Frame 1' object has no attribute 'bind'
The bolded line seems to be where my problem is.
I get the same result in Boa and pyscripter.
Could someone take a look at my code and tell me the error of my ways?
[wxID_FRAME1, wxID_FRAME1PANEL1, wxID_FRAME1TEXT_1, wxID_FRAME1TEXT_2,
] = [wx.NewId() for _init_ctrls in range(4)]
def _init_ctrls(self, prnt):
# generated method, don't edit
wx.Frame.__init__(self, id=wxID_FRAME1, name='', parent=prnt,
pos=wx.Point(444, 307), size=wx.Size(406, 250),
self.panel1 = wx.Panel(id=wxID_FRAME1PANEL1, name='panel1', parent=self,
pos=wx.Point(0, 0), size=wx.Size(390, 212),
self.text_1 = wx.TextCtrl(id=wxID_FRAME1TEXT_1, name=u'text_1',
parent=self.panel1, pos=wx.Point(80, 32), size=wx.Size(240, 21),
self.text_2 = wx.TextCtrl(id=wxID_FRAME1TEXT_2, name=u'text_2',
parent=self.panel1, pos=wx.Point(72, 128), size=wx.Size(240, 21),
self.bind(wx.EVT_TEXT, self.intext, self.text_1)
def __init__(self, parent):
def intext(self, event):
txt = self.text_1.GetValue()
self.text_2 = txt
if __name__ == '__main__':
app = wx.PySimpleApp()
frame = create(None)
July 27th, 2013, 01:31 AM
You certainly need to use code tags when posting.
Other than that, your code is a bit messy, but, the short answer is, wx.Frame has no attribute bind.
It does however have an attribute Bind. Note the capital 'B'
Change the problematic line to:
self.Bind(wx.EVT_TEXT, self.intext, self.text_1)
July 27th, 2013, 07:01 AM
Thank you for replying with the answer to my problem Mek. As I said I am beginning and most of this code was created by Boa Constructor, so if it is messy, I can blame that
I hope that as I move on in learning the language, my code will become more in line with what is expected.
When you say "code tags in my code", could you please expand on what you mean by that?