VisionEgg.PyroApps.ColorCalGUI

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

# Source Code for Module VisionEgg.PyroApps.ColorCalGUI

     1  #!/usr/bin/env python
     2  #
     3  # The Vision Egg: ColorCalGUI
     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  """Handle luminance and color calibration stimulus (client-side)"""
    15
    16  import VisionEgg, string
    17  __version__ = VisionEgg.release_name
    18  __cvs__ = string.split('$Revision$')[1]
    19  __date__ = string.join(string.split('$Date$')[1:3], ' ')
    20  __author__ = 'Andrew Straw <astraw@users.sourceforge.net>'
    21
    22  import sys, os
    23  import Tkinter
    24  import VisionEgg.PyroApps.EPhysGUIUtils as client_utils
    25
    26 -def get_control_list():
    27      return [("color_cal_server",ColorCalControlFrame,ColorCalControlFrame.title)]
    28
    29 -class ColorCalMetaParameters:
    30 -    def __init__(self):
    31          self.color = (1.0, 1.0, 1.0, 0.0)
    32
    33 -class ColorCalControlFrame(client_utils.StimulusControlFrame):
    34      title = "Color Calibration"
    35 -    def __init__(self, master=None, suppress_go_buttons=0,**kw):
    36          client_utils.StimulusControlFrame.__init__(self,
    37                                                     master,
    38                                                     suppress_go_buttons,
    39                                                     ColorCalControlFrame.title,
    40                                                     ColorCalMetaParameters,
    41                                                     **kw)
    42
    43          param_frame = self.param_frame # shorthand for self.param_frame created in base class
    44
    45          # Allow columns to expand
    46          param_frame.columnconfigure(0,weight=1)
    47          param_frame.columnconfigure(1,weight=1)
    48
    49          pf_row = 0
    50          Tkinter.Label(param_frame,text="Red:").grid(row=pf_row,column=0)
    51          self.red_tk_var = Tkinter.DoubleVar()
    52          self.red_tk_var.set(self.meta_params.color[0])
    53          self.make_callback_entry(textvariable=self.red_tk_var).grid(row=pf_row,column=1)
    54
    55          pf_row += 1
    56          Tkinter.Label(param_frame,text="Green:").grid(row=pf_row,column=0)
    57          self.green_tk_var = Tkinter.DoubleVar()
    58          self.green_tk_var.set(self.meta_params.color[1])
    59          self.make_callback_entry(textvariable=self.green_tk_var).grid(row=pf_row,column=1)
    60
    61          pf_row += 1
    62          Tkinter.Label(param_frame,text="Blue:").grid(row=pf_row,column=0)
    63          self.blue_tk_var = Tkinter.DoubleVar()
    64          self.blue_tk_var.set(self.meta_params.color[2])
    65          self.make_callback_entry(textvariable=self.blue_tk_var).grid(row=pf_row,column=1)
    66
    67 -    def get_shortname(self):
    68          return "color_cal"
    69
    70 -    def update_tk_vars(self):
    71          self.red_tk_var.set( self.meta_params.color[0] )
    72          self.green_tk_var.set( self.meta_params.color[1] )
    73          self.blue_tk_var.set( self.meta_params.color[2] )
    74
    75 -    def send_values(self,dummy_arg=None):
    76          self.meta_params.color =  ( self.red_tk_var.get(),
    77                                      self.green_tk_var.get(),
    78                                      self.blue_tk_var.get(),
    79                                      0.0 )
    80
    81          if self.connected:
    82              self.meta_controller.set_parameters( self.meta_params )
    83
    84 -    def get_duration_sec(self):
    85          return 0.0
    86
    87  if __name__=='__main__':
    88      frame = ColorCalControlFrame()
    89      frame.pack(expand=1,fill=Tkinter.BOTH)
    90      frame.winfo_toplevel().title("%s"%(os.path.basename(os.path.splitext(sys.argv[0])[0]),))
    91      frame.mainloop()
    92