Rev 585 |
Rev 587 |
Go to most recent revision |
Blame |
Compare with Previous |
Last modification |
View Log
| RSS feed
#!/usr/bin/env python
# -*- coding: iso-8859-15 -*-
# generated by wxGlade 0.6.3 on Thu Sep 24 15:46:36 2009
import sys
import wx
import wx.lib
import wx.lib.plot
# Needs Numeric or numarray or NumPy
try:
import numpy.oldnumeric as _Numeric
except:
try:
import numarray as _Numeric #if numarray is used it is renamed Numeric
except:
try:
import Numeric as _Numeric
except:
msg= """
This module requires the Numeric/numarray or NumPy module,
which could not be imported. It probably is not installed
(it's not part of the standard Python distribution). See the
Numeric Python site (http://numpy.scipy.org) for information on
downloading source or binaries."""
raise ImportError, "Numeric,numarray or NumPy not found. \n" + msg
# begin wxGlade: extracode
# end wxGlade
class wxFrame(wx.Panel):
def __init__(self, *args, **kwds):
# content of this block not found: did you rename this class?
pass
def __set_properties(self):
# content of this block not found: did you rename this class?
pass
def __do_layout(self):
# content of this block not found: did you rename this class?
pass
# end of class wxFrame
class MyFrame(wx.Frame):
def __init__(self, *args, **kwds):
# content of this block not found: did you rename this class?
pass
def __set_properties(self):
# content of this block not found: did you rename this class?
pass
def __do_layout(self):
# content of this block not found: did you rename this class?
pass
# end of class MyFrame
class MainFrame(wx.Frame):
def __init__(self, *args, **kwds):
# begin wxGlade: MainFrame.__init__
kwds["style"] = wx.DEFAULT_FRAME_STYLE
wx.Frame.__init__(self, *args, **kwds)
self.Port = wx.StaticText(self, -1, "Port")
self.text_ctrl_1 = wx.TextCtrl(self, -1, "")
self.label_5 = wx.StaticText(self, -1, "label_5")
self.text_ctrl_5 = wx.TextCtrl(self, -1, "")
self.label_2 = wx.StaticText(self, -1, "Motor(s)")
self.text_ctrl_2 = wx.TextCtrl(self, -1, "")
self.label_6 = wx.StaticText(self, -1, "label_6")
self.text_ctrl_6 = wx.TextCtrl(self, -1, "")
self.label_3 = wx.StaticText(self, -1, "Channel(s)")
self.text_ctrl_3 = wx.TextCtrl(self, -1, "")
self.label_7 = wx.StaticText(self, -1, "label_7")
self.text_ctrl_7 = wx.TextCtrl(self, -1, "")
self.label_4 = wx.StaticText(self, -1, "Speed(s)")
self.text_ctrl_4 = wx.TextCtrl(self, -1, "")
self.label_8 = wx.StaticText(self, -1, "label_8")
self.text_ctrl_8 = wx.TextCtrl(self, -1, "")
self.button_1 = wx.Button(self, -1, "button_1")
self.GraphFanel = wx.Panel(self, -1)
self.TestListCtrl = wx.ListCtrl(self, -1, style=wx.LC_REPORT|wx.SUNKEN_BORDER)
self.__set_properties()
self.__do_layout()
# end wxGlade
def __set_properties(self):
# begin wxGlade: MainFrame.__set_properties
self.SetTitle("frame_1")
self.GraphFanel.SetMinSize((800,300))
# end wxGlade
def __do_layout(self):
# begin wxGlade: MainFrame.__do_layout
sizer_1 = wx.BoxSizer(wx.VERTICAL)
grid_sizer_2 = wx.GridSizer(2, 1, 4, 4)
grid_sizer_1 = wx.GridSizer(5, 4, 4, 4)
grid_sizer_1.Add(self.Port, 0, wx.ALIGN_RIGHT, 0)
grid_sizer_1.Add(self.text_ctrl_1, 0, 0, 0)
grid_sizer_1.Add(self.label_5, 0, wx.ALIGN_RIGHT, 0)
grid_sizer_1.Add(self.text_ctrl_5, 0, 0, 0)
grid_sizer_1.Add(self.label_2, 0, wx.ALIGN_RIGHT, 0)
grid_sizer_1.Add(self.text_ctrl_2, 0, 0, 0)
grid_sizer_1.Add(self.label_6, 0, wx.ALIGN_RIGHT, 0)
grid_sizer_1.Add(self.text_ctrl_6, 0, 0, 0)
grid_sizer_1.Add(self.label_3, 0, wx.ALIGN_RIGHT, 0)
grid_sizer_1.Add(self.text_ctrl_3, 0, 0, 0)
grid_sizer_1.Add(self.label_7, 0, wx.ALIGN_RIGHT, 0)
grid_sizer_1.Add(self.text_ctrl_7, 0, 0, 0)
grid_sizer_1.Add(self.label_4, 0, wx.ALIGN_RIGHT, 0)
grid_sizer_1.Add(self.text_ctrl_4, 0, 0, 0)
grid_sizer_1.Add(self.label_8, 0, wx.ALIGN_RIGHT, 0)
grid_sizer_1.Add(self.text_ctrl_8, 0, 0, 0)
grid_sizer_1.Add(self.button_1, 0, 0, 0)
sizer_1.Add(grid_sizer_1, 0, 0, 2)
sizer_1.Add(self.GraphFanel, 0, wx.EXPAND, 0)
grid_sizer_2.Add(self.TestListCtrl, 1, wx.ALL|wx.EXPAND, 0)
sizer_1.Add(grid_sizer_2, 1, wx.EXPAND, 0)
self.SetSizer(sizer_1)
sizer_1.Fit(self)
self.Layout()
# end wxGlade
# Configure Graph
self.client = wx.lib.plot.PlotCanvas(self.GraphFanel)
self.client.SetPointLabelFunc(self.DrawPointLabel)
self.client.SetFont(wx.Font(10,wx.SWISS,wx.NORMAL,wx.NORMAL))
self.client.SetFontSizeAxis(10)
self.client.SetFontSizeLegend(7)
self.client.setLogScale((False,False))
self.client.SetXSpec('auto')
self.client.SetYSpec('auto')
data1 = 2.*_Numeric.pi*_Numeric.arange(200)/200.
data1.shape = (100, 2)
data1[:,1] = _Numeric.sin(data1[:,0])
markers1 = wx.lib.plot.PolyMarker(data1, legend='Green Markers', colour='green', marker='circle',size=1)
pi = 3.1415
markers2 = wx.lib.plot.PolyMarker([(0., 0.), (pi/4., 1.), (pi/2, 0.),
(3.*pi/4., -1)], legend='Cross Legend', colour='blue',
marker='cross')
self.client.Draw(wx.lib.plot.PlotGraphics([markers1,markers2],"Graph Title", "X Axis", "Y Axis"))
# Configure TestListCtrl
self.TestListCtrl.InsertColumn(0, "Name")
self.TestListCtrl.InsertColumn(1, "Result")
def DrawPointLabel(self, dc, mDataDict):
"""This is the fuction that defines how the pointLabels are plotted
dc - DC that will be passed
mDataDict - Dictionary of data that you want to use for the pointLabel
As an example I have decided I want a box at the curve point
with some text information about the curve plotted below.
Any wxDC method can be used.
"""
# ----------
dc.SetPen(wx.Pen(wx.BLACK))
dc.SetBrush(wx.Brush( wx.BLACK, wx.SOLID ) )
sx, sy = mDataDict["scaledXY"] #scaled x,y of closest point
dc.DrawRectangle( sx-5,sy-5, 10, 10) #10by10 square centered on point
px,py = mDataDict["pointXY"]
cNum = mDataDict["curveNum"]
pntIn = mDataDict["pIndex"]
legend = mDataDict["legend"]
#make a string to display
s = "Crv# %i, '%s', Pt. (%.2f,%.2f), PtInd %i" %(cNum, legend, px, py, pntIn)
dc.DrawText(s, sx , sy+1)
# -----------
# end of class MainFrame
class VibTest:
def __init__(self, name, rawData):
self.name = name
self.rawData = rawData
class App(wx.App):
def __init__(self, par):
print "A"
self.VibTests = []
wx.App.__init__(self, par)
def AddTest(self, name, rawData):
test = VibTest(name, rawData)
self.VibTests.append(test)
index = self.frame_1.TestListCtrl.InsertStringItem(sys.maxint, test.name)
self.frame_1.TestListCtrl.SetStringItem(index, 1, "OK")
def OnInit(self):
wx.InitAllImageHandlers()
self.frame_1 = MainFrame(None, -1, "")
self.SetTopWindow(self.frame_1)
print "B"
self.AddTest("Test1", range(0,1000))
self.AddTest("Test2", range(0,1000))
self.frame_1.Show()
return 1
# end of class App
if __name__ == "__main__":
VibrationTestGui = App(0)
VibrationTestGui.MainLoop()