source: sasview/src/examples/test_text_panel.py @ 9c2eeb1

ESS_GUIESS_GUI_DocsESS_GUI_batch_fittingESS_GUI_bumps_abstractionESS_GUI_iss1116ESS_GUI_iss879ESS_GUI_iss959ESS_GUI_openclESS_GUI_orderingESS_GUI_sync_sascalccostrafo411magnetic_scattrelease-4.1.1release-4.1.2release-4.2.2ticket-1009ticket-1094-headlessticket-1242-2d-resolutionticket-1243ticket-1249ticket885unittest-saveload
Last change on this file since 9c2eeb1 was d7bb526, checked in by Piotr Rozyczko <piotr.rozyczko@…>, 9 years ago

Refactored plottools into sasgui

  • Property mode set to 100755
File size: 3.2 KB
RevLine 
[3a39c2e]1"""
2Test application that uses plottools
3
4An application required by the REFL group and mainly test the Chisq class.
5   
6The following is a checklist of functionality to look for while testing:
71- Start the application:
8   the graph should have theory curve, experimental data, chisq
9   with a white background.
10
112- Hovering over any plotted data will highlight the whole data set
12   or line in yellow.
13
143- Left-clicking on the graph and dragging will drag the graph.
15
164- Using the mouse wheel will zoom in and out of the graph.
17
185- Right-clicking on the graph when no curve is highlighted will
19   pop up the context menu:
20   - 'Save image' will pop up a save dialog to save an image.
21   - 'Reset graph' will reset the graph to its original appearance after it
22                   has been dragged around or zoomed in or out.
23   - 'Change scale' will pop up a scale dialog with which the axes can
24                    be transformed. Each transformation choice should work.
25
26"""
27
28import wx
[d7bb526]29from sas.sasgui.plottools.PlotPanel import PlotPanel
30from sas.sasgui.plottools.plottables import Text, Graph
[3a39c2e]31
32class TestPlotPanel(PlotPanel):
33   
34    def __init__(self, parent, id = -1,
35                 color = None,
36                 dpi = None,
37                 **kwargs):
38        PlotPanel.__init__(self, parent, id=id, color=color,
39                           dpi=dpi, **kwargs)
40       
41        # Keep track of the parent Frame
42        self.parent = parent
43       
44        # Internal list of plottable names (because graph
45        # doesn't have a dictionary of handles for the plottables)
46        self.plots = {}
47       
48               
49    def onContextMenu(self, event):
50        """
51        Default context menu for a plot panel
52        """
53        # Slicer plot popup menu
54        id = wx.NewId()
55        _menu = wx.Menu()
56        _menu.Append(id,'&Save image', 'Save image as PNG')
57        wx.EVT_MENU(self, id, self.onSaveImage)
58       
59        _menu.AppendSeparator()
60        id = wx.NewId()
61        _menu.Append(id, '&Change scale')
62        wx.EVT_MENU(self, id, self._onProperties)
63       
64        id = wx.NewId()
65        _menu.Append(id, '&Reset Graph')
66        wx.EVT_MENU(self, id, self.onResetGraph)
67 
68        pos = event.GetPosition()
69        pos = self.ScreenToClient(pos)
70        self.PopupMenu(slicerpop, pos)
71       
72
73# ---------------------------------------------------------------
74def sample_graph():
75    # Construct a simple graph
76   
77    T1 = Text(text='text example 1', xpos=0.2, ypos=0.2)
78    T2 = Text(text='text example 2', xpos=0.5, ypos=0.5)
79    T3 = Text(text=r'$\chi^2=1.2$', xpos=0.8, ypos=0.8)
80   
81    graph = Graph()
82    graph.title( 'Test Text Class' )
83    graph.add( T1 )
84    graph.add( T2 ) 
85    graph.add( T3 )
86    return graph
87
88
89def demo_plotter(graph):
90    # Make a frame to show it
91    app     = wx.PySimpleApp()
92    frame   = wx.Frame(None,-1,'Plottables')
93    plotter = TestPlotPanel(frame)
94    frame.Show()
95
96    # render the graph to the pylab plotter
97    graph.render(plotter)
98   
99    app.MainLoop()
100
101   
102if __name__ == "__main__":
103    demo_plotter(sample_graph())
104
105           
Note: See TracBrowser for help on using the repository browser.