polo.windows package

Submodules

polo.windows.ftp_dialog module

class polo.windows.ftp_dialog.FTPDialog(ftp_connection=None, parent=None)[source]

Bases: PyQt5.QtWidgets.QDialog

FTPDialog class acts as the interface for interacting with a remote FTP server. Allows for browsing and downloading files stored on the server.

Parameters
  • ftp_connection (FTP, optional) – Existing FTP connection, defaults to None

  • parent (QWidget, optional) – Parent widget, defaults to None

CONNECTED_ICON = '/home/ethan/Documents/github/HWI/Marco_Polo/src/data/images/icons/connected.png'
DISCONNECTED_ICON = '/home/ethan/Documents/github/HWI/Marco_Polo/src/data/images/icons/disconnected.png'
DOWNLOAD_ICON = '/home/ethan/Documents/github/HWI/Marco_Polo/src/data/images/icons/download.png'
connect_ftp()[source]

Attempt to establish a connection to an ftp server. If the connection is successful then recursively walk through the user’s home directory and display available directories and files via the fileBrowser widget. If the user has an extremely large number of files this can take a while. If the connection fails show the user the error code thrown by ftplib.

property connected
download_selected_files()[source]

Opens a file dialog for the user to select a location to download remote files to. All files / directories that are currently selected in the FTPDialog will then be appended to download_files attribute, marking them for download. A message box informing the user that files are downloading is shown and then the FTPDialog closes.

At this point the method that originally created the FTPDialog instance should realize the dialog is closed and check for an open FTP connection and the presence of files in the download_file attribute (indicating the user had selecting files for downloading).

An FTPDownloadThread instance can then be created to download files in the background without interrupting other Polo interfaces.

property host

Get user entered FTP host.

Returns

host address

Return type

str

property password

Return user entered password.

Returns

password

Return type

str

set_connection_status(connected=False)[source]

Change the Qlabel that displays the current connection status to the user.

Parameters

connected (bool, optional) – If FTP connection is successful, defaults to False

property username

Return username.

Returns

username

Return type

str

polo.windows.image_pop_dialog module

class polo.windows.image_pop_dialog.ImagePopDialog(image, parent=None)[source]

Bases: PyQt5.QtWidgets.QDialog

Pop up that displays a selected image in a larger view. Intended to be used with the PlateViewer widget when a user selects an image from the grid.

Parameters

image (Image) – Image to show

_change_favorite_status()[source]

Private method that updates the favorite status of the current image attribute to the state of the favorite QRadioButton.

_set_allowed_navigation_functions()[source]

Private method to enable or disable navigation by date or spectrum buttons based on the content of the current image. Tests the Image instance referenced by the image attribute to determine if it is linked to a future date, previous date or alt spectrum image through it’s next_image , previous_image and alt_image attributes respectively. If an attribute == None, then the button that requires that attribute will be disabled.

_set_cocktail_details()[source]

Private method that shows the image attribute metadata in the text display widgets.

_set_groupbox_title()[source]

Private method that set the the title of main groupbox to the basename of the path attribute of the Image instance referenced by the image attribute.

_set_image_details()[source]

Private method that displays the Image instance referenced by the image attribute.

classify_image(crystals=False, clear=False, precipitate=False, other=False)[source]

Set the human classification of the Image instances referenced by the image attribute.

Parameters
  • crystals (bool, optional) – If True, classify the image as crystal, default False

  • clear (bool, optional) – If True, classify the image as clear, defaults to False

  • precipitate (bool, optional) – If True, classify the image as precipitate, defaults to False

  • other (bool, optional) – If True, classify as the image as other, defaults to False

property image
The Image

being displayed.

Returns

The Image instance to be displayed

Return type

Image

show()[source]

Shows the dialog window.

show_alt_image(next_date=False, prev_date=False, alt=False)[source]

Show a linked image based on boolean flags.

Parameters
  • next_date (bool, optional) – If True, set image attribute to next the available imaging date, defaults to False

  • prev_date (bool, optional) – If True, set image attribute to previous imaging date, defaults to False

  • alt (bool, optional) – If True, set image attribute to an alt spectrum image, defaults to False

show_image()[source]

Show the Image instance referenced by the image attribute.

polo.windows.log_dialog module

class polo.windows.log_dialog.LogDialog(parent=None)[source]

Bases: PyQt5.QtWidgets.QDialog

Small dialog for displaying the contents of the Polo log file.

clear_log()[source]

Deletes the contents of the log file.

display_log_text()[source]

Opens the log file and writes the contents to textBrowser widget for display to the user.

save_log_file()[source]

Saves the current log file contents to a new location.

polo.windows.main_window module

class polo.windows.main_window.MainWindow[source]

Bases: PyQt5.QtWidgets.QMainWindow, polo.designer.UI_main_window.Ui_MainWindow

QMainWindow that ultimately is the parent of all other included widgets.

BAR_COLORS = [15, 13, 14, 4]
_check_current_run_for_missing_images()[source]
_check_for_new_version()[source]

Use requests to check the Polo GitHub page for a newer release version. If a newer version exists open a message box that the user can click to take them to the releases page.

_handle_citation_menu(action)[source]
_handle_delete_backups()[source]

Private method that handles a user request to delete all backup mso files. If backups cannot be deleted shows a message box indicating failure to delete.

_handle_export(action, export_path=None)[source]

Private method to handle when a user requests to export a run to a non-xtal file format.

Parameters
  • action (QAction) – QAction that describes the export type the user has requested

  • export_path (str or Path, optional) – Path to export file to, defaults to None

_handle_file_menu(selection)[source]

Private method that handles user interaction with the file menu; this usually means saving a run as an xtal file.

Parameters

selection (QAction) – QAction that describes user selection

_handle_help_menu(action)[source]

Private method that handles user interaction with the help menu. All selections open links to various pages of the documentation website.

Parameters

action (QAction) – QAction that describes the user’s selection

_handle_image_import(selection)[source]

Private method that handles when the user attempts to import images into Polo. Effectively a wrapper around other methods that provide the functionality to each option in the import menu.

Parameters

selection – QAction. QAction from user menu selection.

_handle_opening_run(new_run)[source]

Private method that handles opening a run. For the most part, this means setting the run attribute of other widgets to the new_run argument. The setter methods of these widgets should then handle updating their interfaces to reflect the new run being opened. Also calls _tab_limiter() and _plot_limiter() to set allowed functions for the user based on the type of run they open.

Additionally, if this is not the first run to be opened, before the new_run is set as the current_run the pixmaps of the current_run are unloaded to free up memory.

Parameters

q (list) – List containing the run to be opened. Likely originating from the RunOrganizer widget.

_handle_plot_selection()[source]

Private method to handle user plot selections.

TODO: Move all plot methods into their own widget

_handle_recent_import(action)[source]

Private method that handles when recent import filepath menu items are selected. Attempts to open the run specified by the filepath.

Parameters

action (QAction) – QAction associated with recent import

_handle_tool_menu(selection)[source]

Private method that handles selection of all options available to the user in the Tools section of the main window menu.

Parameters

selection (QAction) – User’s menu selection

_on_changed_tab(i)[source]

Private method that handles GUI behavior when a user switches from one tab to another.

Parameters

i – Int. The index of the current tab, after user has changed tabs.

_plot_limiter()[source]

Private method to limit the types of plots that can be shown based on the type of the current_run.

_read_recent_imports()[source]

Read recent import filepaths from the filepath specified by the RECENT_FILES constant. If paths in this file exist then creates a menu item under the “Recents” import menu for that filepath.

_save_file_dialog()[source]

Private method to open a QFileDialog to get a location to save a run to.

Returns

Path to save file to

Return type

str

_set_tab_icons()[source]

Private method that assigns icons to each of the main run interface tabs. Should be called in the __init__ method before the main window is shown to the user.

_tab_limiter()[source]

Private method that limits the interfaces that a user is allowed to interact with based on the type of Run they have loaded and selected. Currently, Run functionality is limited due to the fact cocktails cannot be mapped to images.

closeEvent(event)[source]

Handle main window close events. Writes mso backup files of all loaded runs that have human classifications so they can be restored later.

Parameters

event (QEvent) – QEvent

static delete_all_backups()[source]

Deletes all backup mso files.

Raises

e – Any exceptions thrown by the function call

Returns

True, if backups are deleted

Return type

bool

static get_widget_dims(self, widget)[source]

Returns the width and height of a QWidget as a tuple.

Parameters

widget (QWidget) – QWidget

Returns

width and height of the widget

Return type

tuple

static layout_widget_lister(self, layout)[source]

List all widgets in a given layout.

Parameters

layout (QLayout) – QLayout that contains widgets

Returns

Tuple of widgets in the given layout

Return type

tuple

polo.windows.pptx_dialog module

class polo.windows.pptx_dialog.PptxDesignerDialog(runs, parent=None)[source]

Bases: PyQt5.QtWidgets.QDialog

_browse_and_update_line_edit()[source]

Private method that calls _get_save_path() to open a file browser. If the user selects a save path using the file browser then displays this path in the filepath QLineEdit widget.

_get_images_from_auto_entry(run)[source]
_get_images_from_manual_entry(run)[source]
_get_save_path()[source]

Private method that opens a file browser and returns the selected save filepath.

Returns

Filepath if one is specified by the user, empty string otherwise

Return type

str

_parse_image_classifications()[source]

Private method to get all currently selected image classifications by reading the state of all image classification QCheckBox instances.

Returns

Set of all selected image classifications

Return type

set

_parse_manual_image_entry(num_wells)[source]

Private method to return the image (well) numbers if they have been manually specified by the user.

_set_up_image_classification_checkboxes()[source]

Private method that sets up the labels for the image classifications QCheckBox instances. Should be called in the __init__ function before displaying the dialog to the user.

Returns

Dictionary of image classifications which map to the QCheckBox that corresponds to that image classification

Return type

dict

_validate_typed_path()[source]

Private method that validates that a filepath in the filepath QLineEdit widget is actually a valid path that a pptx file could be saved there.

Returns

True if the path is valid, otherwise returns None and shows a message box to the user.

Return type

True or None

_write_presentation(run=None)[source]

Private method that actually does the work of generating a presentation from a Run or HWIRun instance.

Parameters

run (Run or HWIRun, optional) – Run to create a presentation from, defaults to None

Returns

Path to the pptx presentation is write is successful, Exception otherwise.

Return type

str or Exception

property all_dates

The state of the “Include all Dates” QCheckBox. If it is checked this indicates that a time resolved slide should be included in the presentation.

Returns

State of the QCheckBox

Return type

bool

property all_specs

The state of the “Include all Spectrums” QCheckBox. If it is checked this indicates that a multi-spectrum slide should be included in the presentation.

Returns

State of the QCheckBox

Return type

bool

check_for_warnings()[source]
property favorite

State of the favorite button. Returns boolean based on check status.

Returns:

bool: State of the favorite button

property human

State of the human classifier QCheckBox.

Returns

State of the QCheckBox

Return type

bool

property marco

State of the MARCO classifier QCheckBox.

Returns

State of the QCheckBox

Return type

bool

set_default_titles()[source]
setup_run_tree()[source]
property subtitle

Subtitle the user has entered for the presentation via the subtitle QLineEdit widget. If no string has been entered will return the empty string.

Returns

The presentation subtitle

Return type

str

property title

Title the user has entered for the presentation via the title QLineEdit widget. If no string has been entered will return the empty string.

Returns

The presentation title

Return type

str

polo.windows.run_importer module

class polo.windows.run_importer.RunImporterDialog(current_run_names, parent=None)[source]

Bases: PyQt5.QtWidgets.QDialog

RunImporterDialog instances are the user interface for importing runs from rar archives or directories stored on the local machine.

Parameters

current_run_names (list or set) – Runnames that are already in use by the current Polo session (Run names should be unique)

_close_dialog()[source]
_could_not_import_message(prefix, paths)[source]

Private method that creates a message box popup for when imports fail.

Parameters
  • prefix (str) – First part of the error message. Something like “Could not import the following files:”

  • paths (list) – List of filepaths that could not be imported

Returns

QMessageBox

Return type

QMessageBox

_disable_hwi_import_tools()[source]

Private method to disable widgets that should only be used for HWIRun imports.

_display_candidate_paths()[source]

rewrite import candidate class is no longer used

_display_cocktail_files(menu_type=None)[source]

Private method that displays the available cocktail files to the user via the Menu QComboBox widget.

Parameters

menu_type (str, optional) – Key for which kind of cocktail screens to display, defaults to None. “m” for membrane screens and “s” for soluble screens.

_enable_hwi_import_tools()[source]

Private method to enable widgets that should only be used for HWIRun imports.

_handle_candidate_change()[source]

TODO: Needs rewrite for clarity

Private method that calls _update_selected_candidate() and then _populate_fields(). This updates the data of the previously selected ImportCandidate if it has been changed and then updates data display widgets with the information from the currently selected ImportCandidate instance.

_import_files(rar=True)[source]
Parameters

rar (bool, optional) – If True opens the filebrowser for rar archives and filters out all other import types, defaults to True

_open_browser(rar=True)[source]

Private method that opens a QFileBrowser instance that allows the user to select files for import. The allowed filetype is set using the rar flag.

Parameters

rar (bool, optional) – If True, allow user to only import Rar archive files defaults to True. If False only allows the user to import directories.

Returns

List of files the user has selected for import

Return type

list

_populate_fields(import_candidate)[source]

TODO: Needs a rewrite

_remove_run()[source]

Removes a run as an import candidate and refreshes the QlistWidget to reflect the removal.

_set_cocktail_menu(import_candidate)[source]

Private method that sets the cocktail QComboBox based on the Menu instance referenced by the selected_candidate`attribute. This method is used to convey to the user which :class:`~polo.utils.io_utils.Menu has been selected for a given ImportCandidate.

_set_cocktail_menu_type_radiobuttons(type_)[source]

Private method that sets the Menu type QRadioButtons given a Menu type key.

Parameters

type (str) – Menu type key. If type_ == ‘s’ then soluble menu radioButton state is set to True. If ‘type_` == ‘m’ then membrane radiobutton state is set to True

_set_image_spectrum(spectrum)[source]

Private method that sets the image spectrum comboBox based on the spectrum argument. Should be used to display the inferred spectrum of an import candidate to the user when that candidate is selected.

Parameters

spectrum (str) – Spectrum key

_update_candidate_run_data(import_candidate_path)[source]

Rewrite

_verify_run_name()[source]

Private method to verify a run name. If run name fails verification clears the runname QLineEdit widget and shows an error message to the user.

property all_run_names

All run names of all current :class:ImportCandidate instances.

Returns

Set of all run names

Return type

set

dragEnterEvent(self, QDragEnterEvent)[source]
dragMoveEvent(self, QDragMoveEvent)[source]
dropEvent(self, QDropEvent)[source]
property selected_candidate

The currently selected ImportCandidate if one exists, otherwise returns None.

Returns

Currently selected candidate

Return type

ImportCandidate

property selection_dict

Returns a dictionary who’s keys are Run attributes and values are the values of RunImporterDialog widgets that correspond to these attributes.

Example of the dictionary returned below.

{
    'cocktail_menu': Menu,
    'date': datetime,
    'run_name': str,
    'image_spectrum': str
}
Returns

dict

Return type

dict

polo.windows.run_updater_dialog module

class polo.windows.run_updater_dialog.RunUpdaterDialog(run, run_names, parent=None)[source]

Bases: PyQt5.QtWidgets.QDialog

Small dialog for updating basic information about a run after it has been imported. Includes updating the plate ID, the cocktail menu used and the image spectrum.

Parameters
  • run (Run or HWIRun) – Run to update

  • run_names (list or set) – Names of already loaded runs.

  • parent (QWidget, optional) – Parent widget, defaults to None

_select_run_menu()[source]

Private method that sets the current index of the QComboBox based on the current cocktail_menu attribute of the Run instance referenced by the run attribute.

_set_cocktail_menu()[source]

Private method that display cocktails in the Menu QComboBox based on the current menu type selection. Either displays soluble or membrane cocktail menus.

_set_run_date()[source]

Set the date attribute of the Run referenced by the run attribute from the value in the QDateEdit widget.

_update_date()[source]
_update_plate_id()[source]

Private method that updates the plate_id attribute of the Run instance references by the run attribute based on the contents of the plate ID QLineEdit widget.

_update_run()[source]

Private wrapper method that calls all other _update methods and then closes the dialog.

_update_run_cocktail_menu()[source]

Private method that updates the cocktail_menu attribute of the Run instance referenced by the run attribute based on the current Menu QComboBox selection.

_update_spectrum()[source]

Private method that update the spectrum of the run attribute and the images in that run based on the current selection of the spectrum QComboBox.

property current_menus

The polo.utils.io_utils.Menu instances that are currently being displayed to the user via the Menu :QComboBox widget.

Returns

List of polo.utils.io_utils.Menu instances

Return type

list

property run

The run being updated.

Returns

The run being updated

Return type

Run or HWIRun

updated_run_signal

polo.windows.secure_dave_dailog module

polo.windows.settings_dialog module

polo.windows.spectrum_dialog module

class polo.windows.spectrum_dialog.SpectrumDialog(loaded_runs)[source]

Bases: PyQt5.QtWidgets.QDialog

Small dialog used to link runs together by image spectrum. This is generally done when the same plate has been imaged using different photographic technologies. Linking the runs together allows the user to switch between the images in either run easily.

Parameters

loaded_runs (list) – List of runs that have been loaded into Polo

display_suggestion()[source]

Show the link suggestion to the user by selecting suggested links.

get_selections()[source]

Retrieve the runs that have been selected by the user or by suggestion.

Returns

list of selected run names

Return type

list

get_spectrum_list(run)[source]

Returns the listwidget that a run should be assigned to based on the run’s image type.

Parameters

run (Run) – Run object to assign to a listWidget

Returns

QListWidget to place that run into

Return type

QListWidget

Link the currently selected runs together. Creates a circular linked list structure.

populate_list_widgets()[source]

Adds items to each image spectrum type list widget based on the Run objects stored in the loaded_runs attribute.

show_error_message(message=':(')[source]

Helper method for showing a QErrorMessage dialog to the user.

Parameters

message – String. The message text to show to the user.

Suggest runs to link together based on their imaging dates. A link suggestion will be made if the images were taken on the same day but the runs are labeled as different image types.

Returns

Suggested links as list of tuples, each tuple containing two runs that are suggested for linking.

Return type

list

validate_selection(selected_runs)[source]

polo.windows.time_res_dialog module

class polo.windows.time_res_dialog.TimeResDialog(available_runs)[source]

Bases: PyQt5.QtWidgets.QDialog

display_runs()[source]
get_HWI_runs()[source]
sort_available_runs_by_date()[source]
validate_user_selection()[source]

Module contents