dynamically created buttons cannot be interacted with and are disabled

Swayam S wrote:

I am new to wxp. I have attached my file. The code is My project.py. I
am trying to create buttons dynamically there. The buttons are being
created but I am unable to interact with them, and any function bound
to them buttons don't work. I don't know where I am going wrong.
Please help me out!

You need to add the buttons to a panel. Right now, you're adding your
dynamic buttons to the frame itself. You gain certain event behavior
from the panel that doesn't come directly with the frame.

I made two changes to your code. I added one line to save the panel:
        panel = wx.Panel(self)
        self.panel = panel
and I changed the add_ct function to add the BitmapButton to the panel
instead of the frame:
        self.newct = wx.BitmapButton(self.panel, -1, pic, pos = pos,
size=(50,50), style = wx.NO_BORDER)

After that, I get mouse-over events on the new buttons, as you expect.

By the way, there is no point in calling "SetDefault" on all of your
buttons. You can delete that. The "default" status merely identifies
which button within a dialog is associated with the "enter" key. Only
one button within a dialog can be the default button, and since your
window is not a dialog, the concept isn't available anyway.

You should add an "Exit" item to your File menu. People expect to find
that. I certainly did.

ยทยทยท

--
Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.