I've put together a code to make a periodic table with jpeg bitmap buttons, and here's the code:

element_list = ["H.jpg","He.jpg","Li.jpg"]
        for i in range(len(element_list)):
            image_id = int(i+1)
            image_current = wx.Image("/Applications/PeriodicTable/ButtonBitMap/%s" % element_list[i], wx.BITMAP_TYPE_ANY).ConvertToBitmap()
            current = wx.BitmapButton(self,id=image_id,bitmap=image_current,style=wx.BORDER_NONE)
            main.Add(current,1)

I've done the id, because for some reason, I can't figure out how to reference the button itself. For instance, if I make He = wx.BitmatButton(etc...), how do I get the He in my bound event (so I can run ELEMENTS[He]), so I can have all the buttons reference one event? If I could do this, I wouldn't have to mess around with ID's (which I've heard is a bad idea).

Pay attention to this and how its implemented please
:)

element_list = ["H.jpg","He.jpg","Li.jpg"]
        for i in range(len(element_list)):
            image_id = int(i+1)
            image_current = wx.Image("/Applications/PeriodicTable/ButtonBitMap/%s" % element_list[i], wx.BITMAP_TYPE_ANY).ConvertToBitmap()
            current = wx.BitmapButton(self,id=image_id,bitmap=image_current,style=wx.BORDER_NONE)
            main.Add(current,1)
            self.Bind(wx.EVT_BUTTON,self.OnButtonClick,current) ## add thiss line
     def OnButtonClick(self,event): # And this is how you checked for the pressed button
         ButtonId=event.GetId()     # And you respond to the actions in the if's
         if(ButtonId==1):
             pass
         if(ButtonId==2):
             pass
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.