navigate.view.custom_widgets.LabelInputWidgetFactory.LabelInput
- class navigate.view.custom_widgets.LabelInputWidgetFactory.LabelInput(parent, label_pos='left', label='', input_class=<class 'tkinter.ttk.Entry'>, input_var=None, input_args=None, label_args=None, **kwargs)
Bases:
FrameWidget class that contains label and input together.
Acknowledgment: Based on the design from “Python GUI Programming: A Complete Reference Guide” by Alan D. Moore and B. M. Harwani.
For reference on widget arguments, visit: https://tkdocs.com/shipman/
To use kwargs for parent arguments, update kwargs like this:
kwargs.update(width=900, height=600). Ensure you usesuper().__init__(parent, **kwargs)to override values correctly.User Guide: Create instances of LabelInput as children of a LabelFrame for grouped data. Access the widget within LabelInput using
self.widgetfor customization. Example usage:LabelInput(settings, label_pos="top", label="Exposure Time", input_class=ttk.Spinbox, input_var=tk.IntVar(), input_args={"from_": 0.5, "to": 100, "increment": 0.1}, label_args={"height": 2, "width": 4})
- __init__(parent, label_pos='left', label='', input_class=<class 'tkinter.ttk.Entry'>, input_var=None, input_args=None, label_args=None, **kwargs)
Initialize LabelInput widget
- Parameters:
parent (tk widget) – The parent widget of the LabelInput widget
label_pos (str, optional) – The position of the label, by default “left”
label (str, optional) – The text of the label, by default “”
input_class (tk widget, optional) – The type of input widget, by default ttk.Entry
input_var (tk variable, optional) – The variable of the input widget, by default None
input_args (dict, optional) – The arguments of the input widget, by default None
label_args (dict, optional) – The arguments of the label widget, by default None
**kwargs (dict) – The arguments of the parent widget, by default None
Methods
__init__(parent[, label_pos, label, ...])Initialize LabelInput widget
get([default])Returns the value of the input widget
Returns the variable of the input widget
pad_input(left, up, right, down)Pad the input widget
set(value, *args, **kwargs)Sets the value of the input widget
set_values(values)Set values of a combobox
Attributes
- get(default=None)
Returns the value of the input widget
Creating a generic get function to catch all types of widgets, this uses the try except block for instances when tkintervariables fails
- Parameters:
default (object, optional) – The default value to return if the get value doesn’t work
- Returns:
value – The value of the input widget
- Return type:
str
Examples
>>> value = self.get()
- get_variable()
Returns the variable of the input widget
- Returns:
variable – The variable of the input widget
- Return type:
tk variable
Examples
>>> variable = self.get_variable()
- pad_input(left, up, right, down)
Pad the input widget
This is a function to pad the input widget, it will automatically set the padding of the widget
- Parameters:
left (int) – left padding
up (int) – up padding
right (int) – right padding
down (int) – down padding
Examples
>>> widget.pad_input(10, 10, 10, 10)
- set(value, *args, **kwargs)
Sets the value of the input widget
- Parameters:
value (str) – The value to set the input widget to
Examples
>>> self.set(value)
- set_values(values)
Set values of a combobox
This is a function to set the values of a combobox, it will automatically set the values and set the first value as the current
Values should be a list of strings or numbers that you want to be options in the specific widget
- Parameters:
values (list) – list of values to be set in the widget
- input_class
The widget of the input widget
- Type:
tk.Widget
- label
The label of the input widget
- Type:
ttk.Label
- variable
The variable of the input widget
- Type:
tk.Variable
- widget
Specify label position