Friday, 15 April 2011

python - StaticBox leads to segmentation fault error if layout is called -



python - StaticBox leads to segmentation fault error if layout is called -

i wanted improve gui using staticboxes. since added 1 can't phone call layout function without crashing python (segementation fault; no other error messages). next lines reproduce error exactly. did utilize staticboxes correctly? need run properly? utilize nested sizers layout looks nice ;).

import wx class mainwindow(wx.frame): '''test frame''' def __init__(self,*args,**kwargs): '''constructor''' super(mainwindow,self).__init__(*args,**kwargs) self.panel = wx.panel(self) self.box = wx.staticbox(self.panel, wx.id_any, u'input value1') self.button_calc = wx.button(self.panel, wx.id_any, label=u'calc_xy') self.bind(wx.evt_button, self.calculate, self.button_calc) self._layout() def _layout(self): box_sizer = wx.staticboxsizer(self.box, wx.vertical) sizer = wx.gridbagsizer() inside_the_box = wx.gridbagsizer() box_sizer.add(inside_the_box, 5, wx.all, 5) sizer.add(box_sizer, (0, 0), (2, 2), wx.expand) sizer.add(self.button_calc, (2, 0)) self.panel.setsizerandfit(sizer) def calculate(self, event): print '5' self._layout() if __name__ == '__main__': app = wx.app() frame = mainwindow(none, -1, 'test window') frame.show() app.mainloop()

you calling self._layout() in __init__ method, , works corectly me in there.

then when click button phone call self._layout 1 time again , @ point trying assign self.box new box_sizer assigned sizer hence segfault.

python segmentation-fault wxpython

No comments:

Post a Comment