fitspy.apps.tkinter package


fitspy.apps.tkinter.callbacks module

Callback functions encapsulated in a class to interact with the GUI

class fitspy.apps.tkinter.callbacks.Callbacks

Bases: object

Callback functions to interact with the GUI of the spectra fitting appli

Variables:
  • spectra (Spectra object) – List that contains all Spectrum objects

  • current_spectrum (Spectrum object) – The current selected spectrum to work with

  • cids (list of ints) – connection ids that can be used with FigureCanvasBase.mpl_disconnect

  • show_plot (bool) – Activation key for (re)plotting

  • lines (list of Matplotlib.Lines2D) – Lines related to all the spectra displaying

  • nearest_lines (list Matplotlib.Lines2D) – The nearest profiles of the mouse position when clicking (limited to 10)

  • tmp (matplotlib.text.Annotation) – Annotation to display fit parameters in the plot

  • selected_frame (str) – Frame to enable between ‘Baseline’ and ‘Peaks’

  • model (dict) – Dictionary issued from a .json model reloading

  • ncpus (int or str) – Number of CPUs to work with in fitting. If ncpus = “auto”, determine automatically this number according to the number of spectra to handle and the number of available CPUs. if ncpus is None (default value), consider the value passed through fit_settings.params[‘ncpus’]

update_figure_settings()

Update figure settings

rescale()

Rescale the figure

outliers_calculation()

Calculate the outliers (limit)

set_outliers_coef()

Set the outliers coefficient

show_all()

Show all spectra and highlight spectrum on mouse over

show_hide_results(view)

Show/Hide the ‘paramsview’ or the ‘statsview’

save_results(dirname_res=None)

Save all results (peaks parameters) in .csv files

load_model(fname_json=None)

Load a model from a .json file

get_ncpus(nfiles)

Return the number of CPUs to work with

apply_model(model_dict=None, fnames=None, fit_params=None, ncpus=None)

Apply model to the selected spectra

apply_model_to_all()

Apply model to the all the spectra

messagebox_continue(fnames)

Open a messagebox if no models are found and return True/False concerning process continuation

save(fnames, fname_json=None)

Save spectra in a .json file

save_selection(fname_json=None)

Save selected spectra models in a .json file

save_all(fname_json=None)

Save all spectra models in a .json file

reload(fname_json=None)

Reload spectra models from a .json file

plot()

Plot baseline and peak models after ‘ax’ clearing

on_press_baseline_peaks(event)

Callback function associated to the mouse press event in the ‘Baseline’ and ‘Peaks’ LabelFrames for enabling/disabling

baseline_is_subtracted_message()

Show an error message associated with the baseline

add_baseline_point(x, y)

Add baseline point from the (x,y)-coordinate

del_baseline_point(x, _)

Delete the closest baseline ‘x’-point

apply_baseline_settings(fnames=None)

Apply baseline settings

apply_baseline_settings_to_all()

Apply baseline settings to all the spectra

set_baseline_settings()

Set baseline settings from the baseline to the appli

load_baseline(fname=None)

Load a baseline from a row-column .txt file

load_user_model(model)

Load users model from file to be added to PEAK_MODELS or BKG_MODEL

add_peaks_point(x, y)

Add peak from the (x,y)-coordinates

del_peaks_point(x, _)

Delete the closest peak ‘x’-point

auto_peaks(model_name=None)

Define peaks from automatic detection

set_bkg_model()

Set bkg_model

update_fit_settings()

Update fit settings

colorize_from_fit_status(fnames)

Colorize the fileselector items from the fit success status

fit(fnames=None)

Fit the peaks

fit_all()

Fit the peaks for all the spectra

set_range()

Set range from the spectrum to the appli

apply_range(fnames=None)

Set an apply range to the spectrum/spectra

apply_range_to_all()

Set and apply range to all the spectra

update_normalize()

Update ‘normalize’ to all the spectra

get_value(name)

Return the float value related to the ‘name’ attribute

update_normalize_range()

Update the normalization ranges to all the spectra

set_normalize_settings()

Set normalize settings from the spectrum to the appli

reinit(fnames=None)

Reinitialize the spectrum

reinit_all()

Reinitialize all the spectra

reassign_current_spectrum(fname)

Reassign the current spectrum from ‘fname’

remove(delete_tabview=True)

Remove all the features (spectrum attributes, baseline, tabview)

auto_eval(model_name=None, fnames=None)

Fit spectrum after evaluating baseline and peaks automatically

auto_eval_all(model_name=None)

Apply automatic fitting on all spectra

delete_all(_)

Delete all spectra

delete(fnames=None)

Delete items from spectra selected in the ‘fileselector’ or passed as argument

add_items_from_dir(dirname)

Add new items related to a ‘dirname’

add_items(fnames=None)

Add new items from a ‘fnames’ list

update_markers(fname)

Markers management in 2D-maps

update(fname=None)

Update the appli with the spectrum selected in the ‘fileselector’ or passed as argument

create_map(fname)

Create the 2D-map that consists in replacing the current spectra by the ones issued from the 2D-map extrusion

fitspy.apps.tkinter.gui module

GUI and Appli classes associated to the spectra fitting application

class fitspy.apps.tkinter.gui.GUI

Bases: Callbacks

Gui associated to the spectra fitting application

Variables:
  • canvas_map (ax_map,) – Axes and canvas related to the 2D-map figure displaying

  • figure_settings (FigureSettings obj) – Tkinter.TopLevel derivative object for figure parameters setting

  • fit_settings (FitSettings obj) – Tkinter.TopLevel derivative object for fitting parameters setting

  • paramsview (ParamsView obj) – Tkinter.TopLevel derivative object for fitting models params displaying

  • statsview (StatsView obj) – Tkinter.TopLevel derivative object for fitting stats results displaying

  • progressbar (ProgressBar obj) – Tkinter.TopLevel derivative object with progression bar

  • range_max (range_min,) – Range associated to the spectrum support

  • outliers_coef (Tkinter.DoubleVar) – Coefficient applied to the outliers limits

  • baseline_mode (Tkinter.StringVar) – Method associated with the baseline determination method (‘Semi-Auto’, ‘Linear’ or ‘Polynomial’)

  • baseline_coef (Tkinter.IntVar) – Smoothing coefficient used when calculating the baseline with the ‘Semi-Auto’ algorithm

  • baseline_attached (Tkinter.BooleanVar) – Activation keyword for baseline points attachment to the spectra

  • baseline_sigma (Tkinter.IntVar) – Smoothing gaussian coefficient applied to the spectra when calculating the attached baseline points

  • baseline_distance (Tkinter.DoubleVar) – Minimum distance used by ‘spectrum.auto_baseline’

  • baseline_mode – Type of baseline (‘Linear’ or ‘Polynomial’)

  • baseline_order_max (Tkinter.IntVar) – Max polynomial order to consider when plotting/removing the baseline

  • normalize (Tkinter.BooleanVar) – Activation keyword for spectrum profiles normalization

  • normalize_range_max (normalize_range_min,) – Ranges for searching the maximum value used in the normalization

  • model (Tkinter.StringVar) – Spectrum peak base model name among ‘Gaussian’, ‘Lorentzian’, ‘GaussianAsym’ and ‘LorentzianAsym’

  • bkg_name (Tkinter.StringVar) – Background model name among ‘None’, ‘Constant’, ‘Linear’, ‘Parabolic’ and ‘Exponential’

  • asym (Tkinter.BooleanVar) – Activation keyword to consider asymetric spectrum model

  • ax (Matplotlib.Axes object) – Current axis to work with

  • canvas (FigureCanvasTkAgg object) – Current canvas to work with

  • fileselector (common.core.appli_gui.FilesSelector object) – Widget dedicated to the files selection

frame_map_creation(spectra_map)

Create a frame_map Tkinter.Toplevel() and related ‘ax’ and ‘canvas’ as spectra_map attributes

save_settings()

Save GUI users settings

reload_settings()

Reload GUI users settings

class fitspy.apps.tkinter.gui.Appli(root, size='1550x950', force_terminal_exit=True)

Bases: GUI

Application for spectra fitting

Variables:
  • root (Tkinter.Tk object) – Root window

  • force_terminal_exit (bool) – Key to force terminal session to exit after ‘root’ destroying

on_closing()

To quit ‘properly’ the application

fitspy.apps.tkinter.gui.init_app()

Return an Appli and Tk instances

fitspy.apps.tkinter.gui.end_app(appli, root, dirname_res=None)

Quit properly the appli after saving the results if ‘dirname_res’ is given (for pytest)

fitspy.apps.tkinter.gui.fitspy_launcher(fname_json=None)

Launch the Tkinter appli

fitspy.apps.tkinter.toplevels module

Module dedicated to external widgets (Tkinter.Toplevel) creation

class fitspy.apps.tkinter.toplevels.ResultView(root)

Bases: object

Master class used by ParamsView and StatsView

show_hide()

Show/Hide the TopLevel frame

class fitspy.apps.tkinter.toplevels.ParamsView(root)

Bases: ResultView

Class for models parameters displaying

add_entry(arg, row, col, i, key, param)

Add Tk.Entry at (row, col) linked to params[i][key][arg]

add_check_button(arg, row, col, i, key, param)

Add Tk.Checkbutton at (row, col) linked to params[i][key][arg]

add_entry_peak_labels(row, col, i)

Add Tk.Entry at (row, col) linked to models_labels[i]

add_combobox_peak_model(row, col, i, model)

Add Tk.Combobox at (row, col) linked to peak_models[i]

add_combobox_bkg_model(row, col)

Add Tk.Combobox at (row, col) linked to the bkg_model

label_has_changed(i)

Update the label related to the ith-model

param_has_changed(i, key, arg)

Update the ‘key’-param ‘arg’-value related to the ith-model

model_has_changed(i)

Update the model function related to the ith-model

bkg_model_has_changed(_)

Update the ‘bkg_model’

set_header()

Set the TabView header

delete_models()

Delete selected (peak) models

update()

Update the Tabview

add_model(model, i, row, keys)

Add model in the Tabview

delete()

Delete all the values contained in frames

class fitspy.apps.tkinter.toplevels.StatsView(root)

Bases: ResultView

Class for fit statistics displaying

update()

Update the statistics

delete()

Delete all the values contained in frames

class fitspy.apps.tkinter.toplevels.Settings(root)

Bases: object

Master class for parameters setting

frame_creation(bind_fun, excluded_keys=None)

Create frame with ‘params’ linked to ‘bind_fun’

update(x, y, bind_fun=None)

Display the Toplevel ‘frame’ on (x, y) position with interactive ‘params’ settings

on_press(_)

Hide the Toplevel ‘frame’ if the mouse click is outside

show_hide()

Show/Hide the TopLevel ‘frame’

class fitspy.apps.tkinter.toplevels.FitSettings(root)

Bases: Settings

Class for fitting parameters setting

frame_creation(bind_fun, excluded_keys=None)

Create frame with ‘params’ linked to ‘bind_fun’

class fitspy.apps.tkinter.toplevels.FigureSettings(root)

Bases: Settings

Class for figure parameters setting

frame_creation(bind_fun, excluded_keys=None)

Create frame with ‘params’ linked to ‘bind_fun’

fitspy.apps.tkinter.utils module

utilities functions related to Tkinter

fitspy.apps.tkinter.utils.add(obj, row, col, sticky='', padx=5, pady=3, rspan=1, cspan=1, **kwargs)

Add tkinter object at the (row, col)-position of a grid

fitspy.apps.tkinter.utils.add_entry(frame, row, label, val, width=5, bind_fun=None)

Add 2 columns : ‘label’ and ‘val’ associated to a binding function ‘bind_fun’ at ‘row’ (int) position in a ‘frame’ (Tk.Frame)

fitspy.apps.tkinter.utils.interactive_entry(root, var, fun, width=2)

Return an interactive Tkinter.Entry binded to ‘fun’

fitspy.apps.tkinter.utils.convert_dict_from_tk_variables(parent_dict, excluded_keys=None)

Convert a dictionary from Tkinter.Variables to standard types (thanks to a recursive processing)

class fitspy.apps.tkinter.utils.ToggleFrame(master, exceptions=None, **kwargs)

Bases: LabelFrame

Class dedicated to Enable/Disable LabelFrame and its related children

Construct a labelframe widget with the parent MASTER.

STANDARD OPTIONS

borderwidth, cursor, font, foreground, highlightbackground, highlightcolor, highlightthickness, padx, pady, relief, takefocus, text

WIDGET-SPECIFIC OPTIONS

background, class, colormap, container, height, labelanchor, labelwidget, visual, width

apply_state(state, parent=None)

Apply state ‘disable’ or ‘normal’ to Frame’s children widgets

disable()

Disable Frame’s children widgets

enable()

Enable Frame’s children widgets

class fitspy.apps.tkinter.utils.FilesSelector(root, lbox_size=None)

Bases: object

Class dedicated to the files selection

Variables:
  • lbox (list of Listbox object) – Listbox associated to the selected files

  • filenames (list of str) – List of of filenames to work with

Parameters:
  • root (Tk.widget) – The main window associated to the FileSelector

  • lbox_size (list of 2 ints, optional) – Size (width, height) of the Listbox ‘lbox’. Default value is [30, 15]

move(key)

Move cursor selection according to key value (up or down)

add_items(filenames=None, ind_start=None)

Add items from a ‘filenames’ list

select_files(filenames=None)

Add items from selected files

select_dir(dirname=None)

Add items from a directory

remove()

Remove selected items

remove_all()

Remove all items

select_item(index, selection_clear=True)

Select item in the listbox

class fitspy.apps.tkinter.utils.ProgressBar(frame)

Bases: object

Class to create a progress bar

update(spectra, ntot, ncpus)

update the progressbar info during the fitspy execution