Help with code, wx.TextCtrl

  Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Post Reply
mwkurt Offline
Posting Freak
Posts: 1,145
Joined: Mar 2010
Reputation: 12
Post: #1

I hope that this is not against protocol for this particular forum, but I am in need of some coding help as a beginner. Here is my problem

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?



import wx

def create(parent):
return Frame1(parent)

] = [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),

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):

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

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

(This post was last modified: 2013-07-26 22:45 by mwkurt.)
find quote
markdl Offline
Junior Member
Posts: 5
Joined: Jul 2013
Reputation: 0
Post: #2
Change self.bind to self.Bind. Capitalization is important.
find quote