Code: Select all
class MouseEventFrame(wx.Frame): def __init__(self, parent, id): wx.Frame.__init__(self, parent, id, 'Frame and Button', size=(1210, 400)) self.panel = wx.Panel(self) row = 0 column = 0 for x in range(1,67): txt = books[x] myname = txt while (len(myname) < 15): myname = " " + myname while (len(myname) < 20): myname += " " btn = 'butt' + str(x) btn = wx.Button(self.panel, -1, myname, pos=(column, row ) ) self.Bind(wx.EVT_BUTTON, self.OnClick,btn) self.Bind(wx.EVT_ENTER_WINDOW, self.OnEnterWindow,btn) column += 120 if column == 1200: column = 0 row += 55 def OnClick(self, event): obj = event.GetEventObject() print("You clicked %s"%obj.GetLabel()) event.Skip() def OnEnterWindow(self, event): obj = event.GetEventObject() print("Success at last!") event.Skip()
There is no error generated and the print doesn't do anything either.
I keep thinking I have something but cannot see what.
I hope someone's eyes and brain are sharper than mine.
If I can get the second function working rather than a print I will try to get it to speak the text on the button so she knows what she is hovering the muse over.