polo.windows package¶
Submodules¶
polo.windows.ftp_dialog module¶
-
class
polo.windows.ftp_dialog.FTPDialog(ftp_connection=None, parent=None)[source]¶ Bases:
PyQt5.QtWidgets.QDialogFTPDialog 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.QDialogPop 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
imageattribute to the state of the favoriteQRadioButton.
Private method to enable or disable navigation by date or spectrum buttons based on the content of the current image. Tests the
Imageinstance referenced by theimageattribute to determine if it is linked to a future date, previous date or alt spectrum image through it’snext_image,previous_imageandalt_imageattributes respectively. If an attribute == None, then the button that requires that attribute will be disabled.
-
_set_cocktail_details()[source]¶ Private method that shows the
imageattribute 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
pathattribute of theImageinstance referenced by theimageattribute.
-
_set_image_details()[source]¶ Private method that displays the
Imageinstance referenced by theimageattribute.
-
classify_image(crystals=False, clear=False, precipitate=False, other=False)[source]¶ Set the human classification of the
Imageinstances referenced by theimageattribute.- 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
-
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
imageattribute to next the available imaging date, defaults to Falseprev_date (bool, optional) – If True, set
imageattribute to previous imaging date, defaults to Falsealt (bool, optional) – If True, set
imageattribute to an alt spectrum image, defaults to False
polo.windows.log_dialog module¶
polo.windows.main_window module¶
-
class
polo.windows.main_window.MainWindow[source]¶ Bases:
PyQt5.QtWidgets.QMainWindow,polo.designer.UI_main_window.Ui_MainWindowQMainWindow that ultimately is the parent of all other included widgets.
-
BAR_COLORS= [15, 13, 14, 4]¶
-
_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_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
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
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
runattribute 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_runthe pixmaps of thecurrent_runare unloaded to free up memory.- Parameters
q (list) – List containing the run to be opened. Likely originating from the
RunOrganizerwidget.
-
_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
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_FILESconstant. 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
Runthey have loaded and selected. Currently,Runfunctionality 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
-
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 filepathQLineEditwidget.
-
_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
QCheckBoxinstances.- 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
QCheckBoxinstances. Should be called in the __init__ function before displaying the dialog to the user.- Returns
Dictionary of image classifications which map to the
QCheckBoxthat corresponds to that image classification- Return type
dict
-
_validate_typed_path()[source]¶ Private method that validates that a filepath in the filepath
QLineEditwidget 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
RunorHWIRuninstance.
-
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
-
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
-
property
subtitle¶ Subtitle the user has entered for the presentation via the subtitle
QLineEditwidget. 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
QLineEditwidget. 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.QDialogRunImporterDialog 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)
-
_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
HWIRunimports.
-
_display_cocktail_files(menu_type=None)[source]¶ Private method that displays the available cocktail files to the user via the
MenuQComboBoxwidget.- 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
HWIRunimports.
-
_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 selectedImportCandidateif it has been changed and then updates data display widgets with the information from the currently selectedImportCandidateinstance.
-
_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
QFileBrowserinstance 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
-
_remove_run()[source]¶ Removes a run as an import candidate and refreshes the
QlistWidgetto reflect the removal.
Private method that sets the cocktail
QComboBoxbased on theMenuinstance referenced by theselected_candidate`attribute. This method is used to convey to the user which :class:`~polo.utils.io_utils.Menuhas been selected for a givenImportCandidate.
Private method that sets the
MenutypeQRadioButtonsgiven aMenutype 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
-
_verify_run_name()[source]¶ Private method to verify a run name. If run name fails verification clears the runname
QLineEditwidget 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
-
property
selected_candidate¶ The currently selected
ImportCandidateif one exists, otherwise returns None.- Returns
Currently selected candidate
- Return type
ImportCandidate
-
property
selection_dict¶ Returns a dictionary who’s keys are
Runattributes and values are the values ofRunImporterDialogwidgets 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.QDialogSmall 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
Private method that sets the current index of the
QComboBoxbased on the currentcocktail_menuattribute of theRuninstance referenced by therunattribute.
Private method that display cocktails in the
MenuQComboBoxbased on the current menu type selection. Either displays soluble or membrane cocktail menus.
-
_set_run_date()[source]¶ Set the
dateattribute of theRunreferenced by therunattribute from the value in theQDateEditwidget.
-
_update_plate_id()[source]¶ Private method that updates the plate_id attribute of the Run instance references by the
runattribute based on the contents of the plate IDQLineEditwidget.
-
_update_run()[source]¶ Private wrapper method that calls all other _update methods and then closes the dialog.
Private method that updates the cocktail_menu attribute of the Run instance referenced by the
runattribute based on the currentMenuQComboBoxselection.
-
_update_spectrum()[source]¶ Private method that update the spectrum of the
runattribute and the images in that run based on the current selection of the spectrumQComboBox.
The
polo.utils.io_utils.Menuinstances that are currently being displayed to the user via theMenu:QComboBoxwidget.- Returns
List of
polo.utils.io_utils.Menuinstances- Return type
list
-
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.QDialogSmall 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
-
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_current_selection()[source]¶ 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_links()[source]¶ 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