python - FigureCanvasWxAgg not resizing properly in panel (or notebook) in linux -
i've written program in wxpython works fine in windows when tested in lunix have display issues that occur in linux.
here testapp demonstrates problem resizing of figurecanvaswxagg in panel, seen panel self follows resizingevent figurecanvaswxagg doesn't follow, not problem in windows.
import wx import matplotlib.figure plt matplotlib.backends.backend_wxagg import figurecanvaswxagg figurecanvas import wx.lib.inspection class test(wx.frame): def __init__(self): super(test, self).__init__(parent=none, id=-1) self.figure = plt.figure() self.panel = wx.panel(self, 1) self.figurepanel = figurecanvas(self.panel, -1, self.figure) self.axes1 = self.figure.add_subplot(111) frame_box = wx.boxsizer(wx.vertical) frame_box.addstretchspacer(prop=1) frame_box.add(self.panel, flag=wx.expand, proportion=2) frame_box.addstretchspacer(prop=1) main_box = wx.boxsizer(wx.horizontal) main_box.addstretchspacer(prop=1) main_box.add(frame_box, flag=wx.expand, proportion=1) main_box.addstretchspacer(prop=1) self.setsizer(main_box) self.show() self.layout() def main(): app = wx.app() test() wx.lib.inspection.inspectiontool().show() app.mainloop() if __name__ == '__main__': main() what grateful have answered is:
- how resolve issue of reszing figurecanvaswxagg in linux
- is there difference in general way of gui programming wxpython on windows , in linux
there several issues code posted:
- you have horizontal , vertical spacer expand needed, causes central region remain same shape
self.figurepanelnot part of sizer, means not resize if container,self.paneldoes.
the code below produces window filled plot resizes window:
import wx import matplotlib.figure plt matplotlib.backends.backend_wxagg import figurecanvaswxagg figurecanvas import wx.lib.inspection class test(wx.frame): def __init__(self): super(test, self).__init__(parent=none, id=-1) self.panel = wx.panel(self, 1) self.panel.setbackgroundcolour('red') self.figure = plt.figure() self.axes1 = self.figure.add_subplot(111) self.figurepanel = figurecanvas(self.panel, -1, self.figure) main_box = wx.boxsizer(wx.horizontal) main_box.add(self.figurepanel, flag=wx.expand, proportion=1) self.panel.setsizer(main_box) frame_box = wx.boxsizer(wx.vertical) frame_box.add(self.panel, flag=wx.expand, proportion=1) self.setsizer(frame_box) self.show() self.layout() def main(): app = wx.app() test() wx.lib.inspection.inspectiontool().show() app.mainloop() if __name__ == '__main__': main() there no need manual resizing yourself, , there no problem, think, resize event propagation. if there there lot more breakage seeing.
Comments
Post a Comment