source: trunk/GSASIItestplot.py @ 3173

Last change on this file since 3173 was 2551, checked in by vondreele, 9 years ago

clean up G2imageGUI
Add start on autoSpot mask - not complete
some adjustments of window sizes

  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Author Revision URL Id
File size: 2.2 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.App()
34        self.frame = wx.Frame(None,-1,'Plotter', size=wx.Size(600,600),
35            style=wx.DEFAULT_FRAME_STYLE ^ wx.CLOSE_BOX)
36        self.status = self.frame.CreateStatusBar()
37        self.status.SetStatusText('Use K-box to set plot controls')
38        wx.Panel.__init__(self, self.frame, id=id)
39        self.nb = wx.aui.AuiNotebook(self,
40            style=wx.aui.AUI_NB_DEFAULT_STYLE ^ wx.aui.AUI_NB_CLOSE_ON_ACTIVE_TAB)
41        sizer = wx.BoxSizer()
42        sizer.Add(self.nb, 1, wx.EXPAND)
43        self.SetSizer(sizer)
44
45    def Show(self):
46        self.frame.Show()
47
48    def StartEventLoop(self):
49        self.Show()
50        self.app.MainLoop()
51
52    def add(self,name="plot"):
53       
54        def OnMotion(event):
55            xpos = event.xdata
56            if xpos:                                        #avoid out of frame mouse position
57                ypos = event.ydata
58                self.status.SetStatusText('X= %.2f Y= %.2f'%(xpos,ypos))
59               
60        page = Plot(self.nb)
61        page.canvas.mpl_connect('motion_notify_event', OnMotion)
62        self.nb.AddPage(page,name)
63        return page.figure
Note: See TracBrowser for help on using the repository browser.