Beispiel #1
0
    def refresh(self, event=None):
        '''
        Pulls beam settings from tao and updates the window contents
        '''
        for child in self.list_frame.winfo_children():
            child.destroy()

        beam_head_list = self.pipe.cmd_in("python beam 1")
        beam_body_list = self.pipe.cmd_in("python beam_init 1")
        #TODO: commands above should not be hardcoded to universe 1
        beam_head_list = beam_head_list.splitlines()
        beam_body_list = beam_body_list.splitlines()
        for k in range(len(beam_head_list)):
            beam_head_list[k] = tk_tao_parameter(
                str_to_tao_param(beam_head_list[k]), self.list_frame,
                self.pipe)
            beam_head_list[k].tk_label.grid(row=k, column=0, sticky='W')
            beam_head_list[k].tk_wid.grid(row=k, column=1, sticky='EW')
        b_offset = len(beam_head_list)
        for k in range(len(beam_body_list)):
            beam_body_list[k] = tk_tao_parameter(
                str_to_tao_param(beam_body_list[k]), self.list_frame,
                self.pipe)
            beam_body_list[k].tk_label.grid(row=k + b_offset,
                                            column=0,
                                            sticky='W')
            beam_body_list[k].tk_wid.grid(row=k + b_offset,
                                          column=1,
                                          sticky='EW')
        self.beam_head_list = beam_head_list
        self.beam_body_list = beam_body_list
Beispiel #2
0
 def open_detail_window(self, index):
     self.param_list = self.pipe.cmd_in("python var " + self.array_name +
                                        '[' + str(index) + ']')
     self.param_list = self.param_list.splitlines()
     for i in range(len(self.param_list)):
         self.param_list[i] = str_to_tao_param(self.param_list[i])
     if self.lw:
         lw_table_window.open_detail_window(self, index)
     else:
         table_window.open_detail_window(self, index)
Beispiel #3
0
 def __init__(self, root):
     bmad_list = root.pipe.cmd_in("python bmad_com")
     bmad_list = bmad_list.splitlines()
     for i in range(len(bmad_list)):
         bmad_list[i] = str_to_tao_param(bmad_list[i])
     tao_parameter_window.__init__(self, root, "Bmad Parameters", bmad_list,
                                   root.pipe)
     b = tk.Button(self.button_frame,
                   text="Set Bmad Parameters",
                   command=self.set_callback)
     b.pack()
Beispiel #4
0
 def __init__(self, root):
     global_list = root.pipe.cmd_in("python global")
     global_list = global_list.splitlines()
     for i in range(len(global_list)):
         global_list[i] = str_to_tao_param(global_list[i])
     tao_parameter_window.__init__(self, root, "Global Variables",
                                   global_list, root.pipe)
     b = tk.Button(self.button_frame,
                   text="Set Global Variables",
                   command=self.set_callback)
     b.pack()
Beispiel #5
0
    def __init__(self, root, pipe, v1_var_name, *args, **kwargs):
        self.tao_id = 'var'
        title_list = [
            "Index", "Name", "Meas value", "Model value", "Design value",
            "Useit_opt", "good_user", "Weight"
        ]
        bulk_template = []
        self.lw = root.lw  #set light-weight flag
        bulk_template.append([str_to_tao_param("meas_value;REAL;T;"), 2])
        bulk_template.append([str_to_tao_param("good_user;LOGIC;T;"), 6])
        bulk_template.append([str_to_tao_param("weight;REAL;T;"), 7])

        bulk_set_format = "set var {}|"
        set_format = "set var {}[{}]|"
        if self.lw:
            lw_table_window.__init__(self, root, pipe, v1_var_name, title_list,
                                     bulk_template, bulk_set_format,
                                     set_format, *args, **kwargs)
        else:
            table_window.__init__(self, root, pipe, v1_var_name, title_list,
                                  bulk_template, bulk_set_format, set_format,
                                  *args, **kwargs)
Beispiel #6
0
    def start_main(self):
        self.unbind("<Return>")
        self.lift()
        self.focus_force()
        #self.menubar.entryconfig("File", state="normal")
        #self.menubar.entryconfig("Window", state="normal")
        self.menubar_init()
        self.main_frame = tk.Frame(self, width=20, height=30)
        self.main_frame.pack()
        #Key bindings
        self.bind_all('<Control-n>', self.new_data_event)
        self.bind_all('<Alt-n>', self.new_var_event)
        self.bind_all('<Alt-p>', self.new_template_event)
        self.bind_all('<Control-g>', self.global_vars_event)
        self.bind_all('<Alt-g>', self.bmad_com_event)
        self.bind_all('<Control-d>', self.view_data_event)
        self.bind_all('<Control-e>', self.view_ele_event)
        self.bind_all('<Control-l>', self.view_lattice_event)
        self.bind_all('<Control-t>', self.plot_template_event)
        self.bind_all('<Control-r>', self.plot_region_event)
        self.bind_all('<Alt-v>', self.view_vars_event)
        self.bind_all('<Alt-q>', self.reinit_event)
        self.bind_all('<Control-b>', self.beam_init_event)
        # Clear out python lat_calc_done
        self.pipe.cmd_in('python lat_calc_done')

        # Call
        tk.Label(self.main_frame, text="Call command file:").grid(row=0,
                                                                  column=0)
        self.call_file = tk_tao_parameter(
            str_to_tao_param("call_file;FILE;T;"), self.main_frame, self.pipe)
        self.call_file.tk_wid.grid(row=0, column=1, sticky='EW')
        tk.Button(self.main_frame, text="Run",
                  command=self.tao_call).grid(row=0, column=2, sticky='EW')
        # Arguments
        tk.Label(self.main_frame, text="Arguments:").grid(row=1, column=0)
        self.cf_args = tk_tao_parameter(str_to_tao_param("cf_args;STR;T;"),
                                        self.main_frame, self.pipe)
        self.cf_args.tk_wid.configure(width=30)
        self.cf_args.tk_wid.bind("<Return>", self.tao_call)
        self.cf_args.tk_wid.grid(row=1, column=1, columnspan=2, sticky='EW')

        # Optimization
        tk.Label(self.main_frame, text="Optimization:").grid(row=2, column=0)
        tk.Button(self.main_frame, text="Setup").grid(row=2,
                                                      column=1,
                                                      sticky='EW')
        tk.Button(self.main_frame, text="Run").grid(row=2,
                                                    column=2,
                                                    sticky='EW')

        # Debug
        tk.Button(self.main_frame, text="Debug",
                  command=self.debug_cmd).grid(row=3,
                                               column=0,
                                               columnspan=3,
                                               sticky='EW')

        # Command line
        self.cmd_frame = tk.Frame(self)
        self.cmd_frame.pack(side="bottom", fill='both', expand=1)
        self.history = []  #holds the history
        self.history.append([])  #Tao and shell history
        self.history_pos = 0  #Used for scrolling in history on command line
        self.history.append([])  #Call history
        tk.Button(self.cmd_frame,
                  text="View History...",
                  command=self.view_history_cmd).grid(row=0,
                                                      column=1,
                                                      sticky='EW')
        tk.Button(self.cmd_frame,
                  text="Show/Hide Console",
                  command=self.sh_console).grid(row=0, column=0, sticky='EW')
        self.console = tao_console(self.cmd_frame, self, self.pipe)
        self.cmd_frame.columnconfigure(0, weight=1)
        self.cmd_frame.columnconfigure(1, weight=1)
        self.console.grid(row=1, column=0, columnspan=2, sticky='NSEW')
        self.cmd_frame.rowconfigure(1, weight=1)
        self.console_packed = True
Beispiel #7
0
    def tao_load(self, init_frame):
        '''
        Handles the startup of tao, including parsing gui.init and commandline
        arguments.
        '''
        def toggle_init(*args):
            '''
            Enables/disables the init file box if noinit is selected
            '''
            ix_noinit = tk_list.index('noinit')
            ix_init_file = tk_list.index('init_file')
            if tk_list[ix_noinit].tk_var.get():
                tk_list[ix_init_file].tk_wid.configure(state='disabled')
            else:
                tk_list[ix_init_file].tk_wid.configure(state='normal')

        # End: def toggle_init

        def swap_box(event=None):
            if interface_to_tao.get() == "pexpect":
                ctype_label.grid_forget()
                tao_lib.tk_wid.grid_forget()
                pexp_label.grid(row=k + 1, sticky="E")
                tao_exe.tk_wid.grid(row=k + 1, column=1, sticky="W")
            elif interface_to_tao.get() == "ctypes":
                pexp_label.grid_forget()
                tao_exe.tk_wid.grid_forget()
                ctype_label.grid(row=k + 1, sticky="E")
                tao_lib.tk_wid.grid(row=k + 1, column=1, sticky="W")

        # End: def swap_box

        def param_load(event=None):
            # set the font
            try:
                new_size = int(font_var.get())
                new_font = font.nametofont("TkDefaultFont")
                new_font.configure(size=new_size)
                self.option_add("*Font", new_font)
                self.font_size = new_size
            except:
                self.font_size = None
            # set self.lw
            self.lw = lw_var.get()
            self.plot_mode = plot_mode.get()
            # With noinit, make sure lattice file is chosen
            ix_noinit = tk_list.index('noinit')
            ix_lat_file = tk_list.index('lattice_file')
            if tk_list[ix_noinit].tk_var.get(
            ) and tk_list[ix_lat_file].tk_var.get() in ["", "Browse..."]:
                messagebox.showwarning(
                    "Warning",
                    "A lattice file is required when starting Tao without an init file."
                )
                return
            init_args = ""
            for tk_param in tk_list:
                if tk_param.param.type in ['STR', 'ENUM']:
                    tk_param.param.value = tk_param.tk_var.get()
                    if tk_param.param.value != "":
                        init_args = (init_args + "-" + tk_param.param.name +
                                     " " + tk_param.param.value + " ")
                    elif tk_param.param.name in self.old_init_args:
                        init_args += '--' + tk_param.param.name + ' '
                elif tk_param.param.type == 'FILE':
                    tk_param.param.value = tk_param.tk_var.get()
                    if tk_param.param.value == "Browse...":
                        tk_param.param.value = ""
                    if tk_param.param.value != "":
                        init_args = (init_args + "-" + tk_param.param.name +
                                     " " + tk_param.param.value + " ")
                    elif tk_param.param.name in self.old_init_args:
                        init_args += '--' + tk_param.param.name + ' '
                elif tk_param.param.type == 'LOGIC':
                    tk_param.param.value = tk_param.tk_var.get()
                    if tk_param.param.value:
                        init_args = init_args + "-" + tk_param.param.name + " "
                    elif tk_param.param.name in self.old_init_args:
                        init_args += '--' + tk_param.param.name + ' '
            #
            if plot_mode.get() != "pgplot/plplot":
                init_args = init_args + "-noplot -external_plotting"
            # Run Tao, clear the init_frame, and draw the main frame
            if interface_to_tao.get() == "pexpect":
                mode = "pexpect"
                if tao_exe.tk_var.get() == "Browse...":
                    tao_exe.tk_var.set("")
                self.pipe = tao_interface(mode, init_args,
                                          tao_exe.tk_var.get())
            elif interface_to_tao.get() == "ctypes":
                mode = "ctypes"
                if tao_lib.tk_var.get() == "Browse...":
                    tao_lib.tk_var.set("")
                #Ctypes needs a more sophisticated reinit using reinit tao
                #Check if Tao is open
                if 'pipe' in self.__dict__ and self.pipe.mode == 'ctypes':
                    self.pipe.cmd_in('reinit tao ' + init_args)
                else:
                    self.pipe = tao_interface(mode,
                                              init_args,
                                              so_lib=tao_lib.tk_var.get())
            self.old_init_args = init_args

            init_frame.destroy()
            self.start_main()
            # Clear the plotting lists
            self.placed = tao_plot_dict(self.plot_mode, self.pipe)
            if plot_mode.get() == "matplotlib":
                # place the lattice layout in layout by default
                self.placed.place_template('lat_layout', 'layout')
            self.default_plots()

        # End: def param_load

        def update_font(event=None):
            try:
                new_size = int(font_var.get())
                new_font = font.nametofont("TkDefaultFont")
                new_font.configure(size=new_size)
                self.option_add("*Font", new_font)
            except:
                pass
            return 'break'  # Do not load into Tao yet

        # End of local defs
        #-----------------------

        tk_list = []  #Items: tk_tao_parameter() (see tao_widget.py)
        init_frame.grid_columnconfigure(0, weight=1, pad=10)
        init_frame.grid_columnconfigure(1, weight=1)
        warning_messages = []
        gui_init_file = None

        # Parse command line arguments
        clargs = {}  # keys: command line switches, values: switch value
        looking_for = 'switch'
        for i in range(len(sys.argv)):
            if looking_for == 'switch':
                arg = sys.argv[i]
                if arg[0] == '-':  # -switch
                    arg = arg[1:]

                    normal = True
                    if arg[0] == '-':  # "--switch" negates the effect of "-switch"
                        normal = False
                        arg = arg[1:]

                    # Determine if arg is a valid switch name
                    matches = [
                    ]  # list of startup params that arg might refer to
                    # Special handling for gui_init
                    if arg == 'gui_init':
                        gui_init_file = ""
                        looking_for = 'file'
                        continue
                    # Generic case
                    for param in tao_startup_param_dict.keys():
                        if param.find(arg) == 0:
                            matches.append(param)
                    if len(matches) == 1:  #exactly one match -> good switch
                        arg = matches[0]
                        if (tao_startup_param_dict[matches[0]].type
                                == 'FILE') & (i != len(sys.argv) - 1):
                            clargs[arg] = ""  #add arg to clargs
                            if normal:
                                looking_for = 'file'  # file switches need files
                        elif tao_startup_param_dict[
                                matches[0]].type == 'LOGIC':
                            if normal:
                                clargs[arg] = "T"  #add arg to clargs
                            else:
                                clargs[arg] = "F"  #add arg to clargs
            elif looking_for == 'file':
                arg_file = sys.argv[i]
                if arg_file.find('-') == 0:  #not a file
                    if arg == 'gui_init':
                        pass
                    else:
                        # Remove previous argument from list
                        clargs.pop(arg)
                else:
                    if arg == 'gui_init':
                        gui_init_file = arg_file
                    else:
                        clargs[arg] = arg_file
                looking_for = 'switch'

        #Look for and read gui.init
        #each line should have the form
        #parameter:value
        #E.g. init_file:tao.init
        #E.g. rf_on:T
        if gui_init_file == None:
            # Try to use gui.init if init file not specified
            gui_init_file = os.path.expanduser('gui.init')
        else:
            gui_init_file = os.path.expanduser(gui_init_file)
            gui_init_file = os.path.expandvars(gui_init_file)

        try:
            init_file = open(gui_init_file)
            init_list = init_file.read()
            init_list = init_list.splitlines()
            init_file.close()
        except:
            init_list = []

        for key, value in clargs.items():  # add clargs to init_list
            init_list.append(key + ':' + value)

        init_dict = {}
        for entry0 in init_list:
            entry = entry0.strip()
            entry = entry.split('#', 1)[0]  # Remove comment
            if entry == '': continue
            #Check for proper formatting and not a comment
            if entry.find(':') != -1:
                name = entry[:entry.find(':')]
                name = name.strip()
                value = entry[entry.find(':') + 1:]
                value = value.strip()
            else:
                messagebox.showwarning('Error!',
                                       'Bad line in gui.init file:\n' + entry0)
                continue

            c1 = (name in ["tao_executable", "tao_shared_library"])
            try:
                c2 = (tao_startup_param_dict[name].type == 'FILE')
            except KeyError:
                c2 = False
            if c1 | c2:
                #Check that a good filename has been given
                try:
                    filename = value
                    #Expand environment variables and ~
                    filename = os.path.expanduser(filename)
                    filename = os.path.expandvars(filename)
                    f = open(filename)
                    f.close()
                    init_dict[name] = filename
                except FileNotFoundError:
                    #Don't put bad files in init_dict
                    #messagebox.showwarning(name, "File not found: " + filename)
                    warning_messages.append([name, filename])
            else:
                init_dict[name] = value

        k = 0  #row number counter
        for param, tao_param in tao_startup_param_dict.items():
            if param == 'noplot':
                continue  # The setting of noplot affects the "Plot Mode"
            tk_list.append(tk_tao_parameter(tao_param, init_frame))
            #Possibly set value from init file
            if tk_list[k].param.name in init_dict:
                if tk_list[k].param.type == 'FILE':
                    tk_list[k].tk_var.set(init_dict[tk_list[k].param.name])
                elif tk_list[k].param.type == 'LOGIC':
                    state = (init_dict[tk_list[k].param.name] == 'T') | (
                        init_dict[tk_list[k].param.name] == 'True')
                    tk_list[k].tk_var.set(state)

            if param == 'noinit':  #gets a special label
                tk.Label(init_frame,
                         text="Don't use an init file (noinit)").grid(
                             row=k, sticky="E")
                tk_list[k].tk_var.trace('w', toggle_init)
            else:
                tk.Label(init_frame, text=param).grid(row=k, sticky="E")

            tk_list[k].tk_wid.grid(row=k, column=1, sticky="W")
            k = k + 1

        # Add separator
        tk.ttk.Separator(init_frame, orient="horizontal").grid(row=k,
                                                               columnspan=2,
                                                               sticky='ew')
        k = k + 1

        # Choosing whether to use pexpect or ctypes must be handled separately
        tk.Label(init_frame, text="Interface to Tao:").grid(row=k, sticky="E")

        interface_to_tao = tk.StringVar()
        interface_to_tao.set("ctypes")
        if "interface_to_tao" in init_dict:
            if init_dict["interface_to_tao"] in ["pexpect", "ctypes"]:
                interface_to_tao.set(init_dict["interface_to_tao"])
        tk.OptionMenu(init_frame,
                      interface_to_tao,
                      "pexpect",
                      "ctypes",
                      command=swap_box).grid(row=k, column=1, sticky="W")
        pexp_label = tk.Label(init_frame, text="Tao Executable")
        ctype_label = tk.Label(init_frame, text="Tao Shared Library")
        tao_exe = tk_tao_parameter(str_to_tao_param("tao_executable;FILE;T;"),
                                   init_frame)
        if "tao_executable" in init_dict:
            tao_exe.tk_var.set(init_dict["tao_executable"])
        elif 'ACC_LOCAL_ROOT' in os.environ.keys():
            tao_exe.tk_var.set(os.environ['ACC_LOCAL_ROOT'] +
                               '/production/bin/tao')
        elif 'ACC_EXE' in os.environ.keys():
            tao_exe.tk_var.set(os.environ['ACC_EXE'] + '/tao')
        tao_lib = tk_tao_parameter(
            str_to_tao_param("tao_shared_library;FILE;T;"), init_frame)
        if "tao_shared_library" in init_dict:
            tao_lib.tk_var.set(init_dict["tao_shared_library"])
        elif 'ACC_LOCAL_ROOT' in os.environ.keys() and \
                               os.path.isfile(os.environ['ACC_LOCAL_ROOT']+'/production/lib/libtao.so'):
            tao_lib.tk_var.set(os.environ['ACC_LOCAL_ROOT'] +
                               '/production/lib/libtao.so')
        elif 'ACC_ROOT_DIR' in os.environ.keys() and \
                                  os.path.isfile(os.environ['ACC_ROOT_DIR']+'/production/lib/libtao.so'):
            tao_lib.tk_var.set(os.environ['ACC_ROOT_DIR'] +
                               '/production/lib/libtao.so')
        swap_box()

        #Choosing plot mode must also be handled separately
        tk.Label(init_frame, text="Plot Mode").grid(row=k + 2, sticky='E')
        plot_mode = tk.StringVar()
        plot_mode.set("matplotlib")
        plot_options = ["matplotlib", "pgplot/plplot", "none"]
        plot_chooser = tk.OptionMenu(init_frame, plot_mode, *plot_options)
        plot_chooser.grid(row=k + 2, column=1, sticky='W')
        # Set plot_mode from init_dict if specified
        if "plot_mode" in init_dict:
            if init_dict["plot_mode"] == "pgplot":
                plot_mode.set("pgplot/plplot")
            elif init_dict["plot_mode"] in plot_options:
                plot_mode.set(init_dict["plot_mode"])
            else:
                messagebox.showwarning(
                    'Error', 'Bad setting of "plot_mode" in gui.init: ' +
                    init_dict["plot_mode"])

        if 'noplot' in init_dict and init_dict['noplot'] == 'T':
            plot_mode.set('none')

        # Font size
        tk.Label(init_frame, text="Font size").grid(row=k + 3, sticky='E')
        font_var = tk.StringVar()
        if 'font_size' in init_dict.keys():
            font_var.set(str(init_dict['font_size']))
        else:
            font_var.set('14')
        font_box = tk.Entry(init_frame, textvariable=font_var)

        update_font()  # Set the font for the first time
        font_box.bind('<Return>', update_font)
        font_box.grid(row=k + 3, column=1, sticky='W')

        # Light-weight switch
        lw_var = tk.BooleanVar()
        if 'lw' in init_dict:
            lw_var.set((init_dict['lw'] == 'T') | (init_dict['lw'] == 'True'))
        else:
            lw_var.set(True)
        # Start button
        load_b = tk.Button(init_frame, text="Start Tao", command=param_load)
        load_b.grid(row=k + 5, columnspan=2)
        self.bind("<Return>", param_load)

        # Show warning messages about bad filenames from startup
        for warning in warning_messages:
            messagebox.showwarning(warning[0], "File not found: " + warning[1])

        #Start Tao immediately if start_tao is set true
        c1 = "start_tao" in init_dict
        c2 = len(warning_messages) == 0
        c3 = 'pipe' not in self.__dict__
        c4 = ('start_tao' in init_dict.keys()) and (init_dict["start_tao"]
                                                    in ['T', 'True'])
        if c1 & c2 & c3 & c4: param_load()

        if ('do_mainloop' in init_dict.keys()) and (init_dict["do_mainloop"]
                                                    in ['F', 'False']):
            self.do_mainloop = False
        else:
            self.do_mainloop = True
Beispiel #8
0
 def v1_ttp(x):
     ''' Shortcut for commonly used construct '''
     return tk_tao_parameter(str_to_tao_param(x), self, self.pipe)
Beispiel #9
0
    def __init__(self, tao_parameter, frame, pipe=0, data_source='', plot='', struct_name=''):
        self.param = tao_parameter
        self.pipe = pipe
        self.sub_wid = None # to be set externally, e.g. by tk_tao_linker
        if struct_name != '':
            struct_name = struct_name + '.'

        if self.param.type == 'DAT_TYPE_Z':
            # Check if operating as ENUM or as DAT_TYPE
            if plot == '': # should never occur
                self.param.type = 'STR' # most fail safe option
            else:
                plot_info = self.pipe.cmd_in('python plot1 ' + plot)
                plot_info = plot_info.splitlines()
                for item in plot_info:
                    if item.find('x_axis_type;') == 0:
                        x_axis_type = item.split(';')[3]
                        break
                    else:
                        x_axis_type = None
                if x_axis_type == 'data':
                    self.param.type = 'DAT_TYPE'
                else:
                    self.param.type = 'ENUM_Z'

        if self.param.is_ignored:
            self.tk_var = tk.StringVar()
            self.tk_var.set(str(self.param.value))
            self.tk_wid = tk.Label(frame, textvariable=self.tk_var)
        elif self.param.type in ['STR', 'INT', 'REAL', 'SPECIES']:
            self.tk_var = tk.StringVar()
            if self.param.value == None:
                self.tk_var.set("")
            else:
                self.tk_var.set(str(self.param.value))
            self.tk_wid = tk.Entry(frame, textvariable=self.tk_var)
        elif self.param.type in ['ENUM', 'ENUM_Z']:
            self.tk_var = tk.StringVar()
            self.tk_var.set(self.param.value)
            if self.param.type == 'ENUM':
                if self.param.prefix == None:
                    options = enum_fetch(self.param.name,pipe)
                else:
                    options = enum_fetch(self.param.prefix + '^' + self.param.name,pipe)
            elif self.param.type == 'ENUM_Z': #added to handle DAT_TYPE_Z
                options = enum_fetch('data_type_z', pipe)
                self.param.type = 'ENUM'
            if options == [""]:
                options = [self.param.value]
            if options[0].find('[FATAL') == 0:
                options = ['[ERROR]']
            if self.param.value == "":
                self.tk_var.set(options[0])
            if self.param.can_vary:
                self.tk_wid = tk.OptionMenu(frame, self.tk_var, *options)
            else:
                self.tk_wid = tk.Label(frame, text=self.param.value)
            # Check for and remove num^ from self.param.name
            self.param.name = self.param.name.split('^')[-1]
        elif self.param.type == 'INUM':
            self.tk_var = tk.StringVar()
            self.tk_var.set(self.param.value)
            if self.param.prefix == None:
                options = inum_fetch(self.param.name,pipe)
            else:
                options = inum_fetch(self.param.prefix + '^' + self.param.name,pipe)
            if options == [""]:
                options = [self.param.value]
            if self.param.value == None:
                self.tk_var.set(options[0])
            self.tk_wid = tk.OptionMenu(frame, self.tk_var, *options)
            # Check for and remove num^ from self.param.name
            self.param.name = self.param.name.split('^')[-1]
        elif self.param.type == 'FILE':
            self.tk_var = tk.StringVar()
            self.tk_var.set(self.param.value)
            if self.tk_var.get() == "":
                self.tk_var.set("Browse...")
            self.tk_wid = tk.Button(
                    frame, textvariable=self.tk_var, command=self.open_file)
        elif self.param.type == 'LOGIC':
            self.tk_var = tk.BooleanVar()
            self.tk_var.set(self.param.value)
            if self.param.can_vary:
                self.tk_wid = tk.Checkbutton(frame, variable=self.tk_var)
            else:
                self.tk_wid = tk.Label(frame, text=str(self.tk_var.get()))
        elif self.param.type == 'REAL_ARR':
            self.tk_var = tk.StringVar()
            val = ""
            for i in range(len(self.param.value)):
                val = val+str(self.param.value[i])
                val = val+';'
            self.tk_var.set(val) #; delimited list of values
            self.tk_wid = tk.Frame(frame) #holds the entries
            self._svar = [] #slave variables
            self._s = [] #slave widgets
            for i in range(len(self.param.value)):
                self._svar.append(tk.StringVar())
                self._svar[i].set(str(self.param.value[i]))
                self._s.append(tk.Entry(self.tk_wid, textvariable=self._svar[i]))
                self._s[i].pack(side="left", expand=1)
                self._svar[i].trace("w", self._update_real_arr)
        elif self.param.type == 'DAT_TYPE':
            self._no_s_refresh = False
            self.tk_var = tk.StringVar() #This is for the entire value
            self.tk_var.set(self.param.value)
            self.tk_wid = tk.Frame(frame) #The "widget" that should be placed by the gui
            self._data_source = data_source
            self._mvar = tk.StringVar() # The master variable
            self._mvar.set((self.tk_var.get()).split('.')[0])
            self._mvar_old = self._mvar.get() # Tracks changes inn self._mvar
            self._m = ttk.Combobox(self.tk_wid, textvariable=self._mvar,
                    values = self._get_dat_types(True), state="readonly")
            self._m.bind("<<ComboboxSelected>>", self._s_refresh)
            self._m.pack(side='left', fill='both', expand=1)
            self._svar = [] #list of slave variables
            self._stype = [] #types of slave widgets (needed for input validation)
            self._s = [] # list of slave widgets
            self._traced = False # tracks whether self._trace_cb exists
            self._s_refresh()
            self._trace_cb = self.tk_var.trace('w', self._fill_widgets)
            self._traced = True
        elif self.param.type == 'DAT_TYPE_E':
            self.tk_var = tk.StringVar()
            self.tk_var.set(self.param.value)
            self.tk_wid = tk.Frame(frame)
            # Sub-widget for the DAT_TYPE portion
            # Parse out the extra info around the DAT_TYPE
            # dat_type_str == part of self.param.value relevant to the dat_type
            dat_type_str = self.param.value
            if self.param.value.find('[') == 0:
                if self.param.value.find('@') != -1:
                    dat_type_str = self.param.value[self.param.value.find('@')+1:]
            if dat_type_str.find('[') != -1:
                dat_type_str = dat_type_str[:dat_type_str.find('[')]
            dat_type_str = self.param.name + ';DAT_TYPE;' + ('T;' if self.param.can_vary else 'F;') + dat_type_str
            self._dat_type = tk_tao_parameter(
                    str_to_tao_param(dat_type_str),
                    self.tk_wid, self.pipe, data_source=data_source)
            # DAT_TYPE_E gets a few extra input fields
            self._uvar = tk.StringVar() # Universe range
            self._u = tk.Entry(self.tk_wid, textvariable=self._uvar)
            self._u.configure(width=10)
            self._evar = tk.StringVar() # Element index
            self._e = tk.Entry(self.tk_wid, textvariable=self._evar)
            self._e.configure(width=10)
            self._cvar = tk.StringVar() # Component
            self._c = tk.Entry(self.tk_wid, textvariable=self._cvar)
            self._c.configure(width=10)
            # Extra labels to put around uni, ele, component
            self._labels = [ tk.Label(self.tk_wid, text='['),
                    tk.Label(self.tk_wid, text=']@'),
                    tk.Label(self.tk_wid, text='['),
                    tk.Label(self.tk_wid, text=']|')]
            # Pack everything
            self._labels[0].pack(side='left')
            self._u.pack(side='left')
            self._labels[1].pack(side='left')
            self._dat_type.tk_wid.pack(side='left', fill='both', expand=1)
            self._labels[2].pack(side='left')
            self._e.pack(side='left')
            self._labels[3].pack(side='left')
            self._c.pack(side='left')
        elif self.param.type == 'STRUCT':
            self.tk_var = tk.StringVar()
            self.tk_var.set('STRUCT')
            self.tk_wid = tk.Frame(frame)
            self.tk_wid.grid_columnconfigure(1, weight=1)
            self._shown = False
            self._m_label = tk.StringVar()
            self._m_label.set("Configure..." if self.param.can_vary else "View...")
            self._m = tk.Button(self.tk_wid, textvariable=self._m_label, command=self._show_hide_struct)
            self._m.grid(row=0, column=0, columnspan=2, sticky='EW')
            self._s = [] # list of tk_tao_parameters
            for component in self.param.value:
                # SPECIAL CASE: x, x2, y, y2 structs
                # do not transfer their name as the prefix
                if self.param.name not in ['x', 'x2', 'y', 'y2']:
                    self._s.append(tk_tao_parameter(component, self.tk_wid, pipe, struct_name=self.param.name))
                else:
                    self._s.append(tk_tao_parameter(component, self.tk_wid, pipe))
        elif self.param.type == 'COMPONENT':
            self.tk_var = tk.StringVar()
            self.tk_var.set(self.param.value)
            if not self.param.can_vary:
                self.tk_wid = tk.Entry(frame, textvariable=self.tk_var)
            else:
                self.tk_wid = tk.Frame(frame)
                self._copts = ['model', 'base', 'design', 'meas', 'ref']
                self._aopts = ['', '+', '-']
                self._handle_block = False
                self.tk_var.trace('w', self._write_comps)
                self._c_refresh()

        if self.param.type not in ['DAT_TYPE', 'DAT_TYPE_E', 'REAL_ARR', 'STRUCT', 'COMPONENT']:
            if (self.param.type != 'FILE') and (not self.param.is_ignored):
                self.tk_wid.config(disabledforeground="black")
        elif self.param.type not in ['DAT_TYPE_E', 'STRUCT']:
            for widget in self._s:
                widget.config(disabledforeground="black")
        elif self.param.type == 'DAT_TYPE_E':
            self._u.config(disabledforeground="black")
            self._e.config(disabledforeground="black")
            self._c.config(disabledforeground="black")
        self.tk_label = tk.Label(frame, text=self.param.name)
        if not self.param.can_vary and not self.param.is_ignored:
            if self.param.type not in ['DAT_TYPE', 'DAT_TYPE_E', 'REAL_ARR', 'STRUCT']:
                self.tk_wid.config(state="disabled")
            elif self.param.type not in ['STRUCT', 'DAT_TYPE_E']:
                for widget in self._s:
                    widget.config(state="disabled")
            elif self.param.type == 'DAT_TYPE_E':
                self._u.config(state='disabled')
                self._e.config(state='disabled')
                self._c.config(state='disabled')
        #Bind info printing
        if pipe != 0:
            if pipe.debug == True:
                self.tk_wid.bind("<Button-3>", self.print_info)