User Interface (UI) toolsο
On this page
Create project UIο
- class simba.ui.create_project_ui.ProjectCreatorPopUp[source]ο
Bases:
objectMixin for GUI pop-up windows that accept user-inputs for creating a SimBA project.
- Example
>>> ProjectCreatorPopUp()
- simba.ui.create_project_ui.SCHEMATIC_BG = 'white'ο
Ground behind the schematic. The images themselves carry no frame, so the label supplies one β otherwise a white-ground card floats on the grey panel with no visible edge.
- simba.ui.create_project_ui.SCHEMATIC_DISPLAY_SIZE = (275, 550)ο
Logical size the pose-configuration schematics are displayed at, in px.
- simba.ui.create_project_ui.SCHEMATIC_MIN_H = 240ο
Never shrink the schematic below this, however small the screen reports itself.
- simba.ui.create_project_ui.SCHEMATIC_PAD = 4ο
Breathing room between the schematic and its border, in px.
- simba.ui.create_project_ui.SCHEMATIC_SCREEN_RESERVE = 470ο
Vertical px the rest of the tab needs (window chrome, the setting frames, the buttons). The schematic is capped to whatever is left, so it does not force scrolling on a small laptop β at 275x550 it overflowed a 1366x768 screen by ~240 px.
Set machine learning hyperparameters UIο
- class simba.ui.machine_model_settings_ui.MachineModelSettingsPopUp(config_path)[source]ο
Bases:
simba.mixins.pop_up_mixin.PopUpMixin,simba.mixins.config_reader.ConfigReaderGUI window for specifying ML model training parameters.
SimBA ML settings frameο
SimBA tkinter methodsο
- simba.ui.tkinter_functions.CreateLabelFrameWithIcon(parent, header, icon_name, padx=None, pady=None, relief='solid', width=None, bg=None, font=('DejaVu Sans', 10, 'bold'), icon_link=<class 'tkinter.LabelFrame'>, tooltip_key=None)[source]ο
- class simba.ui.tkinter_functions.DropDownMenu(parent=None, dropdownLabel='', choice_dict=None, labelwidth='', com=None, val=None, **kw)[source]ο
Bases:
tkinter.FrameLegacy, use
simba.ui.tkinter_functions.SimBADropDown().
- class simba.ui.tkinter_functions.Entry_Box(parent, fileDescription='', labelwidth=None, label_bg_clr=None, status='normal', validation=None, trace=None, entry_box_width=None, entry_box_clr='white', img=None, value=None, bg_clr=None, label_font=('DejaVu Sans', 8), entry_font=('DejaVu Sans', 8), tooltip_key=None, justify='left', cmd=None, allow_blank=False, **kw)[source]ο
Bases:
tkinter.FrameCreate a text entry field with an optional label and icon.
This class creates a tkinter Entry with a label and an optional icon to its left. The typed text is read with the
entry_getproperty and set withentry_set().- Parameters
Tk) (parent (Frame | Canvas | LabelFrame | Toplevel |) β The parent widget container.
optional) (cmd (Callable,) β Text label displayed next to the entry box. Default: ββ.
optional) β Width of the label in characters. Default: None.
optional) β Background color of the label. Default: None.
(str) (justify) β State of the entry box, βnormalβ, βdisabledβ (greyed out, not editable) or βreadonlyβ (selectable, not editable). Default: βnormalβ.
optional) β Restricts what can be typed. Only
'numeric'is implemented - it rejects any inserted character that is not a digit. Any other value leaves the entry unvalidated. Default: None.optional) β Called every time the content changes, with this Entry_Box instance as its only argument. Use it to react to typing, e.g. to enable another widget. Default: None.
optional) β Width of the entry box in characters. If None, the tkinter default is used. Default: None.
optional) β Background color of the entry box. Change it later with
set_bg_clr(). Default: βwhiteβ.optional) β Name of the icon displayed to the left of the label, e.g. βjumpβ. For accepted names, see
simba.utils.lookups.get_icons_paths(). Unknown names are ignored. Default: None.optional) β Initial content of the entry box. If None, the entry box starts empty. Default: None.
optional) β Alternative way of setting the entry box background color, applied after the widget is built. Default: None.
(tuple) (entry_font) β Font tuple for the label. Default: Formats.FONT_REGULAR.value.
(tuple) β Font tuple for the typed text. Default: Formats.FONT_REGULAR.value.
optional) β Key for tooltip lookup in TOOLTIPS dictionary, shown when hovering the label. For dictionary, see simba.assets.lookups.tooptips.json. Keys not in the dictionary are ignored. Default: None.
(str) β Alignment of the typed text, βleftβ, βcenterβ or βrightβ. Default: βleftβ.
optional) β Called with the stripped entry box content on every key release. Default: None.
(bool) (allow_blank) β Stored on the widget as
self.allow_blankfor callers that validate the entered value - whether an empty entry box is acceptable. Does not restrict typing. Default: False.kw β Additional keyword arguments passed to the underlying tkinter Frame.
- Example
>>> entry_box = Entry_Box(parent=parent_frm, fileDescription='CURRENT FRAME: ', labelwidth=20, entry_box_width=10, validation='numeric', value=0, justify='center') >>> entry_box.grid(row=0, column=0, sticky=NW) >>> frm_number = entry_box.entry_get
- property entry_getο
- class simba.ui.tkinter_functions.FileSelect(parent=None, fileDescription='', color=None, title=None, lblwidth=None, file_types=None, bg_clr='white', dropdown=None, entry_width=20, status=None, lbl_icon=None, font=('DejaVu Sans', 8), initialdir=None, initial_path=None, tooltip_txt=None, tooltip_key=None, **kw)[source]ο
Bases:
tkinter.Frame- property file_pathο
- class simba.ui.tkinter_functions.FolderSelect(parent, folderDescription='', color=None, label_bg_clr=None, font=('DejaVu Sans', 8), title='', lblwidth=0, bg_clr='white', entry_width=20, lbl_icon=None, initialdir=None, tooltip_txt=None, tooltip_key=None, **kw)[source]ο
Bases:
tkinter.Frame- property folder_pathο
- class simba.ui.tkinter_functions.SimBADropDown(parent, dropdown_options, label=None, label_width=None, label_font=('DejaVu Sans', 8), label_bg_clr=None, dropdown_font_size=None, justify='center', img=None, dropdown_width=None, command=None, value=None, state=None, searchable=False, tooltip_txt=None, tooltip_key=None)[source]ο
Bases:
tkinter.FrameCreate 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()
- simba.ui.tkinter_functions.SimBALabel(parent, txt, txt_clr='black', bg_clr=None, hover_fg_clr=None, font=('DejaVu Sans', 8), hover_font=None, relief='flat', compound='left', justify=None, link=None, width=None, padx=None, pady=None, cursor=None, img=None, anchor=None, tooltip_key=None, hover_img=None)[source]ο
- simba.ui.tkinter_functions.SimBARadioButton(parent, txt, variable, txt_clr='black', font=('DejaVu Sans', 8), compound='left', img=None, enabled=True, tooltip_txt=None, value=False, cmd=None, cmd_kwargs=None)[source]ο
- class simba.ui.tkinter_functions.SimBAScaleBar(parent, label=None, label_width=None, orient='horizontal', length=200, value=95, showvalue=True, label_clr='black', lbl_font=('DejaVu Sans', 8), scale_font=('DejaVu Sans', 8, 'italic'), lbl_img=None, from_=- 1, resolution=1, to=100, tickinterval=None, troughcolor=None, activebackground=None, sliderrelief='flat', tooltip_txt=None, tooltip_key=None)[source]ο
Bases:
tkinter.FrameCreate a slider widget with an optional label and icon.
This class creates a tkinter Scale for picking a value within a numeric range, with an optional text label and icon to its left. The selected value is read with
get_value()(orget()) and set withset_value().- Parameters
Tk) (parent (Frame | Canvas | LabelFrame | Toplevel |) β The parent widget container.
optional) (tooltip_key (str,) β Text label displayed next to the slider. If None, no label is created. Default: None.
optional) β Width of the label in characters. Default: None.
(str) (sliderrelief) β Slider orientation, βhorizontalβ or βverticalβ. Default: βhorizontalβ.
(int) (to) β Length of the slider in pixels. Default: 200.
optional) β Initial value of the slider. If None, the slider starts at
from_. Default: 95.(bool) (showvalue) β If True, the current value is printed next to the slider handle. Default: True.
(str) β Color of the label text. Default: βblackβ.
(tuple) (scale_font) β Font tuple for the label. Default: Formats.FONT_REGULAR.value.
(tuple) β Font tuple for the value and tick text drawn by the slider. Default: Formats.FONT_REGULAR_ITALICS.value.
optional) β Name of the icon displayed to the left of the label, e.g. βwidthβ. For accepted names, see
simba.utils.lookups.get_icons_paths(). Unknown names are ignored. Default: None.(int) β Lowest selectable value. Default: -1.
(int) β Step size between selectable values. Default: 1.
(int) β Highest selectable value. Default: 100.
optional) β Spacing between the value labels printed along the slider. If None, no values are printed. Default: None.
optional) β Color of the trough the slider handle moves in. If None, the tkinter default is used. Default: None.
optional) β Color of the slider handle while the cursor is over it. If None, the tkinter default is used. Default: None.
(str) β Relief style of the slider handle (βraisedβ, βsunkenβ, βflatβ, βridgeβ, βsolidβ, βgrooveβ). Default: βflatβ.
optional) β Tooltip text to display on hover. Takes precedence over
tooltip_key. Default: None.optional) β Key for tooltip lookup in TOOLTIPS dictionary. For dictionary, see simba.assets.lookups.tooptips.json. Keys not in the dictionary are ignored. Default: None.
Note
The tooltip is attached to the label and the icon - the parts of the widget that describe the setting. If neither is created, it is attached to the slider itself.
- Example
>>> scale_bar = SimBAScaleBar(parent=parent_frm, label='MAX IMAGE WIDTH (%): ', from_=10, to=100, value=50, lbl_img='width', tooltip_key='ANNOTATION_INTERFACE_MAX_IMAGE_WIDTH') >>> scale_bar.grid(row=0, column=0, sticky=NW) >>> selected = scale_bar.get_value()
- class simba.ui.tkinter_functions.SimBASeperator(parent, color='black', orient='horizontal', cursor=None, borderwidth=None, takefocus=0, height=1, relief='flat')[source]ο
Bases:
tkinter.Frame
- simba.ui.tkinter_functions.SimbaButton(parent, txt, txt_clr='black', bg_clr='#f0f0f0', active_bg_clr=None, hover_bg_clr='#d1e0e0', hover_font=('DejaVu Sans', 8, 'bold'), font=('DejaVu Sans', 8), width=None, height=None, compound='left', img=None, cmd=None, cmd_kwargs=None, enabled=True, anchor='w', thread=False, tooltip_txt=None, tooltip_key=None)[source]ο
- simba.ui.tkinter_functions.SimbaCheckbox(parent, txt, txt_clr='black', bg_clr=None, txt_img=None, txt_img_location='right', font=('DejaVu Sans', 8), val=False, state='normal', indicatoron=True, cmd=None, tooltip_txt=None, tooltip_key=None)[source]ο
- class simba.ui.tkinter_functions.TwoOptionQuestionPopUp(question, option_one, option_two, title, link=None)[source]ο
Bases:
objectHelpe 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.
SimBA UI utilitiesο
- simba.ui.utils.position_window(window, position, offset_x=0, offset_y=0, lift=True, focus=False, constrain=True, verbose=False, after_ms=10)[source]ο
Place the window at a screen position. Placement is deferred (via after(after_ms)) so the window is mapped and has real dimensions; call right after building the window.
- Parameters
window β A tk.Toplevel or tk.Tk window.
position β One of βtop_leftβ, βtop_rightβ, βbottom_leftβ, βbottom_rightβ, βmiddle_topβ, βmiddle_bottomβ, βmiddle_leftβ, βmiddle_rightβ, βcenterβ.
offset_x β Pixels from the position horizontally (positive = right for corners, right for center/middle).
offset_y β Pixels from the position vertically (positive = down for top, up for bottom, down for center).
lift β If True (default), bring the window to front after placing.
focus β If True, give the window keyboard focus after placing (default False).
constrain β If True (default), clamp position so the window stays fully on screen.
after_ms β Milliseconds to wait before placing (default 10). Use 0 for next tick; increase if placement is sporadic.
SimBA create user-defined pose config UIο
- class simba.ui.user_defined_pose_creator.PoseConfigCreator(pose_name, animal_cnt, img_path, bp_list, animal_id_int_list, circle_scale=None)[source]ο
Bases:
simba.mixins.plotting_mixin.PlottingMixinClass for creating user-defined pose-estimation pipeline in SimBA through a GUI interface.
See also
- 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()
SimBA set video info UIο
- class simba.ui.video_info_ui.VideoInfoTable(config_path, video_dir=None, video_info_path=None)[source]ο
Bases:
simba.mixins.config_reader.ConfigReader,simba.mixins.pop_up_mixin.PopUpMixinCreate 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.
See also
- Example
>>> ui = VideoInfoTable(config_path=r"C: roubleshooting\mitra\project_folder\project_config.ini") >>> ui.run()
SimBA video timelapseο
- class simba.ui.video_timelaps.TimelapseSlider(video_path, frame_cnt=25, crop_ratio=50, padding=60, ruler_divisions=6, show_ruler=True, ruler_height=None, ruler_width=None, img_width=None, img_height=None, use_timestamps=True)[source]ο
Bases:
objectInteractive 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.
- 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()
SimBA import pose frameο
- class simba.ui.import_pose_frame.ImportPoseFrame(parent_frm=None, config_path=None, idx_row=0, idx_column=0)[source]ο
Bases:
simba.mixins.config_reader.ConfigReader,simba.mixins.pop_up_mixin.PopUpMixin
- 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")
SimBA import videos frameο
- class simba.ui.import_videos_frame.ImportVideosFrame(parent_frm=None, config_path=None, idx_row=0, idx_column=0)[source]ο
Bases:
simba.mixins.pop_up_mixin.PopUpMixin,simba.mixins.config_reader.ConfigReader
- 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 get pixels per millimeter converstion UIο
- class simba.ui.px_to_mm_ui.GetPixelsPerMillimeterInterface(video_path, known_metric_mm, line_thickness=None, circle_size=None)[source]ο
Bases:
objectGraphical 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
- 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()
SimBA pop-up UIsο
SimBA pop-up mixinο
- class simba.mixins.pop_up_mixin.PopUpMixin(title, config_path=None, main_scrollbar=True, size=(960, 720), icon=None)[source]ο
Bases:
objectMethods 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, 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, value)[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, values)[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()[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, main_frm=None, frm_title='', idx_row=- 1, command=None)[source]ο
Creates a labelframe with checkboxes and inserts the labelframe into a window.
Note
One checkbox will be created per
cb_titles. The checkboxes will be labeled according to thecb_titles. If checking/un-checking the box should have some effect, pass that function ascommandwhich 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[str]) β Title of the frame.
idx_row (Optional[int]) β The location in main_frm to create the LabelFrame. If -1, then at the bottom.
command (Optional[Callable[[str], Any]]) β Optional function callable associated with checking/unchecking the checkboxes.
- Return Dict[str, BooleanVar]
Dictionary holding the
cb_titlesas 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, run_function, title='SELECT NUMBER OF BODY-PARTS', dropdown_lbl='# 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.
- create_clf_checkboxes(main_frm, clfs, title='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_frameinstead.
- create_dropdown_frame(drop_down_titles, drop_down_options, frm_title='', idx_row=- 1, main_frm=None)[source]ο
Creates a labelframe with dropdowns.
- 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_titlesas 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, title='RUN', btn_txt_clr='black', idx=None, btn_icon_name='rocket', padx=0, pady=0)[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, dropdown_menus)[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, entry_boxes, reverse=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)[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)[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, corner, offset_x=0, offset_y=0)[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).
Main GUI applicationο
- class simba.SimBA.SimbaProjectPopUp(config_path)[source]ο
Bases:
simba.mixins.config_reader.ConfigReader,simba.mixins.pop_up_mixin.PopUpMixinMain entry to the SimBA loaded project pop-up.
Project tree-view widgetο
- class simba.ui.get_tree_view.GetTreeView(data, index_col_name='', headers=('VALUE',), title='DATA', size=(800, 500), theme='clam')[source]ο
Bases:
simba.mixins.pop_up_mixin.PopUpMixinCreate a hierarchical TreeView widget for displaying nested dictionary data in a popup window.
This class creates a TreeView interface that displays nested dictionary data in an expandable tree format. Each top-level dictionary key becomes a parent node, and the nested dictionary entries become child nodes. The TreeView includes vertical and horizontal scrollbars and supports double-click expansion/collapse functionality.
Note
The TreeView automatically calculates its height based on the window size to maximize screen usage. Parent nodes can be expanded/collapsed by double-clicking.
- param Dict[str, Dict[str, Any]] data
Nested dictionary data where top-level keys become parent nodes and nested dictionaries become child nodes.
- param Optional[str] index_col_name
Header text for the tree column (first column). Default is empty string.
- param Optional[Tuple[str, β¦]] headers
Tuple of column headers for data columns. Default is (βVALUEβ,).
- param str title
Window title for the popup. Default is βDATAβ.
- param Optional[Tuple[int, int]] size
Window size as (width, height) tuple. Default is (800, 500).
- param str theme
Tkinter theme name to use. Default is βclamβ for better visual separation.
- example
>>> from simba.utils.read_write import find_all_videos_in_directory >>> from simba.utils.read_write import get_video_meta_data >>> videos = find_all_videos_in_directory(directory=r'C: roubleshooting\mitra\project_folder
- ideosβ, as_dict=True)
>>> results = {} >>> for video_name, video_path in videos.items(): >>> v = get_video_meta_data(video_path=video_path) >>> results[v['video_name']] = v >>> GetTreeView(data=results, index_col_name='VIDEO')
- example
>>> # Simple example with custom data >>> data = { >>> 'Video1': {'fps': 30, 'width': 1920, 'height': 1080}, >>> 'Video2': {'fps': 25, 'width': 1280, 'height': 720} >>> } >>> tree_view = GetTreeView(data=data, index_col_name='Videos', title='Video Metadata')
