Package VisionEgg :: Package PyroApps :: Module SpinningDrumGUI |
[frames] | no frames]

# Source Code for Module VisionEgg.PyroApps.SpinningDrumGUI

      1  #!/usr/bin/env python
      2  #
      3  # The Vision Egg: SpinningDrumGUI
      4  #
      5  # Copyright (C) 2001-2003 Andrew Straw.
      6  # Author: Andrew Straw <astraw@users.sourceforge.net>
      7  # URL: <http://www.visionegg.org/>
      8  #
      9  # Distributed under the terms of the GNU Lesser General Public License
     10  # (LGPL). See LICENSE.TXT that came with this file.
     11  #
     12  # $Id$
     13
     14  import VisionEgg, string
     15  __version__ = VisionEgg.release_name
     16  __cvs__ = string.split('$Revision$')[1]
     17  __date__ = string.join(string.split('$Date$')[1:3], ' ')
     18  __author__ = 'Andrew Straw <astraw@users.sourceforge.net>'
     19
     20  import sys, os
     21  import Tkinter
     22  import VisionEgg.PyroApps.EPhysGUIUtils as client_utils
     23
     24 -def get_control_list():
     25      return [("spinning_drum_server",SpinningDrumControlFrame,SpinningDrumControlFrame.title)]
     26
     27 -class SpinningDrumMetaParameters:
     28 -    def __init__(self):
     29          self.contrast = 1.0
     30          self.velocity_dps = 100.0
     31          self.startpos_deg = 0.0
     32          self.pre_stim_sec = 1.0
     33          self.stim_sec = 5.0
     34          self.post_stim_sec = 1.0
     35
     36 -class SpinningDrumControlFrame(client_utils.StimulusControlFrame):
     37      title = "Spinning Drum Experiment"
     38 -    def __init__(self, master=None, suppress_go_buttons=0,**kw):
     39          client_utils.StimulusControlFrame.__init__(self,
     40                                                     master,
     41                                                     suppress_go_buttons,
     42                                                     SpinningDrumControlFrame.title,
     43                                                     SpinningDrumMetaParameters,
     44                                                     **kw)
     45
     46          param_frame = self.param_frame # shorthand for self.param_frame created in base class
     47
     48          # Allow columns to expand
     49          param_frame.columnconfigure(0,weight=1)
     50          param_frame.columnconfigure(1,weight=1)
     51
     52          pf_row = 0
     53          Tkinter.Label(param_frame,text="Contrast:").grid(row=pf_row,column=0)
     54          self.contrast_tk_var = Tkinter.DoubleVar()
     55          self.contrast_tk_var.set(self.meta_params.contrast)
     56          self.make_callback_entry(textvariable=self.contrast_tk_var).grid(row=pf_row,column=1)
     57          self.loopable_variables["Contrast"] = ("contrast",self.contrast_tk_var)
     58
     59          pf_row += 1
     60          Tkinter.Label(param_frame,text="Velocity (dps):").grid(row=pf_row,column=0)
     61          self.velocity_tk_var = Tkinter.DoubleVar()
     62          self.velocity_tk_var.set(self.meta_params.velocity_dps)
     63          self.make_callback_entry(textvariable=self.velocity_tk_var).grid(row=pf_row,column=1)
     64          self.loopable_variables["Velocity"] = ("velocity_dps",self.velocity_tk_var)
     65
     66          pf_row += 1
     67          Tkinter.Label(param_frame,text="Start position (deg):").grid(row=pf_row,column=0)
     68          self.startpos_tk_var = Tkinter.DoubleVar()
     69          self.startpos_tk_var.set(self.meta_params.startpos_deg)
     70          self.make_callback_entry(textvariable=self.startpos_tk_var).grid(row=pf_row,column=1)
     71          self.loopable_variables["Start position"] = ("startpos_deg",self.startpos_tk_var)
     72
     73          pf_row += 1
     74          Tkinter.Label(param_frame,text="Pre stimulus duration (sec):").grid(row=pf_row,column=0)
     75          self.prestim_dur_tk_var = Tkinter.DoubleVar()
     76          self.prestim_dur_tk_var.set(self.meta_params.pre_stim_sec)
     77          self.make_callback_entry(textvariable=self.prestim_dur_tk_var).grid(row=pf_row,column=1)
     78
     79          pf_row += 1
     80          Tkinter.Label(param_frame,text="Stimulus duration (sec):").grid(row=pf_row,column=0)
     81          self.stim_dur_tk_var = Tkinter.DoubleVar()
     82          self.stim_dur_tk_var.set(self.meta_params.stim_sec)
     83          self.make_callback_entry(textvariable=self.stim_dur_tk_var).grid(row=pf_row,column=1)
     84
     85          pf_row += 1
     86          Tkinter.Label(param_frame,text="Post stimulus duration (sec):").grid(row=pf_row,column=0)
     87          self.poststim_dur_tk_var = Tkinter.DoubleVar()
     88          self.poststim_dur_tk_var.set(self.meta_params.post_stim_sec)
     89          self.make_callback_entry(textvariable=self.poststim_dur_tk_var).grid(row=pf_row,column=1)
     90
     91 -    def get_shortname(self):
     92          """Used as basename for saving parameter files"""
     93          return "spinning_drum"
     94
     95 -    def update_tk_vars(self):
     96          self.contrast_tk_var.set( self.meta_params.contrast )
     97          self.velocity_tk_var.set( self.meta_params.velocity_dps )
     98          self.startpos_tk_var.set( self.meta_params.startpos_deg )
     99          self.stim_dur_tk_var.set( self.meta_params.stim_sec )
    100          self.poststim_dur_tk_var.set( self.meta_params.post_stim_sec )
    101
    102 -    def send_values(self,dummy_arg=None):
    103          self.meta_params.contrast = self.contrast_tk_var.get()
    104          self.meta_params.velocity_dps = self.velocity_tk_var.get()
    105          self.meta_params.startpos_deg = self.startpos_tk_var.get()
    106          self.meta_params.pre_stim_sec = self.prestim_dur_tk_var.get()
    107          self.meta_params.stim_sec = self.stim_dur_tk_var.get()
    108          self.meta_params.post_stim_sec = self.poststim_dur_tk_var.get()
    109          if self.connected:
    110              self.meta_controller.set_parameters( self.meta_params )
    111
    112 -    def get_duration_sec(self):
    113          self.meta_params.pre_stim_sec = self.prestim_dur_tk_var.get()
    114          self.meta_params.stim_sec = self.stim_dur_tk_var.get()
    115          self.meta_params.post_stim_sec = self.poststim_dur_tk_var.get()
    116          return self.meta_params.pre_stim_sec + self.meta_params.stim_sec + self.meta_params.post_stim_sec
    117
    118  if __name__=='__main__':
    119      frame = SpinningDrumControlFrame()
    120      frame.pack(expand=1,fill=Tkinter.BOTH)
    121      frame.winfo_toplevel().title("%s"%(os.path.basename(os.path.splitext(sys.argv[0])[0]),))
    122      frame.mainloop()
    123