-
Notifications
You must be signed in to change notification settings - Fork 0
/
untitled9.py
52 lines (39 loc) · 1.39 KB
/
untitled9.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import wx
import wx.lib.agw.aui as aui
import wx.lib.mixins.inspection as wit
import numpy as np
from numba import vectorize, cuda
import matplotlib as mpl
from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg as FigureCanvas
from matplotlib.backends.backend_wxagg import NavigationToolbar2WxAgg as NavigationToolbar
class Plot(wx.Panel):
def __init__(self, parent, id=-1, dpi=None, **kwargs):
wx.Panel.__init__(self, parent, id=id, **kwargs)
x = np.linspace(0,50., num=100)
X,Y = np.meshgrid(x,x)
self.wxBitmapFromBits(X,Y)
class PlotNotebook(wx.Panel):
def __init__(self, parent, id=-1):
wx.Panel.__init__(self, parent, id=id)
self.nb = aui.AuiNotebook(self)
sizer = wx.BoxSizer()
sizer.Add(self.nb, 1, wx.EXPAND)
self.SetSizer(sizer)
def add(self, name="plot"):
page = Plot(self.nb)
self.nb.AddPage(page, name)
def draw():
x = np.linspace(0,50., num=100)
X,Y = np.meshgrid(x,x)
def demo():
# alternatively you could use
#app = wx.App()
# InspectableApp is a great debug tool, see:
# http://wiki.wxpython.org/Widget%20Inspection%20Tool
app = wit.InspectableApp()
frame = wx.Frame(None, -1, 'Plotter')
plotter = PlotNotebook(frame)
frame.Show()
app.MainLoop()
if __name__ == "__main__":
demo()