def init(self, amp_frame, cv_frame): """ make all the widget elements in this method :return: """ graph_props = graph_properties.GraphProps() update_param_dict() bottom_frame = self.make_bottom_frames() self.make_connect_button(bottom_frame[1]) """ Add the cyclic voltammetry graph, first decide how to make the graph and then display it NOTE: THE canvas_graph_embed DOES NOT WORK RIGHT NOW""" if self.display_type == 'matplotlib': amp_graph = tkinter_pyplot.PyplotEmbed(self, bottom_frame[0], graph_props.amp_plot, amp_frame, operation_params) cv_graph = tkinter_pyplot.PyplotEmbed(self, bottom_frame[0], graph_props.cv_plot, cv_frame, operation_params) else: amp_graph = tkinter_canvas_graph.canvas_graph_embed( master=amp_frame, properties=graph_props.amp_canvas) cv_graph = tkinter_canvas_graph.canvas_graph_embed( master=cv_frame, properties=graph_props.cv_canvas) cv_graph.pack(side='left', expand=True, fill=tk.BOTH) self.graph = cv_graph """ call a routine to make all the components to put in the notebook for cyclic voltammetry """ self.build_cv_notebook(cv_graph, cv_frame) amp_graph.pack(expand=True, fill=tk.BOTH) """ make a button to display connection settings and allow user to try to reconnect """ self.notebook.pack(side='top', expand=True, fill=tk.BOTH) """make the option menu""" # self.build_option_menu() option_menu.OptionMenu(self)
def make_graph_area(self, master, graph_props): """ Make the graph area to display the cyclic voltammetry data. Use matplotlib if it is available or else plot in a tk Canvas TODO: add canvas option :param master: tk.Tk overall master of the program :param graph_props: dictionary fo properties on how the graph looks :return: the graph object, currently a PyplotEmbed class from tkinter_pyplot """ if check_display_type() == 'matplotlib': # current_lim = 1.2 * 1000. / master.device_params.adc_tia.tia_resistor current_lim = master.device_params.adc_tia.current_lims low_voltage = self.settings.low_voltage high_voltage = self.settings.high_voltage graph = tkinter_pyplot.PyplotEmbed( master.frames[0], # frame to put the toolbar in NOTE: hack, fix this graph_props.cv_plot, self, current_lim, low_voltage, high_voltage) else: graph = None # TODO: implement for canvas raise NotImplementedError return graph
def make_graph(self, sweep_type, start_volt_type): """ Make a graph of what the voltage versus time protocol looks like :param sweep_type: str - 'LS' or 'CV' for a linear sweep or cyclic voltammetry :param start_volt_type: str - 'Zero' or 'Start' for starting the protocol at zero volts or the starting voltage """ self.geometry("700x300") blank_frame = tk.Frame() # holder for toolbar that is not needed try: start_volt = int(float(self.start_volt.get())) end_volt = int(float(self.end_volt.get())) rate = float(self.freq.get()) except: return -1 low_voltage = min([start_volt, end_volt]) high_volt = max([start_volt, end_volt]) voltage_step = self.master.device_params.dac.voltage_step_size ylims = [low_voltage, high_volt] # make the voltage protocol, use the functions used by the cv_frame self.data = cv_frame.make_x_line(start_volt, end_volt, voltage_step, sweep_type, start_volt_type) steps_per_second = rate * float(voltage_step) total_time = len(self.data) * steps_per_second time = [x * steps_per_second for x in range(len(self.data))] plt_props = {'xlabel': "'time (msec)'", 'ylabel': "'voltage (mV)'", 'title': "'Voltage profile'", 'subplots_adjust': "bottom=0.15, left=0.12"} self.graph = tkinter_pyplot.PyplotEmbed(blank_frame, plt_props, self, ylims, 0, total_time) self.graph.pack(side='left') self.graph.simple_update_data(time, self.data)
def __init__(self, parent=None): tk.Tk.__init__(self, parent) self.color_index = 0 self.last_dir = None self.display_type = 'decimated' self.data = pyplot_data.PyplotData_v2( ) # make a list of panda data frames # make menu bar option_menu.OptionMenu(self) # make frame to hold buttons to manipulate the data in self.top_frame = tk.Frame(self, height=35) self.top_frame.pack(side='top', fill=tk.X) self.make_buttons(self.top_frame) # make a second frame to hold button to manipulate data print('1') self.manipulation_frame = tk.Frame(self, height=35) self.manipulation_frame.pack(side='top', fill=tk.X) self.make_manipulate_buttons(self.manipulation_frame) # make graph area to plot later self.data_area = tkinter_pyplot.PyplotEmbed(self, self.data) self.data_area.pack(side='top', expand=True, fill=tk.BOTH) # make frame to show data statistics on the bottom print('2') self.bottom_frame = tk.Frame(self) self.bottom_frame.pack(side='top', fill=tk.X) self.data_info_frames = [] self.data_summary_frames = []
def make_graph_area(self, master, graph_props): if check_display_type() == 'matplotlib': current_lim = 1.2 * 1000. / master.device_params.adc_tia.tia_resistor # 1's are not needed, the properties will override this graph = tkinter_pyplot.PyplotEmbed(master, master.frames[1], graph_props.amp_plot, self, current_lim, 1, 1) else: graph = None # TODO: implement for canvas return graph
def make_graph_area(self, master, graph_props): """ Make the graph area to display the cyclic voltammetry data. Use matplotlib if it is available or else plot in a tk Canvas TODO: Merge this with CV frame so it works better :param master: tk.Tk overall master of the program :param graph_props: dictionary fo properties on how the graph looks :return: the graph object, currently a PyplotEmbed class from tkinter_pyplot """ current_lim = master.device_params.adc_tia.current_lims low_voltage = master.device_params.asv_settings.low_voltage high_voltage = master.device_params.asv_settings.high_voltage graph = tkinter_pyplot.PyplotEmbed( master.frames[0], # frame to put the toolbar in NOTE: hack, fix this graph_props.cv_plot, self, current_lim, low_voltage, high_voltage) return graph