wxpython - Display image in wx.GridBagSizer -
i trying display image on wx.gridbagsizer
the image being read , can see if comment out sizermain.add lines, not show in sizer. interestingly space reserved in sizer.
can please help?
import wx class mainwindow(wx.frame): def __init__(self,parent,id,title): wx.frame.__init__(self,parent, wx.id_any, title, size = (1200,600), style=wx.default_frame_style|wx.no_full_repaint_on_resize) sizermain = wx.gridbagsizer(3, 2) self.sizermain = sizermain pnl = wx.panel(self) cmd1 = wx.button(pnl, label='aaaaa') cmd2 = wx.button(pnl, label='bbbbbb') cmd3 = wx.button(pnl, label='ccccc') cmd4 = wx.button(pnl, label='dddd') imgsizer = wx.boxsizer(wx.horizontal) image = wx.bitmap('test.png',wx.bitmap_type_png) img = wx.staticbitmap(self, -1, image) imgsizer.add(img, flag=wx.left, border=10) sizermain.add(imgsizer, pos=(0,0), span=(1, 3), flag=wx.top|wx.left|wx.right, border=10) sizermain.add(cmd1, pos=(2,2), flag=wx.top|wx.left|wx.right, border=10) sizermain.add(cmd2, pos=(1, 0), flag=wx.top|wx.left|wx.right, border=10) sizermain.add(cmd3, pos=(1, 1), flag=wx.top|wx.left|wx.right, border=10) sizermain.add(cmd4, pos=(2, 1), flag=wx.top|wx.left|wx.right, border=10) pnl.setsizer(sizermain) pnl.layout() pnl.fit() self.show(true) def closewindow(self, event): self.close() class myapp(wx.app): def oninit(self): frame = mainwindow(none, -1, "test gridbag") frame.centre() self.settopwindow(frame) return true # declare application , start main loop app = myapp(0) app.mainloop()
the parent of wx.staticbitmap "img" needs panel "pnl". not "self".
Comments
Post a Comment