我有同樣的問題,如。
它有效,但這個數字不能覆蓋整個框架;所以我改變了他的面板的大小和位置。現在的問題是,我的身材仍然和我的身材一樣大,因此我只改變了面板尺寸,我的身材被「剪裁」了。我該如何解決這個問題?
爲了更好地理解這個例子:我的框架是800x600,在這個框架內我的圖形只有400x300的尺寸。嵌入matplotlib圖並改變其大小
編輯:
import wx
from numpy import arange, sin, pi
import matplotlib
#matplotlib.use('WXAgg')
from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg as FigureCanvas
from matplotlib.backends.backend_wx import NavigationToolbar2Wx
from matplotlib.figure import Figure
class MainFrame(wx.Frame):
def __init__(self):
wx.Frame.__init__(self, None, wx.ID_ANY,
"Pyramid App",size=(800,600),pos=((wx.DisplaySize()[0]-800)/2,(wx.DisplaySize()[1]-600)/2),style= wx.SYSTEM_MENU | wx.CAPTION | wx.MINIMIZE_BOX | wx.CLOSE_BOX)
self.PageThree = pageThree(self)
class pageThree(wx.Panel):
def __init__(self, parent):
wx.Panel.__init__(self, parent=parent,size=(800,525))
self.myparent=parent
self.pageThree=wx.Panel(self,size=(800,525)) # put some elements at this panel
self.pylabfigure = wx.Panel(self,size=(440,420),pos=(350,105)) # this is the panel for my figure
self.drawPylabFigure()
self.draw()
def drawPylabFigure(self):
self.figure = Figure()
self.axes = self.figure.add_subplot(111)
self.canvas = FigureCanvas(self.pylabfigure, -1, self.figure)
self.sizer = wx.BoxSizer(wx.VERTICAL)
self.sizer.Add(self.canvas, 1, wx.LEFT | wx.TOP | wx.GROW)
self.SetSizer(self.sizer)
self.Fit()
def draw(self):
#example drawing
t = arange(0.0, 3.0, 0.01)
s = sin(2 * pi * t)
self.axes.plot(t, s)
if __name__ == "__main__":
app = wx.App()
MainFrame().Show()
app.MainLoop()
pls.show一些代碼 – joaquin
對不起,我編輯。 – Munchkin