Commit 168c0b3b authored by Michael Rudolf's avatar Michael Rudolf
Browse files

Added tooltips for many interface elements.

parent 9f47170e
......@@ -45,9 +45,11 @@ class ToolTip(object):
tw.destroy()
def CreateToolTip(widget, text):
def create_tooltip(widget, text):
toolTip = ToolTip(widget)
text = format_text(text)
def enter(event):
toolTip.showtip(text)
......@@ -55,3 +57,22 @@ def CreateToolTip(widget, text):
toolTip.hidetip()
widget.bind('<Enter>', enter)
widget.bind('<Leave>', leave)
def format_text(text, num=80):
"""
Inserts new lines into text after 'num' characters when there is a space
character.
"""
split_text = text.split(' ')
new_text = ''
current_line = ''
for s in split_text:
if len(current_line) + len(s) < num:
current_line += s + ' '
else:
new_text += current_line + '\n'
current_line = s + ' '
if current_line:
new_text += current_line
return new_text
""" Provides PhotoImage objects for all images """
import os
import tkinter as tk
from importlib import resources
......
......@@ -6,9 +6,11 @@ import pathlib
import re
import sys
import tkinter as tk
from importlib import resources
from tkinter import filedialog, messagebox, ttk
from rstevaluation import RST_pick_GUI as main
from rstevaluation import classes as rstclasses
from rstevaluation import get_icons as rsticons
from rstevaluation import processing as rstprocess
......@@ -165,6 +167,7 @@ class RST_pick_GUI(tk.Tk):
self.button_start.grid(column=1, row=7, sticky='e')
self.button_start.bind('<ButtonRelease-1>', self.start_processing)
self.add_tooltips()
self.iconphoto(True, rsticons.icon_rst())
self.make_dpi_aware()
self.update()
......@@ -224,7 +227,23 @@ class RST_pick_GUI(tk.Tk):
plot_win.wm_title('Plot Window')
return
def add_tooltips(self):
""" Adds tooltips to all elements with an entry in tooltips.json """
# Get tooltip text
with resources.path('rstevaluation', 'tooltips.json') as jpath:
with open(jpath) as jfile:
self.tooltips = json.load(jfile)
ttkeys = self.tooltips.keys()
all_vars = vars(self)
for k in all_vars.keys():
if k in ttkeys:
rstclasses.create_tooltip(
all_vars[k],
self.tooltips[k]
)
# == CALLBACKS ==
def folder_browser(self, event):
"""Callback for folderbrowser."""
f_path = filedialog.askdirectory()
......@@ -303,6 +322,19 @@ class RST_pick_GUI(tk.Tk):
opt_dlg,
text=self.cfg['units'][item[0]])
opt_dlg.label_unit.grid(column=2, row=i + 1, sticky='w')
if item[0] in self.tooltips.keys():
rstclasses.create_tooltip(
opt_dlg.label_item,
self.tooltips[item[0]]
)
rstclasses.create_tooltip(
opt_dlg.entry_item,
self.tooltips[item[0]]
)
rstclasses.create_tooltip(
opt_dlg.label_unit,
self.tooltips[item[0]]
)
def set_data(self, init=False):
''' Set contents of fields and variables according to config '''
......
{
"entry_projname": "Project name (automatically generated from input folder).",
"button_input": "Select project folder.",
"entry_input": "Project folder: Location where all data is stored.",
"button_output": "Select alternative output folder (automatically filled with input folder).",
"entry_output": "Output folder: Location where all plots and picks are stored (automatically filled with input folder).",
"opt_rst": "Select if the project is a standard ring shear test. Picks are automatically suggested and the user is asked for manual revision.",
"opt_pred": "Uses a set of predefined normal stresses that is set in the options. A warning is displayed when the actual normal stress has a large difference from the predefined value.",
"opt_vst": "Select if the project is a velocity stepping test.",
"opt_stickslip": "If enabled uses peak detection to detect stick slip events. The result is a fit of the mean between peaks and troughs. When disabled uses the full time series for fitting. In both cases the data is subsampled to create an evenly distributed dataset over all velocity steps.",
"button_options": "View and change additional options for processing.",
"button_start": "Starts the processing. Progress is displayed in the command line.",
"A": "Area of shear zone = Area of lid (DO NOT CHANGE unless you know what you do!).",
"li": "Inner lever (center cell-center shear zone) (DO NOT CHANGE unless you know what you do!).",
"lo": "Outer lever (center cell-hinge point) (DO NOT CHANGE unless you know what you do!).",
"vel": "Shear velocity for ring-shear tests. Only needed for calculating displacement in plots.",
"prec": "Precision for normal stress in filenames.",
"velnoise": "Legacy option (deprecated).",
"stressnoise": "Legacy option (deprecated).",
"cellweight": "Weight of shear cell.",
"smoothwindow": "Smoothing factor for plots and for picking. Uses a median filter over N samples.",
"pred_norms": "Predefined normal stress values.",
"nsamples": "Maximum number of samples to use to improve performance for large data sets (RST only).",
"downsample_filter": "Use downsampling filter or not (RST only).",
"peak_prominence": "Sensitivity for peak finding. Prominence = Height above background (VST only).",
"vel_accuracy": "Rounding accuracy for logarithm of velocity to determine velocity steps (VST only).",
"fit_percentiles": "Number of percentiles to take for vst fit (VST only)."
}
\ No newline at end of file
......@@ -10,6 +10,6 @@ setuptools.setup(
long_description=long_description,
long_description_content_type='text/markdown',
package_data={
'': ['*.png']
'': ['*.png', '*.json'],
}
)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment