#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2013
    Posts
    4
    Rep Power
    0

    Help requested - AttributeError: 'Frame 1' object has no attribute 'bind'


    Hello,

    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?

    Thanks,
    Mark

    #Boa:Frame:Frame1

    import wx

    def create(parent):
    return Frame1(parent)

    [wxID_FRAME1, wxID_FRAME1PANEL1, wxID_FRAME1TEXT_1, wxID_FRAME1TEXT_2,
    ] = [wx.NewId() for _init_ctrls in range(4)]

    class Frame1(wx.Frame):
    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),
    style=wx.DEFAULT_FRAME_STYLE, title='Frame1')
    self.SetClientSize(wx.Size(390, 212))

    self.panel1 = wx.Panel(id=wxID_FRAME1PANEL1, name='panel1', parent=self,
    pos=wx.Point(0, 0), size=wx.Size(390, 212),
    style=wx.TAB_TRAVERSAL)

    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),
    style=0, value=u'')

    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),
    style=0, value=u'')

    self.bind(wx.EVT_TEXT, self.intext, self.text_1)


    def __init__(self, parent):
    self._init_ctrls(parent)

    def intext(self, event):
    txt = self.text_1.GetValue()
    self.text_2 = txt


    if __name__ == '__main__':
    app = wx.PySimpleApp()
    frame = create(None)
    frame.Show()

    app.MainLoop()
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2012
    Posts
    194
    Rep Power
    3
    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:
    Code:
    self.Bind(wx.EVT_TEXT, self.intext, self.text_1)
    -Mek
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2013
    Posts
    4
    Rep Power
    0
    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?

    Thanks again!
    Mark

IMN logo majestic logo threadwatch logo seochat tools logo