Error with on click event in wxpython

巧了我就是萌 提交于 2019-12-13 02:55:51

问题


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

回答1:


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



来源:https://stackoverflow.com/questions/44348606/error-with-on-click-event-in-wxpython

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!