Subversion Repositories Projects

Compare Revisions

Ignore whitespace Rev 611 → Rev 612

/VibrationTest/trunk/VibrationTest/VibrationTestGui.py
4,10 → 4,14
 
import sys
import os
import time
import thread
import ConfigParser
 
import wx
import wx.lib
import wx.lib.plot
import ConfigParser
import wx.lib.newevent
 
# Needs Numeric or numarray or NumPy
try:
31,7 → 35,63
# end wxGlade
 
 
# This creates a new Event class and a EVT binder function
(MeasStatusUpdateEvent, EVT_MEAS_STATUS_UPDATE) = wx.lib.newevent.NewEvent()
 
class MeasureDialog(wx.Dialog):
def __init__(self, *args, **kwds):
# begin wxGlade: MeasureDialog.__init__
kwds["style"] = wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER|wx.THICK_FRAME
wx.Dialog.__init__(self, *args, **kwds)
self.text_ctrl_1 = wx.TextCtrl(self, -1, "", style=wx.TE_MULTILINE|wx.TE_READONLY|wx.HSCROLL)
self.button = wx.Button(self, -1, "STOP")
 
self.__set_properties()
self.__do_layout()
 
self.Bind(wx.EVT_BUTTON, self.onButton, self.button)
# end wxGlade
self.running = True
self.Bind(EVT_MEAS_STATUS_UPDATE, self.OnUpdate)
 
def __set_properties(self):
# begin wxGlade: MeasureDialog.__set_properties
self.SetTitle("Measuring Status")
self.text_ctrl_1.SetMinSize((400,300))
# end wxGlade
 
def __do_layout(self):
# begin wxGlade: MeasureDialog.__do_layout
sizer_1 = wx.BoxSizer(wx.HORIZONTAL)
sizer_2 = wx.BoxSizer(wx.VERTICAL)
sizer_1.Add((20, 20), 0, 0, 0)
sizer_2.Add((20, 20), 0, 0, 0)
sizer_2.Add(self.text_ctrl_1, 1, wx.EXPAND, 0)
sizer_2.Add((20, 20), 0, 0, 0)
sizer_2.Add(self.button, 0, wx.ALIGN_CENTER_HORIZONTAL, 0)
sizer_2.Add((20, 20), 0, 0, 0)
sizer_1.Add(sizer_2, 1, wx.EXPAND, 0)
sizer_1.Add((20, 20), 0, 0, 0)
self.SetSizer(sizer_1)
sizer_1.Fit(self)
self.Layout()
# end wxGlade
 
def OnUpdate(self, evt):
print "Event received"
self.running = evt.running
self.text_ctrl_1.WriteText("%s\n"%evt.msg)
if (not self.running):
self.button.SetLabel("Close")
def onButton(self, event): # wxGlade: MeasureDialog.<event_handler>
if (not self.running):
self.Destroy()
 
# end of class MeasureDialog
 
 
class SettingsDialog(wx.Dialog):
def __init__(self, *args, **kwds):
# begin wxGlade: SettingsDialog.__init__
106,70 → 166,7
# end of class SettingsDialog
 
 
class SettingsFrame(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 SettingsFrame
 
 
class MenuBar(wx.MenuBar):
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 MenuBar
 
 
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__
218,6 → 215,7
self.Bind(wx.EVT_MENU, self.OnSettings, id=101)
self.Bind(wx.EVT_MENU, self.onClear, id=301)
self.Bind(wx.EVT_MENU, self.OnImport, id=302)
self.Bind(wx.EVT_BUTTON, self.onStartMeasure, self.button_4)
self.Bind(wx.EVT_CHOICE, self.onGraphTypeChange, self.graphTypeChoice)
self.Bind(wx.EVT_CHOICE, self.onYAxisChange, self.yAxisChoice)
# end wxGlade
441,6 → 439,17
dlg.Destroy()
self.app.onSettingsChanged()
 
def onStartMeasure(self, event): # wxGlade: MainFrame.<event_handler>
# create the dialog that will show the satus
dlg = MeasureDialog(self)
dlg.CenterOnScreen()
# Signal that application
self.app.startMeasure(dlg)
# Show the dialog
val = dlg.ShowModal() # this does not return until the dialog is closed.
dlg.Destroy()
 
# end of class MainFrame
 
class Setting:
454,6 → 463,25
else:
self.value = str(newValue)
 
 
class MeasureThread:
def __init__(self, evtConsumer):
self.evtConsumer = evtConsumer
def start(self):
thread.start_new_thread(self._run, ())
def _run(self):
i=0
for i in range(20):
time.sleep(0.5)
evt = MeasStatusUpdateEvent(running=True, msg="Hello %d" % i)
wx.PostEvent(self.evtConsumer, evt)
evt = MeasStatusUpdateEvent(running=False, msg="Done")
wx.PostEvent(self.evtConsumer, evt)
 
class VibTest:
def __init__(self, descr, motor, speed, channel, rawData):
self.descr = descr
608,8 → 636,17
if (len(data[c]) % 2) != 0:
data[c].append(data[c][-1])
self.AddTest(descr[c], 0, int(speed[c]), channel[c], data[c])
def startMeasure(self, dialog):
print "Start measuring"
self.measureThread = MeasureThread(dialog)
self.measureThread.start()