Create project UI

class simba.ui.create_project_ui.ProjectCreatorPopUp[source]

Bases: object

Mixin for GUI pop-up windows that accept user-inputs for creating a SimBA project.

_images/ProjectCreatorPopUp.webp
Example

>>> ProjectCreatorPopUp()
extract_frames()[source]
run()[source]
update_body_part_dropdown(selected_value)[source]
update_img(selected_value)[source]

Set machine learning hyperparameters UI

class simba.ui.machine_model_settings_ui.MachineModelSettingsPopUp(config_path: Union[str, PathLike])[source]

Bases: PopUpMixin, ConfigReader

GUI window for specifying ML model training parameters.

check_meta_data_integrity()[source]
clear_cache()[source]
dropdown_switch_entry_box_state(box, dropdown)[source]
find_meta_file_cnt()[source]
get_expected_meta_dict_entry_keys()[source]
load_config()[source]
save_config()[source]
save_global()[source]

SimBA ML settings frame

class simba.ui.ml_settings_frm.GetMLSettingsFrame(parent: Frame, lbl_width: int = 35, bx_width: int = 35)[source]

Bases: object

Creates ML name definition LabelFrame panel in ProjectCreatorPopUp interface.

_images/GetMLSettingsFrame.png
add_entry_box()[source]
fill_frm()[source]
get_existing_values()[source]
remove_entry_box()[source]

SimBA tkinter methods

simba.ui.tkinter_functions.CreateLabelFrameWithIcon(parent: ~typing.Union[~tkinter.Toplevel, ~tkinter.LabelFrame, ~tkinter.Canvas, ~tkinter.Frame], header: str, icon_name: str, padx: ~typing.Optional[int] = None, pady: ~typing.Optional[int] = None, relief: str = 'solid', width: ~typing.Optional[int] = None, bg: ~typing.Optional[str] = None, font: tuple = ('DejaVu Sans', 10, 'bold'), icon_link: ~typing.Optional[str] = <class 'tkinter.LabelFrame'>, tooltip_key: ~typing.Optional[str] = None)[source]
simba.ui.tkinter_functions.CreateToolTip(widget, text)[source]
class simba.ui.tkinter_functions.DropDownMenu(parent=None, dropdownLabel='', choice_dict=None, labelwidth='', com=None, val: Optional[Any] = None, **kw)[source]

Bases: Frame

Legacy, use simba.ui.tkinter_functions.SimBADropDown().

disable()[source]
enable()[source]
getChoices()[source]
setChoices(choice)[source]
class simba.ui.tkinter_functions.Entry_Box(parent: Union[Frame, Canvas, LabelFrame, Toplevel, Tk], fileDescription: Optional[str] = '', labelwidth: Optional[Union[int, str]] = None, label_bg_clr: Optional[str] = None, status: typing_extensions.Literal['normal', 'disabled', 'readonly'] = 'normal', validation: Optional[Union[Callable, str]] = None, trace: Optional[Callable] = None, entry_box_width: Optional[Union[int, str]] = None, entry_box_clr: Optional[str] = 'white', img: Optional[str] = None, value: Optional[Any] = None, bg_clr: Optional[str] = None, label_font: tuple = ('DejaVu Sans', 8), entry_font: tuple = ('DejaVu Sans', 8), tooltip_key: Optional[str] = None, justify: typing_extensions.Literal['left', 'center', 'right'] = 'left', cmd: Optional[Callable] = None, allow_blank: bool = False, **kw)[source]

Bases: Frame

bind_combobox_keys()[source]
destroy()[source]

Destroy this and all descendants widgets.

property entry_get
entry_set(val)[source]
run_cmd(x)[source]
set_bg_clr(clr: str)[source]
set_state(setstatus)[source]
class simba.ui.tkinter_functions.FileSelect(parent=None, fileDescription='', color=None, title: Optional[str] = None, lblwidth: Optional[int] = None, file_types=None, bg_clr: Optional[str] = 'white', dropdown: Optional[Union[DropDownMenu, SimBADropDown]] = None, entry_width: Optional[int] = 20, status: Optional[str] = None, lbl_icon: Optional[str] = None, font: Tuple = ('DejaVu Sans', 8), initialdir: Optional[Union[str, PathLike]] = None, initial_path: Optional[Union[str, PathLike]] = None, tooltip_txt: Optional[str] = None, tooltip_key: Optional[str] = None, **kw)[source]

Bases: Frame

property file_path
setFilePath()[source]
set_state(setstatus)[source]
class simba.ui.tkinter_functions.FolderSelect(parent: Union[Frame, LabelFrame, Canvas, Toplevel], folderDescription: Optional[str] = '', color: Optional[str] = None, label_bg_clr: Optional[str] = None, font: Tuple = ('DejaVu Sans', 8), title: Optional[str] = '', lblwidth: Optional[int] = 0, bg_clr: Optional[str] = 'white', entry_width: Optional[int] = 20, lbl_icon: Optional[str] = None, initialdir: Optional[Union[str, PathLike]] = None, tooltip_txt: Optional[str] = None, tooltip_key: Optional[str] = None, **kw)[source]

Bases: Frame

property folder_path
setFolderPath()[source]
set_folder_path(folder_path)[source]
class simba.ui.tkinter_functions.SimBADropDown(parent: Union[Frame, Canvas, LabelFrame, Toplevel, Tk], dropdown_options: Union[Iterable[Any], List[Any], Tuple[Any]], label: Optional[str] = None, label_width: Optional[int] = None, label_font: tuple = ('DejaVu Sans', 8), label_bg_clr: Optional[str] = None, dropdown_font_size: Optional[int] = None, justify: typing_extensions.Literal['left', 'right', 'center'] = 'center', img: Optional[str] = None, dropdown_width: Optional[int] = None, command: Optional[Callable] = None, value: Optional[Any] = None, state: Optional[str] = None, searchable: bool = False, tooltip_txt: Optional[str] = None, tooltip_key: Optional[str] = None)[source]

Bases: Frame

Create a dropdown menu widget with optional searchable functionality.

This class creates a ttk.Combobox dropdown menu with a label, supporting both readonly and searchable modes. When searchable mode is enabled, users can type to filter the dropdown options.

Parameters
  • Tk) (parent (Frame | Canvas | LabelFrame | Toplevel |) – The parent widget container.

  • Tuple[Any]) (dropdown_options (Iterable[Any] | List[Any] |) – List of options to display in the dropdown menu.

  • optional) (tooltip_key (str,) – Text label displayed next to the dropdown. Default: None.

  • optional) – Width of the label in characters. Default: None.

  • optional) – Font tuple for the label. Default: Formats.FONT_REGULAR.value.

  • optional) – Background color for the label. Default: None.

  • optional) – Font size for the dropdown text. Default: None.

  • (str) (justify) – Text justification in the dropdown (β€˜left’, β€˜center’, β€˜right’). Default: β€˜center’.

  • optional) – Width of the dropdown widget in characters. Default: None.

  • optional) – Callback function to execute when an option is selected. Default: None.

  • optional) – Initial selected value for the dropdown. Default: None.

  • optional) – Initial state of the dropdown (β€˜normal’, β€˜disabled’). Default: None.

  • (bool) (searchable) – If True, allows typing to filter dropdown options. Default: False.

  • optional) – Tooltip text to display on hover. Default: None.

  • optional) – Key for tooltip lookup in TOOLTIPS dictionary. For dictionary, see simba.assets.lookups.tooptips.json. Default: None.

Example

>>> dropdown = SimBADropDown(parent=parent_frm, dropdown_options=['Option 1', 'Option 2', 'Option 3'], label='Select option:', searchable=True)
>>> selected = dropdown.get_value()
bind_combobox_keys()[source]
change_options(values: List[str], set_index: Optional[int] = None, set_str: Optional[str] = None, auto_change_width: Optional[bool] = True)[source]
disable()[source]
enable()[source]
getChoices()[source]
get_value()[source]
on_select(event)[source]
setChoices(choice)[source]
set_value(value: Any)[source]
set_width(width: int)[source]
simba.ui.tkinter_functions.SimBALabel(parent: Union[Frame, Canvas, LabelFrame, Toplevel], txt: str, txt_clr: str = 'black', bg_clr: Optional[str] = None, hover_fg_clr: Optional[str] = None, font: tuple = ('DejaVu Sans', 8), hover_font: Optional[Tuple] = None, relief: str = 'flat', compound: Optional[typing_extensions.Literal['left', 'right', 'top', 'bottom', 'center']] = 'left', justify: Optional[str] = None, link: Optional[str] = None, width: Optional[int] = None, padx: Optional[int] = None, pady: Optional[int] = None, cursor: Optional[str] = None, img: Optional[str] = None, anchor: Optional[str] = None, tooltip_key: Optional[str] = None, hover_img: Optional[ndarray] = None)[source]
simba.ui.tkinter_functions.SimBARadioButton(parent: Union[Frame, Canvas, LabelFrame, Toplevel], txt: str, variable: Union[BooleanVar, StringVar], txt_clr: Optional[str] = 'black', font: Optional[Tuple] = ('DejaVu Sans', 8), compound: Optional[str] = 'left', img: Optional[Union[PhotoImage, str]] = None, enabled: Optional[bool] = True, tooltip_txt: Optional[str] = None, value: bool = False, cmd: Optional[Callable] = None, cmd_kwargs: Optional[Dict[Any, Any]] = None) Radiobutton[source]
class simba.ui.tkinter_functions.SimBAScaleBar(parent: Union[Frame, Canvas, LabelFrame, Toplevel, Tk], label: Optional[str] = None, label_width: Optional[int] = None, orient: typing_extensions.Literal['horizontal', 'vertical'] = 'horizontal', length: int = 200, value: Optional[int] = 95, showvalue: bool = True, label_clr: str = 'black', lbl_font: tuple = ('DejaVu Sans', 8), scale_font: tuple = ('DejaVu Sans', 8, 'italic'), lbl_img: Optional[str] = None, from_: int = -1, resolution: int = 1, to: int = 100, tickinterval: Optional[int] = None, troughcolor: Optional[str] = None, activebackground: Optional[str] = None, sliderrelief: typing_extensions.Literal['raised', 'sunken', 'flat', 'ridge', 'solid', 'groove'] = 'flat')[source]

Bases: Frame

get() Union[int, float][source]
get_value() Union[int, float][source]
set_value(value: int)[source]
class simba.ui.tkinter_functions.SimBASeperator(parent: Union[Frame, Canvas, LabelFrame, Toplevel, Tk], color: Optional[str] = 'black', orient: typing_extensions.Literal['horizontal', 'vertical'] = 'horizontal', cursor: Optional[str] = None, borderwidth: Optional[int] = None, takefocus: Optional[int] = 0, height: int = 1, relief: typing_extensions.Literal['raised', 'sunken', 'flat', 'ridge', 'solid', 'groove'] = 'flat')[source]

Bases: Frame

simba.ui.tkinter_functions.SimbaButton(parent: Union[Frame, Canvas, LabelFrame, Toplevel], txt: str, txt_clr: Optional[str] = 'black', bg_clr: Optional[str] = '#f0f0f0', active_bg_clr: Optional[str] = None, hover_bg_clr: Optional[str] = '#d1e0e0', hover_font: Optional[Tuple] = ('DejaVu Sans', 8, 'bold'), font: Optional[Tuple] = ('DejaVu Sans', 8), width: Optional[int] = None, height: Optional[int] = None, compound: Optional[str] = 'left', img: Optional[Union[PhotoImage, str]] = None, cmd: Optional[Callable] = None, cmd_kwargs: Optional[Dict[Any, Any]] = None, enabled: Optional[bool] = True, anchor: str = 'w', thread: Optional[bool] = False, tooltip_txt: Optional[str] = None, tooltip_key: Optional[str] = None) Button[source]
simba.ui.tkinter_functions.SimbaCheckbox(parent: Union[Frame, Toplevel, LabelFrame, Canvas], txt: str, txt_clr: Optional[str] = 'black', bg_clr: Optional[str] = None, txt_img: Optional[str] = None, txt_img_location: typing_extensions.Literal['left', 'right', 'top', 'bottom'] = 'right', font: Optional[Tuple[str, str, int]] = ('DejaVu Sans', 8), val: Optional[bool] = False, state: typing_extensions.Literal['disabled', 'normal'] = 'normal', indicatoron: bool = True, cmd: Optional[Callable] = None, tooltip_txt: Optional[str] = None, tooltip_key: Optional[str] = None)[source]
class simba.ui.tkinter_functions.ToolTip(widget)[source]

Bases: object

hidetip()[source]
showtip(text)[source]

Display text in tooltip window

class simba.ui.tkinter_functions.TwoOptionQuestionPopUp(question: str, option_one: str, option_two: str, title: str, link: Optional[str] = None)[source]

Bases: object

Helpe to create a two-option question tkinter pop up window (e.g., YES/NO).

Parameters
  • question (str) – Question to present to the user. E.g., DO YOU WANT TO PROCEED?.

  • option_one (str) – The first user option. E.g., YES.

  • option_one – The second user option. E.g., NO.

  • title (str) – The window titel in the top banner of the pop-up. E.g., A QUESTION FOR YOU!.

  • link (Optional[str]) – If not None, then a link to documentation presenting background info about the user choices.

run(selected_option)[source]
simba.ui.tkinter_functions.bindToMousewheel(event, canvas)[source]
simba.ui.tkinter_functions.callback(url)[source]
simba.ui.tkinter_functions.create_scalebar(parent: Frame, name: str, min: int, max: int, cmd: object = None)[source]
simba.ui.tkinter_functions.form_validator_is_numeric(inStr, acttyp)[source]
simba.ui.tkinter_functions.get_menu_icons()[source]
simba.ui.tkinter_functions.hxtScrollbar(master)[source]
simba.ui.tkinter_functions.onFrameConfigure(canvas)[source]

Reset the scroll region to encompass the inner frame

simba.ui.tkinter_functions.onMousewheel(event, canvas)[source]
simba.ui.tkinter_functions.on_mouse_scroll(event, canvas)[source]
simba.ui.tkinter_functions.unbindToMousewheel(event, canvas)[source]

SimBA create user-defined pose config UI

class simba.ui.user_defined_pose_creator.PoseConfigCreator(pose_name: str, animal_cnt: int, img_path: Union[str, PathLike], bp_list: List[str], animal_id_int_list: List[int], circle_scale: Optional[int] = None)[source]

Bases: PlottingMixin

Class for creating user-defined pose-estimation pipeline in SimBA through a GUI interface.

..seealso::

GitHub tutorial/documentation.

Parameters
  • pose_name (str) – Name of the user-defined pose-estimation setting.

  • no_animals (str) – Number of animals in the user-defined pose-estimation setting.

  • img_path (str) – Path to image representation of user-defined pose-estimation setting

  • bp_list (List[str]) – Body-parts in the user-defined pose-estimation setting.

  • animal_id_int_list (List[int]) – Integers representing the animal ID which the body-parts belong to.

Examples

>>> pose_config_creator = PoseConfigCreator(pose_name="My_test_config", no_animals=2, img_path='simba/splash_050122.png', bp_list=['Ear', 'Nose', 'Left_ear', 'Ear', 'Nose', 'Left_ear'], animal_id_int_list= [1, 1, 1, 2, 2, 2])
>>> pose_config_creator.launch()
launch()[source]
save()[source]

SimBA set video info UI

class simba.ui.video_info_ui.VideoInfoTable(config_path: Union[str, PathLike], video_dir: Optional[Union[str, PathLike]] = None, video_info_path: Optional[Union[str, PathLike]] = None)[source]

Bases: ConfigReader, PopUpMixin

Create GUI that allows users to modify resolutions, fps, and pixels-per-mm interactively of videos within the SimBA project. Data is stored within the project_folder/logs/video_info.csv file in the SimBA project.

Parameters
  • config_path (Union[str, os.PathLike]) – path to SimBA project config file in Configparser format

  • video_dir (Union[str, os.PathLike]) – Optional path to directory with video files. If None, then read from the SimBA project as dictated by project config. Default None.

  • video_info_path (Optional[Union[str, os.PathLike]]) – Optional path to vide_info.csv file. If None, then read from the SimBA project as dictated by project config. Default None.

..seealso::

Tutorial.

Example

>>> ui = VideoInfoTable(config_path=r"C:    roubleshooting\mitra\project_folder\project_config.ini")
>>> ui.run()
run()[source]

SimBA video timelapse

class simba.ui.video_timelaps.TimelapseSlider(video_path: Union[str, PathLike], frame_cnt: int = 25, crop_ratio: Optional[int] = 50, padding: int = 60, ruler_divisions: int = 6, show_ruler: bool = True, ruler_height: Optional[int] = None, ruler_width: Optional[int] = None, img_width: Optional[int] = None, img_height: Optional[int] = None, use_timestamps: bool = True)[source]

Bases: object

Interactive timelapse viewer with segment selection sliders.

Creates a Tkinter GUI window displaying a timelapse composite image generated from evenly-spaced frames across a video. Includes interactive sliders to select start and end times for video segments, with visual highlighting of the selected segment and frame previews.

_images/TimelapseSlider.png
Parameters
  • video_path (Union[str, os.PathLike]) – Path to video file to create timelapse from.

  • frame_cnt (int) – Number of frames to include in timelapse composite. Default 25.

  • ruler_width (Optional[int]) – Width per frame in pixels. If None, calculated to match video width. Default None.

  • crop_ratio (Optional[int]) – Percentage of frame width to keep (0-100). Default 50.

  • padding (int) – Padding in pixels added to timelapse when ruler is shown. Default 60.

  • ruler_divisions (int) – Number of major divisions on time ruler. Default 6.

  • show_ruler (bool) – If True, display time ruler below timelapse. Default True.

  • ruler_height (int) – Height of ruler in pixels. Default 60.

  • use_timestamps (bool) – If True, display timestamps (HH:MM:SS) in labels and ruler. If False, display frame numbers. Default True.

Example

>>> slider = TimelapseSlider(video_path='path/to/video.mp4', frame_cnt=25, crop_ratio=75)
>>> slider.run()
>>> # Use sliders to select segment, then access selected times and frames:
>>> start_time = slider.get_start_time()  # seconds (float)
>>> end_time = slider.get_end_time()  # seconds (float)
>>> start_time_str = slider.get_start_time_str()  # "HH:MM:SS" string
>>> end_time_str = slider.get_end_time_str()  # "HH:MM:SS" string
>>> start_frame = slider.get_start_frame()  # frame number (int)
>>> end_frame = slider.get_end_frame()  # frame number (int)
>>> slider.close()
close()[source]
get_end_frame() int[source]
get_end_time() float[source]
get_end_time_str() str[source]
get_start_frame() int[source]
get_start_time() float[source]
get_start_time_str() str[source]
run()[source]

SimBA import pose frame

class simba.ui.import_pose_frame.ImportPoseFrame(parent_frm: Optional[Union[Frame, Canvas, LabelFrame, Frame]] = None, config_path: Optional[Union[str, PathLike]] = None, idx_row: Optional[int] = 0, idx_column: Optional[int] = 0)[source]

Bases: ConfigReader, PopUpMixin

_images/ImportPoseFrame.webp
Parameters
  • parent_frm (Optional[Union[Frame, Canvas, LabelFrame, ttk.Frame]]) – Parent frame to insert the Import pose frame into. If None, one is created.

  • config_path (Optional[Union[str, os.PathLike]]) –

  • idx_row (Optional[int]) – The row in parent_frm to insert the Import pose frame into. Default: 0.

  • idx_column (Optional[int]) – The column in parent_frm to insert the Import pose frame into. Default: 0.

Example

>>> _ = ImportPoseFrame(config_path='/Users/simon/Desktop/envs/simba/troubleshooting/two_black_animals_14bp/project_folder/project_config.ini')
>>> _ = ImportPoseFrame(config_path=r"C:    roubleshooting\simba_blob_project\project_folder\project_config.ini")
create_import_menu(data_type_choice: typing_extensions.Literal['CSV (DLC/DeepPoseKit)', 'JSON (BENTO)', 'H5 (multi-animal DLC)', 'SLP (SLEAP)', 'CSV (SLEAP)', 'H5 (SLEAP)', 'TRK (multi-animal APT)', 'MAT (DANNCE 3D)', 'CSV (SimBA BLOB)', 'CSV (SimBA YOLO)'])[source]

SimBA import videos frame

class simba.ui.import_videos_frame.ImportVideosFrame(parent_frm: Optional[Union[Frame, Canvas, LabelFrame, Frame]] = None, config_path: Optional[Union[str, PathLike]] = None, idx_row: Optional[int] = 0, idx_column: Optional[int] = 0)[source]

Bases: PopUpMixin, ConfigReader

_images/ImportVideosFrame.webp
Parameters
  • parent_frm (Optional[Union[Frame, Canvas, LabelFrame, ttk.Frame]]) – Parent frame to insert the Import Videos frame into. If None, one is created.

  • config_path (Optional[Union[str, os.PathLike]]) –

  • idx_row (Optional[int]) – The row in parent_frm to insert the Videos frame into. Default: 0.

  • idx_column (Optional[int]) – The column in parent_frm to insert the Videos frame into. Default: 0.

Example

>>> ImportVideosFrame(config_path='/Users/simon/Desktop/envs/simba/troubleshooting/two_black_animals_14bp/project_folder/project_config.ini')

SimBA batch process menus

class simba.video_processors.batch_process_menus.BatchProcessFrame(input_dir: Union[str, PathLike], output_dir: Union[str, PathLike])[source]

Bases: PopUpMixin

Interactive GUI that collect user-inputs for batch processing videos (e.g., cropping, clipping etc.). User-selected output is stored in json file format within the user-defined output_dir

Parameters
  • input_dir (str) – Input folder path containing videos for bath processing.

  • output_dir (str) – Output folder path for where to store the processed videos.

Example

>>> batch_preprocessor = BatchProcessFrame(input_dir=r'MyInputVideosDir', output_dir=r'MyOutputVideosDir')
>>> batch_preprocessor.create_main_window()
>>> batch_preprocessor.create_video_table_headings()
>>> batch_preprocessor.create_video_rows()
>>> batch_preprocessor.create_execute_btn()
>>> batch_preprocessor.main_frm.mainloop()
apply_fps_to_all()[source]
apply_quality_to_all()[source]
apply_resolution_to_all()[source]
apply_trim_to_all()[source]
batch_process_crop_function(video_name)[source]
create_execute_btn()[source]
create_main_window()[source]
create_video_rows()[source]
create_video_table_headings()[source]
execute()[source]
get_file_menu()[source]
get_input_files()[source]
inverse_all_cb_ticks(variable_name=None)[source]
perform_unit_tests(out_video_dict)[source]
preferences_pop_up()[source]
reset_crop()[source]

SimBA get pixels per millimeter converstion UI

class simba.ui.px_to_mm_ui.GetPixelsPerMillimeterInterface(video_path: Union[str, PathLike], known_metric_mm: float, line_thickness: Optional[float] = None, circle_size: Optional[float] = None)[source]

Bases: object

Graphical interface to compute how many pixels represents a metric millimeter.

Parameters
  • video_path (Union[str, os.PathLike]) – Path to a video file on disk.

  • known_metric_mm (float) – Known millimeter distance to get the pixels conversion factor for.

Returns

The number of pixels per metric millimeter.

Return type

float

Example

>>> runner = GetPixelsPerMillimeterInterface(video_path='/Users/simon/Desktop/envs/simba/troubleshooting/two_black_animals_14bp/project_folder/videos/Together_1.avi', known_metric_mm=140)
>>> runner.run()
>>> runner = GetPixelsPerMillimeterInterface(video_path='/Users/simon/Desktop/blank_video.mp4', known_metric_mm=140)
>>> runner.run()
run()[source]

SimBA pop-up UIs

SimBA pop-up mixin

class simba.mixins.pop_up_mixin.PopUpMixin(title: str, config_path: Optional[str] = None, main_scrollbar: Optional[bool] = True, size: Tuple[int, int] = (960, 720), icon: Optional[str] = None)[source]

Bases: object

Methods for pop-up windows in SimBA. E.g., common methods for creating pop-up windows with drop-downs, checkboxes, entry-boxes, listboxes etc.

Parameters
  • title (str) – Pop-up window title

  • config_path (Optional[configparser.Configparser]) – path to SimBA project_config.ini. If path, the project config is read in. If None, the project config is not read in.

  • size (tuple) – HxW of the pop-up window. The size of the pop-up window in pixels.

  • main_scrollbar (bool) – If True, the pop-up window is scrollable.

add_to_listbox_from_entrybox(list_box: Listbox, entry_box: Entry_Box)[source]

Add a value that populates a tkinter entry_box to a tkinter listbox.

Parameters
  • list_box (Listbox) – The tkinter Listbox to add the value to.

  • entry_box (Entry_Box) – The tkinter Entry_Box containing the value that should be added to the list_box.

add_value_to_listbox(list_box: Listbox, value: float)[source]

Add a float value to a tkinter listbox.

Parameters
  • list_box (Listbox) – The tkinter Listbox to add the value to.

  • value (float) – Value to add to the listbox.

add_values_to_several_listboxes(list_boxes: List[Listbox], values: List[float])[source]

Add N values to N listboxes. E.g., values[0] will be added to list_boxes[0].

Parameters
  • list_boxes (List[Listbox]) – List of Listboxes that the values should be added to.

  • values (List[float]) – List of floats that will be added to the list_boxes.

children_cnt_main() int[source]

Find the number of children (e.g., labelframes) currently exist within a main pop-up window. Useful for finding the row at which a new frame within the window should be inserted.

create_cb_frame(cb_titles: List[str], main_frm: Optional[Union[Frame, Canvas, LabelFrame, Frame]] = None, frm_title: Optional[str] = '', idx_row: Optional[int] = -1, command: Optional[Callable[str, Any]] = None) Dict[str, BooleanVar][source]

Creates a labelframe with checkboxes and inserts the labelframe into a window.

_static/img/create_cb_frame.png

Note

One checkbox will be created per cb_titles. The checkboxes will be labeled according to the cb_titles. If checking/un-checking the box should have some effect, pass that function as command which takes the name of the checked/unchecked box.

Parameters
  • main_frm (Optional[Union[Frame, Canvas, LabelFrame, ttk.Frame]]) – The pop-up window to insert the labelframe into.

  • cb_titles (List[str]) – List of strings representing the names of the checkboxes.

  • frm_title (Optional[Callable[[str], Any]]) – Title of the frame.

  • idx_row (Optional[int]) – The location in main_frm to create the LabelFrame. If -1, then at the bottom.

  • frm_title – Optional function callable associated with checking/unchecking the checkboxes.

Return Dict[str, BooleanVar]

Dictionary holding the cb_titles as keys and the BooleanVar representing if the checkbox is ticked or not.

Example

>>> PopUpMixin.create_cb_frame(cb_titles=['Attack', 'Sniffing', 'Rearing'], frm_title='My classifiers')
create_choose_number_of_body_parts_frm(project_body_parts: List[str], run_function: object, title: str = 'SELECT NUMBER OF BODY-PARTS', dropdown_lbl: str = '# of body-parts')[source]

Many menus depend on how many animals the user choose to compute metrics for. Thus, we need to populate the menus dynamically. This function creates a single drop-down menu where the user select the number of animals the user choose to compute metrics for. It inserts this drop-down iat the bottom of the pop-up window, and ties this dropdown menu choice to a callback.

Parameters
  • project_body_parts (List[str]) – Options of the dropdown menu.

  • run_function (object) – Function tied to the choice in the dropdown menu.

create_clf_checkboxes(main_frm: Union[Frame, LabelFrame, Toplevel, Canvas], clfs: List[str], title: str = 'SELECT CLASSIFIER ANNOTATIONS')[source]

Creates a labelframe with one checkbox per classifier, and inserts the labelframe into the bottom of the pop-up window.

Note

Legacy. Use create_cb_frame instead.

create_dropdown_frame(drop_down_titles: List[str], drop_down_options: List[str], frm_title: Optional[str] = '', idx_row: Optional[int] = -1, main_frm: Optional[Union[Frame, Canvas, LabelFrame, Frame]] = None) Dict[str, DropDownMenu][source]

Creates a labelframe with dropdowns.

_static/img/create_dropdown_frame.png
Parameters
  • main_frm (Optional[Union[Frame, Canvas, LabelFrame, ttk.Frame]]) – The pop-up window to insert the labelframe into. If None, one will be created.

  • drop_down_titles (List[str]) – The titles of the dropdown menus.

  • drop_down_options (List[str]) – The options in each dropdown. Note: All dropdowns must have the same options.

  • frm_title (Optional[str]) – Title of the frame.

Return Dict[str, BooleanVar]

Dictionary holding the drop_down_titles as keys and the drop-down menus as values.

Example

>>> PopUpMixin.create_dropdown_frame(drop_down_titles=['Dropdown 1', 'Dropdown 2', 'Dropdown 2'], drop_down_options=['Option 1', 'Option 2'], frm_title='My dropdown frame')
create_run_frm(run_function: Callable, title: Optional[str] = 'RUN', btn_txt_clr: Optional[str] = 'black', idx: Optional[int] = None, btn_icon_name: Optional[str] = 'rocket', padx: int = 0, pady: int = 0) None[source]

Create a label frame with a single button with a specified callback.

Parameters
  • btn_txt_clr – The color of the text on the execute button.

  • idx – If not none, then the index of the main frame where to insert the RUN labelframe.

  • btn_icon_name – Name of the icon to use for the run button. If None, then no icon.

  • run_function (object) – The function/method callback of the button.

  • title (str) – The title of the frame.

enable_dropdown_from_checkbox(check_box_var: BooleanVar, dropdown_menus: List[DropDownMenu])[source]

Given a single checkbox, enable a bunch of dropdowns if the checkbox is ticked, and disable the dropdowns if the checkbox is un-ticked.

Parameters
  • check_box_var (BooleanVar) – The checkbox associated tkinter BooleanVar.

  • dropdown_menus (List[DropDownMenu]) – List of dropdowns which status is controlled by the check_box_var.

enable_entrybox_from_checkbox(check_box_var: BooleanVar, entry_boxes: List[Entry_Box], reverse: bool = False)[source]

Given a single checkbox, enable or disable a bunch of entry-boxes based on the status of the checkbox.

Parameters
  • check_box_var (BooleanVar) – The checkbox associated tkinter BooleanVar.

  • entry_boxes (List[Entry_Box]) – List of entry-boxes which status is controlled by the check_box_var.

  • reverse (bool) – If False, the entry-boxes are enabled with the checkbox is ticked. Else, the entry-boxes are enabled if checkbox is unticked. Default: False.

frame_children(frame: Union[Frame, Toplevel, Canvas, LabelFrame]) int[source]

Find the number of children (e.g., labelframes) currently exist within specified frame.Similar to children_cnt_main, but accepts a specific frame rather than the main frame beeing hardcoded.

place_frm_at_top_right(frm: Toplevel)[source]

Place a TopLevel tkinter pop-up at the top right of the monitor. Note: call before putting scrollbars or converting to Canvas.

static place_window_at_corner(window: Toplevel, corner: typing_extensions.Literal['top_left', 'top_right', 'bottom_left', 'bottom_right'], offset_x: int = 0, offset_y: int = 0) None[source]

Place the window at a screen corner. Placement is deferred (via after(0, …)) so the window is laid out first; call right after building the window.

Parameters
  • win – A tk.Toplevel or tk.Tk window.

  • corner – One of β€œtop_left”, β€œtop_right”, β€œbottom_left”, β€œbottom_right”.

  • offset_x – Pixels from the corner horizontally (positive = inward).

  • offset_y – Pixels from the corner vertically (positive = inward).

remove_from_listbox(list_box: Listbox)[source]

Remove the current selection in a listbox from a listbox.

Parameters

list_box (Listbox) – The listbox that the current selection should be removed from.

update_config() None[source]

Helper to update the SimBA project config file

update_file_select_box_from_dropdown(filename: str, fileselectbox: FileSelect)[source]

Updates the text inside a tkinter FileSelect entrybox with a new string.