Skip to content
Snippets Groups Projects
Commit 711b29a3 authored by Alexandros Asonitis's avatar Alexandros Asonitis
Browse files

TLM-CTLM programming part 3 (Programm flow and More UI)

parent 0c5c0460
Branches
No related tags found
No related merge requests found
......@@ -221,4 +221,27 @@ def measure_TLM(device):
I = device.return_values("I")
return V,I
#ask to exit the measurement
def ask_to_exit():
root = tk.Tk()
root.withdraw()
root.lift() #show window above all other applications
root.attributes("-topmost", True)#window stays above all other applications
answer = tk.messagebox.askokcancel(message="Do you want to exit/abort the measurement? Please note that any unsaved measuerement results will be deleted!")
root.destroy()
return answer
#this function displays an information box!
def information_box(information):
#open dialog and hide the main window
root = tk.Tk()
root.withdraw()
root.lift() #show window above all other applications
root.attributes("-topmost", True)#window stays above all other applications
#display meaagebox
tkinter.messagebox.showinfo(message=information)
root.destroy()
\ No newline at end of file
......@@ -74,21 +74,28 @@ smu4.update(CONS=const_parameters)
def on_start_button_clicked(b):
with output:
global V,I,curve
global V,I,curve,distances,counter
clear_output(wait = True)
#disable all widgets
disable_widgets(input_fields)
disable_widgets(all_buttons)
#clear the figure
ax.cla()
#check if values are correct
valid = check_values(start=parameters['start'],stop=parameters['stop'],step=parameters['step'])
if valid == True:
#load parameters,exexute measurement and plot results
#first increase counter
#first reset counter
counter= 0
#retrive distances
distances = [sample[f"d{i}"].value for i in range(1,6)]
#load parameters
#update the dictionary var1
var1.update(
......@@ -109,39 +116,80 @@ def on_start_button_clicked(b):
#plot results
fig.suptitle(sample["type"].value)
ax.set_xlabel("V(V)")
ax.set_ylabel("I(A)")
curve=ax.plot(V,I)
ax.set_xlabel("V/V")
ax.set_ylabel("I/A")
curve=ax.plot(V,I,label =f"distance (um):{distances[counter]}")
ax.legend()
fig.show()
change_state(first_time_buttons)
else:
change_state(input_fields)
change_state(all_buttons)
else:#enable the widgets again
enable_widgets(input_fields)
enable_widgets(all_buttons)
def on_repeat_button_clicked(b):
with output:
global V,I,curve
global V,I,curve,counter
change_state(first_time_buttons)
clear_output(wait = True)
#remove last measurement
line = curve.pop(0)
line.remove()
#measure again
V,I=measure_TLM(device)
curve=ax.plot(V,I)
#update results
curve=ax.plot(V,I,label =f"distance (um):{distances[counter]}")
ax.legend()
fig.show()
if counter==4:
information_box('You have completed the 5th Measurement. Press save+continue to save results')
change_state(first_time_buttons)
def on_continue_button_clicked(b):
with output:
global V,I,curve
global V,I,curve,counter
change_state(first_time_buttons)
clear_output(wait = True)
#save results(counter = 0,1,2,3,4)
#increase counter
counter = counter +1 # this is the value before the next measurement starts
if counter <= 4 : #measure the next structure
V,I=measure_TLM(device)
curve=ax.plot(V,I)
curve=ax.plot(V,I,label =f"distance (um):{distances[counter]}")
ax.legend()
fig.show()
if counter==4:
information_box('You have completed for the first time the 5th Measurement. Press save+continue to save results')
change_state(first_time_buttons)
else: #measurement finished
enable_widgets(all_buttons) # all buttons active
enable_widgets(input_fields)
disable_widgets(first_time_buttons) #only start new active
def on_exit_button_clicked(b):
with output:
change_state(first_time_buttons)
#ask first
exit = ask_to_exit()
if exit == True:
enable_widgets(all_buttons)
enable_widgets(input_fields)
disable_widgets(first_time_buttons)
else:
change_state(first_time_buttons)
start_button.on_click(on_start_button_clicked)
continue_button.on_click(on_continue_button_clicked)
repeat_button.on_click(on_repeat_button_clicked)
exit_button.on_click(on_exit_button_clicked)
\ No newline at end of file
%% Cell type:code id:1850827a-0811-4a03-9ea4-68a99e240de4 tags:
``` python
%matplotlib widget
%run tlm-ctlm.py
```
%% Output
Controls
Save Parameters in .ini file
%% Cell type:code id:fca4fd49-7bb0-4f5f-a446-d6cf14574e19 tags:
%% Cell type:code id:bea7cae7-2f79-4bcf-88f9-d9b50f7881ad tags:
``` python
```
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment