Yashwanth S Prabhu
Yashwanth S Prabhu

Reputation: 21

Error with on click event in wxpython

I want to collect input from the user in test box. So when I click a button it should give me name of that button in test box Error: you should omit either rows of column

   for i in A:


        hbox1=wx.BoxSizer(wx.HORIZONTAL)



        btn = wx.Button(p, -1, i, (10,20)) 


        btn.myname = I


        gs.Add(btn,0,)


        self.Bind(wx.EVT_BUTTON, self.OnClick, btn)


        self.t1=wx.TextCtrl(p)


        gs.Add(btn,0,)    


        self.t1.Bind(wx.EVT_BUTTON, self.OnClick, btn)


        gs.Add(hbox1)

    p.SetSizer(gs)


def OnClick(self, event):  #When the button is clicked

    name = event.GetEventObject().myname

Upvotes: 0

Views: 237

Answers (1)

phd
phd

Reputation: 95080

Use wx.TextCtrl: self.t1=wx.TextCtrl(p)

Upvotes: 2

Related Questions