3.1.1. broh5.lib.rendering

class broh5.lib.rendering.GuiRendering[source]

Bases: object

A class to build the graphical user interface for an HDF viewer.

This class creates various UI elements like headers, buttons, sliders, tables, and plots to facilitate user interaction with HDF data.

fig_size

Dimensions for the figure in the UI.

Type:

tuple

plot_size

Dimensions for the histogram plot in the UI.

Type:

tuple

tree_container

Container for the HDF tree structure.

Type:

UI column

select_file_button

Button to trigger file selection.

Type:

UI button

file_path_display

Label to display selected file path.

Type:

UI label

hdf_key_display

Label to display HDF key.

Type:

UI label

hdf_value_display

Label to display HDF value.

Type:

UI label

axis_list

Dropdown to select axis for slicing.

Type:

UI select

cmap_list

Dropdown to select color map for plots.

Type:

UI select

enable_zoom

Check-box to enable/disable image zoom.

Type:

UI checkbox

zoom_list

Dropdown to select zooming ratio.

Type:

UI select

enable_profile

Check-box to enable/disable the intensity-profile plot

Type:

UI checkbox

profile_list

Dropdown to select the direction of the intensity profile.

Type:

UI select

save_image_button

Button to save current image.

Type:

UI button

display_type

Dropdown to choose the display type (plot or table).

Type:

UI select

marker_list

Dropdown to select marker type for plots.

Type:

UI select

save_data_button

Button to save current data.

Type:

UI button

main_slider

Slider to navigate through slices of 3D data.

Type:

UI slider

main_table

Table to display data in tabular form.

Type:

UI table

main_plot

Matplotlib element to display plots.

Type:

UI matplotlib

zoom_profile_plot

Pyplot element to display zooming of an image or intensity-profile.

Type:

UI pyplot

min_slider

Slider to adjust the minimum value for image contrast.

Type:

UI slider

max_slider

Slider to adjust the maximum value for image contrast.

Type:

UI slider

reset_button

Button to reset adjustments.

Type:

UI button

histogram_plot

Pyplot element to display histogram of an image.

Type:

UI pyplot

image_info_table

Table to display statistical information of an image.

Type:

UI table

init_gui()[source]

Initializes and constructs the GUI elements.

class broh5.lib.rendering.FilePicker(*args: Any, **kwargs: Any)[source]

Bases: dialog

A dialog class for file picking in the GUI. Codes are adapted from an example of NiceGUI: https://github.com/zauberzeug/nicegui/tree/main/examples/local_file_picker

Allows users to browse and select files from the local filesystem where the application is running.

Parameters:
  • directory (str) – The starting directory for the file picker.

  • upper_limit (str, optional) – The upper directory limit for browsing. None by default.

  • show_hidden_files (bool, optional) – Flag to show hidden files. False by default.

  • allowed_extensions (List of str, optional) – List of allowed file extensions for filtering. None by default.

check_extension(filename: str)[source]

Check if the given filename has an allowed extension.

add_drives_toggle()[source]

Add a toggle for drive selection on Windows systems.

update_grid()[source]

Update the file grid based on the current directory and filters.

handle_double_click(GenericEventArguments)[source]

Handle double click events on the file grid.

handle_ok()[source]

Handle the OK button, click to submit the selected file path.

class broh5.lib.rendering.FileSaver(*args: Any, **kwargs: Any)[source]

Bases: dialog

A dialog class for saving files in the GUI.

Allows users to specify a file name and directory for saving files.

Parameters:
  • directory (str) – Starting directory for the file saver.

  • upper_limit (str, optional) – Upper directory limit for browsing. None by default.

  • show_hidden_files (bool, optional) – Flag to show hidden files. False by default.

  • title (str, optional) – Title for the file-name input-field. ‘File name’ by default.

add_drives_toggle()[source]

Add a toggle for drive selection on Windows systems.

update_grid() None[source]

Update the file grid based on the current directory.

handle_double_click(e: GenericEventArguments) None[source]

Handle double-click events on the file grid.

handle_save()[source]

Handle the Save button, click to submit the specified file path.

create_folder_dialog()[source]

Open a dialog for creating a new folder.

create_folder(folder_name: str, dialog: ui.dialog)[source]

Create a new folder with the specified name.