grapa.shared.funcgui.FuncGUI
- class grapa.shared.funcgui.FuncGUI(func, textsave, hiddenvars=None, tooltiptext='')
Bases:
objectThe GUI request from the displayed Curve a list of FuncGUI objects. Each FuncGUI objects contains a possible action the user can perform. The class FuncGUI rationalizes the following:
out.append([self.currentCalc, 'EQE current', ['ROI', 'interpolate', 'spectrum'], [[min(self.x()), max(self.x())], 'linear', fnames[0]], {}, [{'width': 15}, {'width': 8, 'field': 'Combobox', 'values': ['linear', 'quadratic']}, {'width': 8, 'field': 'Combobox', 'values': fnames}]])
Becomes:
line = FuncGUI(self.currentCalc, 'EQE current') line.append('ROI', [min(self.x()), max(self.x())], {'width': 15}) line.appendcbb('interpolate', 'linear', ['linear', 'quadratic'], {'width': 8}) line.append("", "", "Frame") # new line line.appendcbb('spectrum', fnames[0], fnames, options={'width': 8}) out.append(line)
- __init__(func, textsave, hiddenvars=None, tooltiptext='')
In principe, create FuncGUI with func, textsave, hiddenvars, then create fields with .append() one after the other One may also do FuncGUI(None, None).initLegacy(oldformat)
Methods
__init__(func, textsave[, hiddenvars, ...])In principe, create FuncGUI with func, textsave, hiddenvars, then create fields with .append() one after the other One may also do FuncGUI(None, None).initLegacy(oldformat)
append(label, value[, widgetclass, bind, ...])Examples
Shortcut to append a new line in the GUI
append_pickfile(label, value, initialdir)Notation shortcut to .append() an entry and a button to choose a file
appendcbb(label, value, values[, bind, ...])Notation shortcut to .append(), append a Combobox: .appendcbb("my value", "a", ["a", "b", "c"])
Returns str lines, with slight reformatting from function docstring
init_legacy(line)Initialize a FuncGUI object from the legacy list format.
is_similar(other)Determines if 2 FuncGUI objects are similar Checks for function name, textsave, hidden vars, fields labels Does NOT check for field values - user force same value for all
move_item(old_idx, new_idx)Use-case: a posteriori append a field, want to place it not at last position.
set_funcdocstring_alt(documentation)for use in printHelp
set_hiddenvars(hiddenvars)hiddenvars is a dict of variables that will be provided to func when called by the GUI, in addition to the values provided by the user
set_tooltiptext(tooltiptext)A short text that will be displayed as tooltip in the GUI
Attributes
ASKFORFILENAME- append(label, value, widgetclass='Entry', bind=None, keyword=None, options=None, **kwargs)
Examples
- Parameters:
label – ‘my choice’
value – ‘b’
widgetclass – ‘Entry’, ‘Combobox’… a tk widget (or other library if implemented). Frame: new line. None: to not show in the GUI and not provide a value (e.g. display label)
keyword – for the parameter to be submitted as keyword variable
bind –
a (validation) function on the widget value. Examples:
’beforespace’: <<ComboboxSelected>> remove all before first space
’previouswidgettogglereadonly’: toggle previous widget readonly state
other: <<ComboboxSelected>> call the function provided as ‘bind’
options – {‘width’: 8, ‘values’: [‘a’, ‘b’, ‘c’]}
kwargs – additional keywords will be added into options
- append_newline()
Shortcut to append a new line in the GUI
- append_pickfile(label, value, initialdir: str | None)
Notation shortcut to .append() an entry and a button to choose a file
- appendcbb(label, value, values, bind=None, keyword=None, options=None, **kwargs)
Notation shortcut to .append(), append a Combobox: .appendcbb(“my value”, “a”, [“a”, “b”, “c”])
- func_docstring_to_text() → list
Returns str lines, with slight reformatting from function docstring
- init_legacy(line)
Initialize a FuncGUI object from the legacy list format.
- is_similar(other)
Determines if 2 FuncGUI objects are similar Checks for function name, textsave, hidden vars, fields labels Does NOT check for field values - user force same value for all
- move_item(old_idx, new_idx)
Use-case: a posteriori append a field, want to place it not at last position. For example, CurveMCA fit which line are prepared in base class of FitHandler Beware index if moving after old_idx.
- set_funcdocstring_alt(documentation)
for use in printHelp
- set_hiddenvars(hiddenvars)
hiddenvars is a dict of variables that will be provided to func when called by the GUI, in addition to the values provided by the user
- set_tooltiptext(tooltiptext)
A short text that will be displayed as tooltip in the GUI