wx.Panel 上的 PlotCanvas?
我在使用 wx.lib.plot.PlotCanvas
模块时遇到困难,无法将其显示在面板中。有人可以帮助我理解我做错了什么吗?
#!/usr/bin/python
import wx
import logging
import wx.lib.plot as plot
class PlotCanvasExample(wx.Panel):
def __init__(self, parent, id, size):
''' Initialization routine for the this panel.'''
wx.Panel.__init__(self, parent, id, style=wx.BORDER_NONE, size=desiredSize)
self.data = [(1,2), (2,3), (3,5), (4,6), (5,8), (6,8), (10,10)]
canvas = plot.PlotCanvas(self, size=desiredSize)
line = plot.PolyLine(self.data, legend='', colour='pink', width=2)
gc = plot.PlotGraphics([line], 'Line Graph', 'X Axis', 'Y Axis')
canvas.Draw(gc, xAxis=(0,15), yAxis=(0,15))
if __name__ == '__main__':
''' Simple main program to display this panel. '''
# Create a simple wxFrame to insert the panel into
desiredSize = wx.Size(300,200)
app = wx.App()
frame = wx.Frame(None, -1, 'PlotCanvasExample', size=desiredSize)
example = PlotCanvasExample(frame, -1, size=desiredSize)
frame.Show()
app.MainLoop()
I'm having difficulties with the wx.lib.plot.PlotCanvas
module, getting it to display in a panel. Can someone please help me understand what I'm doing wrong?
#!/usr/bin/python
import wx
import logging
import wx.lib.plot as plot
class PlotCanvasExample(wx.Panel):
def __init__(self, parent, id, size):
''' Initialization routine for the this panel.'''
wx.Panel.__init__(self, parent, id, style=wx.BORDER_NONE, size=desiredSize)
self.data = [(1,2), (2,3), (3,5), (4,6), (5,8), (6,8), (10,10)]
canvas = plot.PlotCanvas(self, size=desiredSize)
line = plot.PolyLine(self.data, legend='', colour='pink', width=2)
gc = plot.PlotGraphics([line], 'Line Graph', 'X Axis', 'Y Axis')
canvas.Draw(gc, xAxis=(0,15), yAxis=(0,15))
if __name__ == '__main__':
''' Simple main program to display this panel. '''
# Create a simple wxFrame to insert the panel into
desiredSize = wx.Size(300,200)
app = wx.App()
frame = wx.Frame(None, -1, 'PlotCanvasExample', size=desiredSize)
example = PlotCanvasExample(frame, -1, size=desiredSize)
frame.Show()
app.MainLoop()
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是通过子类化 PlotCanvas 来实现的。
我没有将其放在面板中,而是直接放在框架中
This works by subclassing PlotCanvas.
I do not put it in a panel but directly in the Frame