im trying create grid 10 rows , 10 columns. dont have problems displaying grid separately, when add menubar, not being displayed correctly..im trying add find button, can find elements in grid.
import wx import wx.grid gridlib class scrollbarframe(wx.frame): def __init__(self): wx.frame.__init__(self, none, wx.id_any,"grid popup menu") self.layout_file = {'id':[1,5,5],'name':[6,12],'state':[13,20]} print self.layout_file self.oninit() def oninit(self): panel = wx.panel(self, wx.id_any) vbox = wx.boxsizer(wx.vertical) hbox1 = wx.boxsizer(wx.horizontal) hbox2 = wx.boxsizer(wx.horizontal) menubar = wx.menubar() filemenu = wx.menu() filemenu.append(wx.id_new, '&new') filemenu.append(wx.id_open, '&open') filemenu.append(wx.id_save, '&save') menubar.append(filemenu, '&file') menu = self.setmenubar(menubar) # hbox1.add(menu, proportion=1) # vbox.add(hbox1, flag=wx.expand|wx.left|wx.right|wx.top, border=10) self.grid = gridlib.grid(panel) self.grid.creategrid(10 ,10) self.grid.setcellvalue(0,0,'(0,0)') self.grid.setcellvalue(0,0,'(0,1)') self.grid.setcellvalue(1,0,'(1,0)') self.grid.setcellvalue(1,0,'(1,1)') hbox2.add(self.grid,1,wx.expand,5) vbox.add(hbox2, flag=wx.expand|wx.left|wx.right|wx.top, border=10) panel.setsizer(vbox) if __name__ == '__main__': app = wx.pysimpleapp() frame = scrollbarframe() frame.show() app.mainloop()
add menubar first before adding widgets
import wx import wx.grid gridlib class scrollbarframe(wx.frame): def __init__(self): wx.frame.__init__(self, none, wx.id_any,"grid popup menu") self.layout_file = {'id':[1,5,5],'name':[6,12],'state':[13,20]} print self.layout_file self.oninit() def oninit(self): menubar = wx.menubar() filemenu = wx.menu() filemenu.append(wx.id_new, '&new') filemenu.append(wx.id_open, '&open') filemenu.append(wx.id_save, '&save') menubar.append(filemenu, '&file') menu = self.setmenubar(menubar) panel = wx.panel(self, wx.id_any) vbox = wx.boxsizer(wx.vertical) hbox1 = wx.boxsizer(wx.horizontal) hbox2 = wx.boxsizer(wx.horizontal) # hbox1.add(menu, proportion=1) # vbox.add(hbox1, flag=wx.expand|wx.left|wx.right|wx.top, border=10) self.grid = gridlib.grid(panel) self.grid.creategrid(10 ,10) self.grid.setcellvalue(0,0,'(0,0)') self.grid.setcellvalue(0,0,'(0,1)') self.grid.setcellvalue(1,0,'(1,0)') self.grid.setcellvalue(1,0,'(1,1)') hbox2.add(self.grid,1,wx.expand,5) vbox.add(hbox2, flag=wx.expand|wx.left|wx.right|wx.top, border=10) panel.setsizer(vbox) if __name__ == '__main__': app = wx.app() frame = scrollbarframe() frame.show() app.mainloop()
Comments
Post a Comment