117 lines
7.4 KiB
Python
117 lines
7.4 KiB
Python
# Copyright (c) 2019 Esben Rossel
|
|
# All rights reserved.
|
|
#
|
|
# Author: Esben Rossel <esbenrossel@gmail.com>
|
|
#
|
|
# Redistribution and use in source and binary forms, with or without
|
|
# modification, are permitted provided that the following conditions
|
|
# are met:
|
|
# 1. Redistributions of source code must retain the above copyright
|
|
# notice, this list of conditions and the following disclaimer.
|
|
# 2. Redistributions in binary form must reproduce the above copyright
|
|
# notice, this list of conditions and the following disclaimer in the
|
|
# documentation and/or other materials provided with the distribution.
|
|
#
|
|
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
|
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
# ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
|
|
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
# SUCH DAMAGE.
|
|
|
|
import os
|
|
import tkinter as tk
|
|
from PIL import Image,ImageTk
|
|
|
|
def center_window(size, window) :
|
|
window_width = size[0] #Fetches the width you gave as arg. Alternatively window.winfo_width can be used if width is not to be fixed by you.
|
|
window_height = size[1] #Fetches the height you gave as arg. Alternatively window.winfo_height can be used if height is not to be fixed by you.
|
|
if window==None:
|
|
window_x = 200
|
|
window_y = 200
|
|
else:
|
|
window_x = int((window.winfo_screenwidth() / 2) - (window_width / 2)) #Calculates the x for the window to be in the centre
|
|
window_y = int((window.winfo_screenheight() / 2) - (window_height / 2)) #Calculates the y for the window to be in the centre
|
|
|
|
window_geometry = str(window_width) + 'x' + str(window_height) + '+' + str(window_x) + '+' + str(window_y) #Creates a geometric string argument
|
|
window.geometry(window_geometry) #Sets the geometry accordingly.
|
|
return
|
|
|
|
|
|
def get_icon_image(xx):
|
|
directory_path = os.path.dirname(__file__)
|
|
file_path = os.path.join(directory_path, 'images\\')
|
|
image =Image.open(file_path+xx)
|
|
photo = ImageTk.PhotoImage(image)
|
|
return photo
|
|
|
|
|
|
|
|
def jfshelpme(win,helpfor):
|
|
top = tk.Toplevel(win)
|
|
scrolling = tk.Scrollbar(top)
|
|
scrolling.pack(side=tk.RIGHT, fill=tk.Y)
|
|
|
|
frame = tk.Frame(top)
|
|
frame.pack()
|
|
text = tk.Text(frame, height=30, width=100, wrap=tk.WORD)
|
|
text.pack(side=tk.LEFT, fill=tk.Y)
|
|
scrolling.config(command=text.yview)
|
|
text.config(yscrollcommand=scrolling.set)
|
|
|
|
photoImg = get_icon_image('nm405.gif')
|
|
photoImg2= get_icon_image('methods.gif')
|
|
photoImg3= get_icon_image('kinetics.gif')
|
|
photoImg4= get_icon_image('xenon.gif')
|
|
|
|
text.tag_configure('it', font=('Arial', 10, 'italic'))
|
|
text.tag_configure('h1', font=('Verdana', 16, 'bold'))
|
|
text.tag_configure('h2', font=('Verdana', 12, 'bold'))
|
|
text.tag_configure('h3', font=('Verdana', 10, 'bold'))
|
|
|
|
if (helpfor == 0): #do you need help with the device?
|
|
text.image_create(tk.END,image=photoImg)
|
|
text.insert(tk.END, " Calibration\n", 'h1')
|
|
text.insert(tk.END, "\nTo calibrate the Instrument we need two laserpointer of different colors und known wavelength.\nFor example a blue [405nm] and red [650nm] one.\n")
|
|
text.insert(tk.END, "1) First take two messurements with your device und save the files with the [Save] button under a comprehensible name (e.g. 405nm.data) \n")
|
|
text.insert(tk.END, "2) Open the calibration dialog and insert the wavelength in [nm] and afterwards select the respective file. <first peak> stands for the lower and <second peak> for the higher wavelength.\n")
|
|
text.insert(tk.END, "3) Now you can use the [Calibrate] button to calibrate the instrument and [Save Config] will the store the configuration.\n")
|
|
text.insert(tk.END,"\nAfter this procedure you can switch the [nm] scale on and use other option:\n")
|
|
text.insert(tk.END,'\nMethods\n','h2')
|
|
text.insert(tk.END,"\nAs a Photometer to messure the transmittance or absorbance depending on the concentration of colored compounds.\n\n")
|
|
text.image_create(tk.END,image=photoImg2)
|
|
text.insert(tk.END,"\n\nKinetic\n",'h2')
|
|
text.insert(tk.END,"\nThe instrument can messure in specific intervalls over time the change in absorbance. From this data it is possible to determine the rate of the reaction.\n")
|
|
text.image_create(tk.END,image=photoImg3)
|
|
text.insert(tk.END,"\n Baseline\n",'h1')
|
|
text.insert(tk.END,"\nIn order to messure the absorption of a compound in the cuvette, you have to messure the intensity of the the light passing through the reference cell.\n")
|
|
text.insert(tk.END,"The intensity of the light at a specific wavelength depends on the kind of lightsource. The spectrum of a tungstone lamp is different from a LED etc.\n")
|
|
text.insert(tk.END,"\nTo make things easy: the value <threshold for the baseline> cuts off the beginning and the end where the lightsource is not strong enought to give reasonable results ")
|
|
text.image_create(tk.END,image=photoImg4)
|
|
text.insert(tk.END,"\nFor example xenon-lamp as a source. If the value of the threshold is set to 100 (green), the baseline will start at 380nm and end at 510nm\n")
|
|
text.insert(tk.END,"If the value of the threshold is set to 50 (red), the baseline will start at 370nm and end at 695nm. The baseline determines the range of messurement\n")
|
|
|
|
elif (helpfor == 1): #do you need help with the device?
|
|
text.image_create(tk.END,image=photoImg)
|
|
text.insert(tk.END, " Calibration\n", 'h1')
|
|
text.insert(tk.END, "\nTo calibrate the Instrument we need two laserpointer of different colors und known wavelength.\nFor example a blue [405nm] and red [650nm] one.\n")
|
|
text.insert(tk.END, "1) First take two messurements with your device und save the files with the [Save] button under a comprehensible name (e.g. 405nm.data) \n")
|
|
text.insert(tk.END, "2) Open the calibration dialog and insert the wavelength in [nm] and afterwards select the respective file. <first peak> stands for the lower and <second peak> for the higher wavelength.\n")
|
|
text.insert(tk.END, "3) Now you can use the [Calibrate] button to calibrate the instrument and [Save Config] will the store the configuration.\n")
|
|
text.insert(tk.END,"\nAfter this procedure you can switch the [nm] scale on and use other option:\n")
|
|
text.insert(tk.END,'\nMethods\n','h2')
|
|
text.insert(tk.END,"\nAs a Photometer to messure the transmittance or absorbance depending on the concentration of colored compounds.\n\n")
|
|
text.image_create(tk.END,image=photoImg2)
|
|
text.insert(tk.END,"\n\nKinetic\n",'h2')
|
|
text.insert(tk.END,"\nThe instrument can messure in specific intervalls over time the change in absorbance. From this data it is possible to determine the rate of the reaction.\n")
|
|
text.image_create(tk.END,image=photoImg3)
|
|
### at the end
|
|
text.config(state=tk.DISABLED)
|
|
top.focus_set()
|
|
top.grab_set()
|
|
top.wait_window() |