source: trunk/GSASIItestplot.py @ 1112

Last change on this file since 1112 was 1112, checked in by toby, 8 years ago

corrections example; expand docs

  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Author Revision URL Id
File size: 1.6 KB
Line 
1# -*- coding: utf-8 -*-
2#GSASIItestplot.py
3'''
4*GSASIItestplot: Plotting for testDeriv*
5========================================
6
7Plotting module used for script testDeriv.
8'''
9import wx
10import wx.aui
11import matplotlib as mpl
12from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg as Canvas
13from matplotlib.backends.backend_wxagg import NavigationToolbar2Wx as Toolbar
14
15class Plot(wx.Panel):
16    'Creates a plotting window'
17    def __init__(self, parent, id = -1, dpi = None, **kwargs):
18        wx.Panel.__init__(self, parent, id=id, **kwargs)
19        self.figure = mpl.figure.Figure(dpi=dpi, #figsize=(5,7)
20                                        )
21        self.canvas = Canvas(self, -1, self.figure)
22        self.toolbar = Toolbar(self.canvas)
23        self.toolbar.Realize()
24
25        sizer = wx.BoxSizer(wx.VERTICAL)
26        sizer.Add(self.canvas,1,wx.EXPAND)
27        sizer.Add(self.toolbar, 0 , wx.LEFT | wx.EXPAND)
28        self.SetSizer(sizer)
29
30class PlotNotebook(wx.Panel):
31    'creates a Wx application and a plotting notebook'
32    def __init__(self, id = -1):
33        self.app = wx.PySimpleApp()
34        self.frame = wx.Frame(None,-1,'Plotter', size=wx.Size(600,600))
35        wx.Panel.__init__(self, self.frame, id=id)
36        self.nb = wx.aui.AuiNotebook(self)
37        sizer = wx.BoxSizer()
38        sizer.Add(self.nb, 1, wx.EXPAND)
39        self.SetSizer(sizer)
40
41    def Show(self):
42        self.frame.Show()
43
44    def StartEventLoop(self):
45        self.Show()
46        self.app.MainLoop()
47
48    def add(self,name="plot"):
49       page = Plot(self.nb)
50       self.nb.AddPage(page,name)
51       return page.figure
Note: See TracBrowser for help on using the repository browser.