def AfficherProtocol(Window, protocol): """ This function generates a list of steps in the protocol. It's primary use is to show in the right window the steps that are currently in the protocol Entry: Window(Frame): the parent frame protocol(list): the list of protocols """ Create_text(Window, 'Protocol:', color=Clr_txt_frames, Police=Font_frames_title, back_colour=Bkg_frm_blue, col=1, line=1) nbline = 3 for step in protocol: cmd = step[0] if cmd == 'pip': vol = step[1] sol = step[2] Create_text(Window, '', color=Clr_txt_protocol, Police=Font_command, back_colour=Bkg_txt_protocol, col=1, line=nbline, form='wens') Create_text(Window, str(nbline - 2) + ' - Pipet ' + str(vol) + 'µL in solution ' + str(sol), color=Clr_txt_protocol, Police=Font_command, back_colour=Bkg_txt_protocol, col=1, line=nbline, form='wns') elif cmd == 'dep': Create_text(Window, '', color=Clr_txt_protocol, Police=Font_command, back_colour=Bkg_txt_protocol, col=1, line=nbline, form='wens') Create_text(Window, str(nbline - 2) + ' - Leave the pipetted solution on the EWOD plate', color=Clr_txt_protocol, Police=Font_command, back_colour=Bkg_txt_protocol, col=1, line=nbline, form='wns') elif cmd == 'mov': xbeg = step[1] ybeg = step[2] xend = step[3] yend = step[4] Create_text(Window, '', color=Clr_txt_protocol, Police=Font_command, back_colour=Bkg_txt_protocol, col=1, line=nbline, form='wens') Create_text(Window, str(nbline - 2) + ' - Move the droplet from (' + str(xbeg) + ',' + str(ybeg) + ') to (' + str(xend) + ',' + str(yend) + ')', color=Clr_txt_protocol, Police=Font_command, back_colour=Bkg_txt_protocol, col=1, line=nbline, form='wns') elif cmd == 'lum': nbmes = step[1] t_inter_mes = step[2] Create_text(Window, '', color=Clr_txt_protocol, Police=Font_command, back_colour=Bkg_txt_protocol, col=1, line=nbline, form='wens') Create_text(Window, str(nbline - 2) + ' - Do ' + str(nbmes) + ' measures of luminescence, waiting ' + str(t_inter_mes) + ' ms between each', color=Clr_txt_protocol, Police=Font_command, back_colour=Bkg_txt_protocol, col=1, line=nbline, form='wns') elif cmd == 'cle': Create_text(Window, '', color=Clr_txt_protocol, Police=Font_command, back_colour=Bkg_txt_protocol, col=1, line=nbline, form='wens') Create_text(Window, str(nbline - 2) + ' - Clean the EWOD plate', color=Clr_txt_protocol, Police=Font_command, back_colour=Bkg_txt_protocol, col=1, line=nbline, form='wns') elif cmd == 'tha': Create_text(Window, '', color=Clr_txt_protocol, Police=Font_command, back_colour=Bkg_txt_protocol, col=1, line=nbline, form='wens') Create_text(Window, str(nbline - 2) + ' - Thaw the solutions', color=Clr_txt_protocol, Police=Font_command, back_colour=Bkg_txt_protocol, col=1, line=nbline, form='wns') elif cmd == 'position': Create_text(Window, '', color=Clr_txt_position, Police=Font_command, back_colour=Bkg_txt_position, col=1, line=nbline, form='wens') Create_text(Window, str(nbline - 2) + ' - ACTUAL POSITION', color=Clr_txt_position, Police=Font_command, back_colour=Bkg_txt_position, col=1, line=nbline, form='wns') else: ValueError nbline = nbline + 1 return Window
def ProtocolWindow(Window, file_proto): """ This function opens a secondary window to create or modify the measurement protocol. Entry: Window(Frame): the parent window proto(list): the list of actions Returns: protocol(list): the list of actions in the protocol """ print(file_proto) #Create the new window Window_protocol = Toplevel(Window) Window_protocol.title('Neurodrop - Protocol Window') #Create the list from the protocol file if (file_proto != None): proto = ReadProtocolFile(file_proto) else: proto = [["position"]] EcrireProtocoleFichier(proto, 'temp.txt') #Create the heading of the new window Heading = Create_Heading(Window_protocol) #Create the two main frames of the window Comands = Create_Frame(Window_protocol, border_thickness=5, style_border='groove', back_colour=Bkg_frm_blue, col=1, line=2, nblines=3, nbcolumns=3, form='wens') Protocol = Create_Frame(Window_protocol, border_thickness=5, style_border='groove', back_colour=Bkg_frm_blue, col=6, line=2, nblines=7, nbcolumns=3, form='we') Position = Create_Frame(Window_protocol, border_thickness=5, style_border='groove', back_colour=Bkg_frm_blue, col=1, line=6, nblines=3, nbcolumns=3, form='wens') #Create the command frame Create_text(Comands, 'Comands', color=Clr_txt_frames, Police=Font_frames_title, back_colour=Bkg_frm_blue, col=1, line=1, form='wens', nbcolumns=1, nblines=1) Create_button(Comands, 'Pipet a solution', partial(fb.pipet, Window_protocol, Protocol, 'temp.txt'), color='#000000', activefg=Bkg_button_active, Width=30, Height=2, Police=Font_command, col=1, line=3, form='wens', nblines=1) Create_button(Comands, 'Drop on the EWOD plate', partial(fb.dropEWOD, Window_protocol, Protocol, 'temp.txt'), color='#000000', activefg=Bkg_button_active, Width=30, Height=2, Police=Font_command, col=1, line=4, form='wens', nblines=1) Create_button(Comands, 'Move the droplet on the EWOD plate', partial(fb.move, Window_protocol, Protocol, 'temp.txt'), color='#000000', activefg=Bkg_button_active, Width=30, Height=2, Police=Font_command, col=1, line=5, form='wens', nblines=1) Create_button(Comands, 'Measure the luminescence', partial(fb.measure, Window_protocol, Protocol, 'temp.txt'), color='#000000', activefg=Bkg_button_active, Width=30, Height=2, Police=Font_command, col=1, line=6, form='wens', nblines=1) Create_button(Comands, 'Clean the EWOD plate', partial(fb.clean, Window_protocol, Protocol, 'temp.txt'), color='#000000', activefg=Bkg_button_active, Width=30, Height=2, Police=Font_command, col=1, line=7, form='wens', nblines=1) Create_button(Comands, 'Thaw the solutions', partial(fb.thaw, Window_protocol, Protocol, 'temp.txt'), color='#000000', activefg=Bkg_button_active, Width=30, Height=2, Police=Font_command, col=1, line=8, form='wens', nblines=1) #Create the position frame Create_text(Position, 'Position', color=Clr_txt_frames, Police=Font_frames_title, back_colour=Bkg_frm_blue, col=1, line=1, form='wens', nbcolumns=2, nblines=1) Create_button(Position, 'Move up', partial(fb.PosUp, Window_protocol, Protocol, 'temp.txt'), color='#000000', activefg=Bkg_button_active, Width=15, Height=2, Police=Font_command, col=1, line=3, form='wens', nblines=1) Create_button(Position, 'Move down', partial(fb.PosDown, Window_protocol, Protocol, 'temp.txt'), color='#000000', activefg=Bkg_button_active, Width=15, Height=2, Police=Font_command, col=1, line=4, form='wens', nblines=1) Create_button(Position, 'Save', partial(fb.Save, Window_protocol, Protocol, 'temp.txt'), color='#000000', activefg=Bkg_button_active, Width=15, Height=2, Police=Font_command, col=2, line=3, form='wens', nblines=1) Create_button(Position, 'Delete last line', partial(fb.Delete, Window_protocol, Protocol, 'temp.txt'), color='#000000', activefg=Bkg_button_active, Width=15, Height=2, Police=Font_command, col=2, line=4, form='wens', nblines=1) #Create the protocol frame Protocol = AfficherProtocol(Protocol, proto) #Configure the frames Auto_configure(Window_protocol, lines=[1, 5, 9], columns=[0, 4, 5, 9], min_size_row=10, min_size_col=10, weight_col=1, weight_row=1) Auto_configure(Window_protocol, lines=[2, 3, 4, 6, 7, 8], columns=[1, 2, 3], min_size_row=10, min_size_col=30, weight_col=0, weight_row=0) Auto_configure(Window_protocol, lines=[2, 3, 4, 5, 6, 7, 8], columns=[6, 7, 8], min_size_row=10, min_size_col=170, weight_col=0, weight_row=0) Auto_configure(Heading, lines=[0], columns=[0, 1, 2, 3, 4, 5, 6, 7], min_size_row=10, min_size_col=30, weight_col=1, weight_row=0) Auto_configure(Comands, lines=[0, 2, 9], columns=[0, 2], min_size_row=10, min_size_col=10, weight_col=1, weight_row=1) Auto_configure(Comands, lines=[1, 3, 4, 5, 6, 7, 8], columns=[1], min_size_row=10, min_size_col=10, weight_col=0, weight_row=0) Auto_configure(Position, lines=[0, 2, 5], columns=[0, 3], min_size_row=10, min_size_col=10, weight_col=1, weight_row=1) Auto_configure(Position, lines=[1, 3, 4], columns=[1, 2], min_size_row=10, min_size_col=10, weight_col=0, weight_row=0) Auto_configure(Protocol, lines=[0, 2], columns=[0, 2], min_size_row=10, min_size_col=10, weight_col=1, weight_row=1) Auto_configure(Protocol, lines=[], columns=[1], min_size_row=10, min_size_col=10, weight_col=0, weight_row=0) return proto
def pipet(Window, ProtoWindow, temp_file): """ This program adds the pipeting instruction. Entry: Window(Frame): the protocol window ProtoWindow(Frame): the protocol frame temp_file(string): the name of the file """ protocole = Prot.ReadProtocolFile(temp_file) pos = protocole.index(['position']) a = protocole[:pos] if a == []: a = [['pip']] else: a = a + [['pip']] b = protocole[pos:] #Create the new window Window_option = Toplevel(Window) Window_option.title('Neurodrop - Pipette calibration') #Create the heading of the new window Heading = Create_Heading(Window_option) #Create the choices of solutions and the slider for the volume Solution = Create_Frame(Window_option, border_thickness=5, style_border='groove', back_colour=sty.Bkg_frm_blue, col=1, line=2, nblines=2, nbcolumns=8, form='wens') Create_text(Solution, 'Choose the solution', color=sty.Clr_txt_frames, Police=sty.Font_frames_title, back_colour=sty.Bkg_frm_blue, col=1, line=1, form='wens', nbcolumns=4, nblines=1) var = IntVar() for i in [1, 2, 3, 4]: R = Radiobutton(Solution, text="Solution " + str(i), variable=var, value=i, bg=sty.Bkg_frm_blue) R.grid(column=i, row=3, columnspan=1, rowspan=1, sticky='we') scale = IntVar() Volume = Create_Frame(Window_option, border_thickness=5, style_border='groove', back_colour=sty.Bkg_frm_blue, col=1, line=5, nblines=2, nbcolumns=8, form='wens') Create_text(Volume, 'Choose the volume (in nL)', color=sty.Clr_txt_frames, Police=sty.Font_frames_title, back_colour=sty.Bkg_frm_blue, col=1, line=1, form='wens', nbcolumns=1, nblines=1) volscale = Scale(Volume, from_=200, to=10000, resolution=50, variable=scale, showvalue=True, label='nL', orient='horizontal', bg=sty.Bkg_frm_blue, length=30) volscale.grid(column=1, row=3, columnspan=1, rowspan=1, sticky='we') Confirm = Create_Frame(Window_option, border_thickness=5, style_border='groove', back_colour=sty.Bkg_frm_blue, col=1, line=8, nblines=1, nbcolumns=8, form='wens') Create_text(Confirm, 'Save parameters', color=sty.Clr_txt_frames, Police=sty.Font_frames_title, back_colour=sty.Bkg_frm_blue, col=1, line=1, form='wens', nbcolumns=1, nblines=1) Create_button( Confirm, 'OK', partial(get_value_2, Window_option, scale, var, a + b, ProtoWindow)).grid(column=1, row=3, columnspan=1, rowspan=1, sticky='wens') #Configure the window W = [ Window_option, Window_option, Heading, Solution, Solution, Volume, Volume, Confirm, Confirm ] Lines = [[0, 2, 3, 4, 6, 7, 8], [1, 5, 9], [0], [0, 2, 4], [1, 3], [0, 2, 4], [1, 3], [0, 2, 4], [1, 3]] Columns = [[1, 2, 3, 4, 5, 6, 7, 8], [0, 9], [0, 1, 2, 3, 4, 5, 6, 7], [0, 5], [1, 2, 3, 4], [0, 2], [1], [0, 2], [1]] WC = [0, 1, 1, 1, 0, 1, 0, 1, 0] WL = [0, 1, 0, 1, 0, 1, 0, 1, 0] for i in range(len(W)): Auto_configure(W[i], lines=Lines[i], columns=Columns[i], min_size_col=10, min_size_row=10, weight_col=WC[i], weight_row=WL[i]) return 1
def wait(Window, ProtoWindow, temp_file): """ This program adds the temperature instruction. Entry: Window(Frame): the protocol window ProtoWindow(Frame): the protocol frame temp_file(string): the name of the file """ protocole = Prot.ReadProtocolFile(temp_file) pos = protocole.index(['position']) a = protocole[:pos] if a == []: a = [['wai']] else: a = a + [['wai']] b = protocole[pos:] #Create the new window Window_option = Toplevel(Window) Window_option.title('Neurodrop - Waiting calibration') #Create the heading of the new window Heading = Create_Heading(Window_option) #Create the choices of solutions and the slider for the volume Tme = Create_Frame(Window_option, border_thickness=5, style_border='groove', back_colour=sty.Bkg_frm_blue, col=1, line=2, nblines=5, nbcolumns=8, form='wens') Create_text(Tme, 'Define the number of seconds you want to wait', color=sty.Clr_txt_frames, Police=sty.Font_frames_title, back_colour=sty.Bkg_frm_blue, col=1, line=1, form='wens', nbcolumns=1, nblines=1) tim = StringVar() Create_entry(Tme, tim, Width=30, Police='Arial 25', col=1, line=3, form='wens', nblines=1) Confirm = Create_Frame(Window_option, border_thickness=5, style_border='groove', back_colour=sty.Bkg_frm_blue, col=1, line=8, nblines=1, nbcolumns=8, form='wens') Create_text(Confirm, 'Save parameters', color=sty.Clr_txt_frames, Police=sty.Font_frames_title, back_colour=sty.Bkg_frm_blue, col=1, line=1, form='wens', nbcolumns=1, nblines=1) Create_button(Confirm, 'OK', partial(get_value_1, Window_option, tim, a + b, ProtoWindow)).grid(column=1, row=3, columnspan=1, rowspan=1, sticky='wens') #Configure the window W = [Window_option, Window_option, Heading, Tme, Tme, Confirm, Confirm] Lines = [[0, 2, 3, 4, 6, 7, 8], [1, 5, 9], [0], [0, 2, 4], [1, 3], [0, 2, 4], [1, 3]] Columns = [[1, 2, 3, 4, 5, 6, 7, 8], [0, 9], [0, 1, 2, 3, 4, 5, 6, 7], [0, 2], [1], [0, 2], [1]] WC = [0, 1, 1, 1, 0, 1, 0, 1, 0] WL = [0, 1, 0, 1, 0, 1, 0, 1, 0] for i in range(len(W)): Auto_configure(W[i], lines=Lines[i], columns=Columns[i], min_size_col=10, min_size_row=10, weight_col=WC[i], weight_row=WL[i]) return 1
def move(Window, ProtoWindow, temp_file): """ This program adds the pipeting instruction. Entry: Window(Frame): the protocol window ProtoWindow(Frame): the protocol frame temp_file(string): the name of the file """ protocole = Prot.ReadProtocolFile(temp_file) pos = protocole.index(['position']) a = protocole[:pos] if a == []: a = [['mov']] else: a = a + [['mov']] b = protocole[pos:] Prot.EcrireProtocoleFichier(a + b, 'temp.txt') #Create the new window Window_option = Toplevel(Window) Window_option.title('Neurodrop - Movement calibration') #Create the heading of the new window Heading = Create_Heading(Window_option) #Create the button matrix to choose the displacement canvas = Canvas(Window_option, width=750, height=600) scroll_y = Scrollbar(Window_option, orient="vertical", command=canvas.yview) Matrix = Create_Frame(canvas, border_thickness=0, style_border='solid', back_colour=sty.Bkg_frm_blue, col=1, line=2, nblines=6, nbcolumns=8, form='wens') fichier = open('list_pad.csv', 'r') lines = fichier.readlines() fichier.close() for i in range(len(lines)): lines[i] = lines[i].replace('\n', "") lines[i] = lines[i].split(';') #lines[i][-1]=lines[i][-1][:-1] #We get rid of the jumpline symbols lines[0][0] = lines[0][0][1:] for l in range(len(lines)): lin = l for col in range(len(lines[l])): if (lines[l][col] != '0'): Create_button(Matrix, '', partial(get_values_matrix, Window_option, l, col, temp_file, ProtoWindow), color='#000000', activefg='#318ce7', Width=2, Height=1, Police='Arial 10', col=1 + col, line=3 + l, form='wens', nblines=1, pady=0) Create_text(Matrix, 'Select the departure and the arriving pads', color=sty.Clr_txt_frames, Police=sty.Font_frames_title, back_colour=sty.Bkg_frm_blue, col=1, line=1, form='wens', nbcolumns=col + 1, nblines=1) Create_text(Matrix, 'END', color=sty.Bkg_frm_blue, Police=sty.Font_frames_title, back_colour=sty.Bkg_frm_blue, col=1, line=lin + 5, form='wens', nbcolumns=col, nblines=1) canvas.create_window(0, 0, anchor='nw', window=Matrix) canvas.update_idletasks() canvas.configure(scrollregion=canvas.bbox('all'), yscrollcommand=scroll_y.set) canvas.grid(row=2, column=1, rowspan=6, columnspan=7, sticky='wens') scroll_y.grid(row=2, column=8, rowspan=6, columnspan=1, sticky='ns') #Configure the window W = [Window_option, Window_option, Heading, Matrix, Matrix] Lines = [[0, 2, 3, 4, 5, 6, 7, 8], [1, 9], [0], [0, 2, lin + 5], [1] + [i for i in range(3, lin + 4)]] Columns = [[1, 2, 3, 4, 5, 6, 7, 8], [0, 9], [0, 1, 2, 3, 4, 5, 6, 7], [1] + [i for i in range(2, col + 2)], [0, col + 2]] WC = [0, 1, 1, 1, 0, 1, 0] WL = [0, 1, 0, 1, 0, 1, 0] for i in range(len(W)): Auto_configure(W[i], lines=Lines[i], columns=Columns[i], min_size_col=10, min_size_row=10, weight_col=WC[i], weight_row=WL[i])
def measure(Window, ProtoWindow, temp_file): """ This program adds the pipeting instruction. Entry: Window(Frame): the protocol window ProtoWindow(Frame): the protocol frame temp_file(string): the name of the file """ protocole = Prot.ReadProtocolFile(temp_file) pos = protocole.index(['position']) a = protocole[:pos] if a == []: a = [['lum']] else: a = a + [['lum']] b = protocole[pos:] #Create the new window Window_option = Toplevel(Window) Window_option.title('Neurodrop - Measurement calibration') #Create the heading of the new window Heading = Create_Heading(Window_option) #Create the choices of solutions and the slider for the volume Nb_measurements = Create_Frame(Window_option, border_thickness=5, style_border='groove', back_colour=Bkg_frm_blue, col=1, line=2, nblines=2, nbcolumns=8, form='wens') Create_text(Nb_measurements, 'Enter the number of measurements to perform', color=Clr_txt_frames, Police=Font_frames_title, back_colour=Bkg_frm_blue, col=1, line=1, form='wens', nbcolumns=3, nblines=1) nb_mes = StringVar() Create_entry(Nb_measurements, nb_mes, Width=30, Police='Arial 25', col=1, line=3, form='wens', nblines=1) Time_inter = Create_Frame(Window_option, border_thickness=5, style_border='groove', back_colour=Bkg_frm_blue, col=1, line=5, nblines=2, nbcolumns=8, form='wens') Create_text(Time_inter, 'Enter the time between each measurements (in ms)', color=Clr_txt_frames, Police=Font_frames_title, back_colour=Bkg_frm_blue, col=1, line=1, form='wens', nbcolumns=3, nblines=1) tme_mes = StringVar() Create_entry(Time_inter, tme_mes, Width=30, Police='Arial 25', col=1, line=3, form='wens', nblines=1) Confirm = Create_Frame(Window_option, border_thickness=5, style_border='groove', back_colour=Bkg_frm_blue, col=1, line=8, nblines=1, nbcolumns=8, form='wens') Create_text(Confirm, 'Save parameters', color=Clr_txt_frames, Police=Font_frames_title, back_colour=Bkg_frm_blue, col=1, line=1, form='wens', nbcolumns=1, nblines=1) Create_button( Confirm, 'OK', partial(get_value_2, Window_option, nb_mes, tme_mes, a + b, ProtoWindow)).grid(column=1, row=3, columnspan=1, rowspan=1, sticky='wens') #Configure the window W = [ Window_option, Window_option, Heading, Nb_measurements, Nb_measurements, Time_inter, Time_inter, Confirm, Confirm ] Lines = [[0, 2, 3, 4, 6, 7, 8], [1, 5, 9], [0], [0, 2, 4], [1, 3], [0, 2, 4], [1, 3], [0, 2, 4], [1, 3]] Columns = [[1, 2, 3, 4, 5, 6, 7, 8], [0, 9], [0, 1, 2, 3, 4, 5, 6, 7], [0, 4], [1, 2, 3], [0, 2], [1], [0, 2], [1]] WC = [0, 1, 1, 1, 0, 1, 0, 1, 0] WL = [0, 1, 0, 1, 0, 1, 0, 1, 0] for i in range(len(W)): Auto_configure(W[i], lines=Lines[i], columns=Columns[i], min_size_col=10, min_size_row=10, weight_col=WC[i], weight_row=WL[i]) return 1
def move(Window, ProtoWindow, temp_file): """ This program adds the pipeting instruction. Entry: Window(Frame): the protocol window ProtoWindow(Frame): the protocol frame temp_file(string): the name of the file """ protocole = Prot.ReadProtocolFile(temp_file) pos = protocole.index(['position']) a = protocole[:pos] if a == []: a = [['mov']] else: a = a + [['mov']] b = protocole[pos:] Prot.EcrireProtocoleFichier(a + b, 'temp.txt') #Create the new window Window_option = Toplevel(Window) Window_option.title('Neurodrop - Movement calibration') #Create the heading of the new window Heading = Create_Heading(Window_option) #Create the button matrix to choose the displacement Matrix = Create_Frame(Window_option, border_thickness=5, style_border='groove', back_colour=Bkg_frm_blue, col=1, line=2, nblines=7, nbcolumns=8, form='wens') Pds_per_line = [10, 10, 10, 10, 10, 10, 10, 10] Create_text(Matrix, 'Select the departure and the arriving pads', color=Clr_txt_frames, Police=Font_frames_title, back_colour=Bkg_frm_blue, col=1, line=1, form='wens', nbcolumns=max(Pds_per_line), nblines=1) for k in range(len(Pds_per_line)): for nb in range(Pds_per_line[k]): for i in range(nb): Create_button(Matrix, '', partial(get_values_matrix, Window_option, i, k, temp_file, ProtoWindow), color='#000000', activefg='#318ce7', Width=1, Height=1, Police='Arial 20', col=1 + i, line=3 + k, form='wens', nblines=1) #Configure the window W = [Window_option, Window_option, Heading, Matrix, Matrix] Lines = [[0, 2, 3, 4, 5, 6, 7, 8], [1, 9], [0], [0, 2, 4], [1, 3], [0, 2, len(Pds_per_line)], [1] + [i for i in range(3, 2 + len(Pds_per_line))]] Columns = [[1, 2, 3, 4, 5, 6, 7, 8], [0, 9], [0, 1, 2, 3, 4, 5, 6, 7], [0, 4], [1] + [i for i in range(max(Pds_per_line))], [0, max(Pds_per_line)]] WC = [0, 1, 1, 1, 0, 1, 0] WL = [0, 1, 0, 1, 0, 1, 0] for i in range(len(W)): Auto_configure(W[i], lines=Lines[i], columns=Columns[i], min_size_col=10, min_size_row=10, weight_col=WC[i], weight_row=WL[i])