otterpy/JFShelp.py
2020-12-29 14:19:25 +01:00

96 lines
4.9 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 jfshelpme(win,helpfor):
#### this is where we store the pictures etc
directory_path = os.path.dirname(__file__)
file_path = os.path.join(directory_path, 'images\\')
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)
image1 = Image.open(file_path+'nm405.gif')
photoImg = ImageTk.PhotoImage(image1)
image2 = Image.open(file_path+'methods.gif')
photoImg2= ImageTk.PhotoImage(image2)
image3 = Image.open(file_path+'kinetics.gif')
photoImg3= ImageTk.PhotoImage(image3)
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)
### at the end
text.config(state=tk.DISABLED)
top.focus_set()
top.grab_set()
top.wait_window()