wxPython overlapping images -


i have program displays suit of cards overlapped images , wish select card double clicking on it. unfortunately, way i've programmed it, program pick image has been overlapped , not top image (e.g, if click on ks, system prints 'as' etc. js returns qs area of overlap, js right of that)

the cards .png images 72x96 pixels.

cardimages

can please suggest how can set respond displayed card?

here individual card images

ace of spadeskingqueenjack

import wx  class example(wx.frame):    def __init__(self, parent, title):     super(example, self).__init__(parent, title=title,        size=(250, 200))      self.center()     self.show()     pnl = wx.panel(self)      mainsizer= self.buildsuit(pnl)     pnl.setsizer(mainsizer)     pnl.layout()     pnl.fit()    def buildsuit(self, pnl):     cards=['as', 'ks', 'qs', 'js']     suitsizer=wx.gridbagsizer(1, 13)     border = 10     ii in range(0, len(cards)):       card=cards[ii]       image = wx.bitmap('images/cardimages/'+card+'.png',wx.bitmap_type_png)       img = wx.staticbitmap(pnl, -1, image, name=card)       img.bind(wx.evt_left_dclick, self.onsuitclick)       suitsizer.add(img, pos=(0,ii), flag=wx.left, border=border)       border = -50     return suitsizer         def onsuitclick(self, event):     imgctrl=event.geteventobject()     print imgctrl.getname()  if __name__ == '__main__':    app = wx.app()   example(none, title='double click images')   app.mainloop() 

solved using getsubimage() method on image

thanks if looked :)

def buildsuit(self, pnl):   cards=['as', 'ks', 'qs', 'js']   suitsizer=wx.gridbagsizer(1, 13)   border = 0   ii in range(0, len(cards)):     card=cards[ii]     image = wx.bitmap('images/cardimages/'+card+'.png',wx.bitmap_type_png).converttoimage()     image=image.getsubimage(wx.rect(0, 0, 26, 96))     img = wx.staticbitmap(pnl, -1, image.converttobitmap(), name=card)     img.bind(wx.evt_left_dclick, self.onsuitclick)     suitsizer.add(img, pos=(0,ii), flag=wx.left, border=border)     border = -13   return suitsizer     

Comments

Popular posts from this blog

facebook - android ACTION_SEND to share with specific application only -

python - Creating a new virtualenv gives a permissions error -

javascript - cocos2d-js draw circle not instantly -