schrodinger.ui.qt.standard.widgets.path_browse_controller module

Controller that connects a browse button to a file dialog and a display widget, decoupled from any particular layout.

Basic usage:

from schrodinger.ui.qt.standard.widgets.path_browse_controller import make_open_file_controller

controller = make_open_file_controller(
    parent=self,
    file_formats=[fileutils.MAESTRO_STRICT],
    history_id='my_panel/input',
)
# Place widgets wherever you like:
layout.addWidget(controller.displayWidget(), 0, 0)
layout.addWidget(controller.browseButton(), 0, 1)
# Connect signal:
controller.pathsChanged.connect(self._onPathsChanged)

Mapper integration:

class Model(parameters.CompoundParam):
    input_file: str

class Panel(mappers.MapperMixin, ...):
    def initSetUp(self):
        super().initSetUp()
        self.browse_ctrl = make_open_file_controller(
            parent=self,
            file_formats=[fileutils.MAESTRO_STRICT],
            history_id='my_panel/input',
        )

    def initLayOut(self):
        super().initLayOut()
        layout.addWidget(self.browse_ctrl.displayWidget(), 0, 0)
        layout.addWidget(self.browse_ctrl.browseButton(), 0, 1)

    def defineMappings(self):
        M = self.model_class
        return [(self.browse_ctrl, M.input_file)]

The controller automatically maps to the correct type (str vs list[str]) based on the file dialog’s selection mode configuration.

class schrodinger.ui.qt.standard.widgets.path_browse_controller.DisplayType

Bases: Enum

Display widget type for file browse controllers.

LineEdit = 'line_edit'
Label = 'label'
class schrodinger.ui.qt.standard.widgets.path_browse_controller.PathBrowseController(button: QAbstractButton, display_widget: QWidget, *, file_dialog: QFileDialog, parent: QObject, history_id: Optional[str] = None)

Bases: TargetMixin, QObject

Connects a browse button to a file dialog and writes the result to a display widget.

The controller knows nothing about dialog configuration. It manages: button -> show dialog -> paths -> display.

Variables:

pathsChanged – Emitted with the new paths list whenever paths change.

pathsChanged

A pyqtSignal emitted by instances of the class.

targetValueChanged

A pyqtSignal emitted by instances of the class.

__init__(button: QAbstractButton, display_widget: QWidget, *, file_dialog: QFileDialog, parent: QObject, history_id: Optional[str] = None)
Parameters:
  • button – The button whose clicked signal triggers the file dialog.

  • display_widget – Widget used to show the selected paths. Must support setText(str). If it is a QLineEdit, its editingFinished signal is connected for manual edits.

  • file_dialog – A pre-configured QFileDialog. Any QFileDialog or filedialog.FileDialog is accepted. Note that targetGetValue and targetSetValue types change based on whether the file dialog supports single or multi selection.

  • parent – QObject parent.

  • history_id – Identifier for directory memory. Dialogs with the same id remember the last directory the user navigated to.

paths() list[str]

Return the currently selected paths.

setPaths(paths: list[str])

Programmatically set the paths.

When the value changes, emits both pathsChanged and targetValueChanged.

Parameters:

paths – New path values.

allowsMultiSelection() bool

Whether the dialog allows selecting multiple files.

fileDialog() QFileDialog

Return the current file dialog.

browseButton() QAbstractButton

Return the connected browse button.

displayWidget() QWidget

Return the connected display widget.

targetGetValue() Union[str, list[str]]

Return the current value for the mapper.

This method is ONLY meant to be called by the mapper framework.

Returns str for single-select or list[str] for multi-select, matching the mapped param type.

targetSetValue(value: Union[str, list[str]])

Set the value from the mapper.

This method is ONLY meant to be called by the mapper framework.

Emits pathsChanged but NOT targetValueChanged.

schrodinger.ui.qt.standard.widgets.path_browse_controller.make_open_file_controller(*, parent: QWidget, display_type: DisplayType = DisplayType.Label, file_formats: Optional[list] = None, caption: str = 'Open File', initial_dir: Optional[str] = None, history_id: Optional[str] = None) PathBrowseController

Create a PathBrowseController wired to an open-file dialog.

Parameters:
  • parent – Parent widget. The button, display widget, dialog, and controller are all children of this widget.

  • display_type – Whether to use a QLineEdit (editable) or a read-only InfoTextLabel to display the selected path.

  • file_formats – File format strings accepted by filedialog.filter_string_from_formats. When None, all files are shown.

  • caption – Window title for the file dialog.

  • initial_dir – Starting directory. Defaults to the current working directory.

  • history_id – Identifier for directory memory across dialogs.

schrodinger.ui.qt.standard.widgets.path_browse_controller.make_open_multi_files_controller(*, parent: QWidget, display_type: DisplayType = DisplayType.Label, file_formats: Optional[list] = None, caption: str = 'Open Files', initial_dir: Optional[str] = None, history_id: Optional[str] = None) PathBrowseController

Create a PathBrowseController wired to a multi-file open dialog.

See make_open_file_controller for parameter descriptions.

schrodinger.ui.qt.standard.widgets.path_browse_controller.make_save_file_controller(*, parent: QWidget, display_type: DisplayType = DisplayType.Label, file_formats: Optional[list] = None, caption: str = 'Save File', initial_dir: Optional[str] = None, history_id: Optional[str] = None) PathBrowseController

Create a PathBrowseController wired to a save-file dialog.

See make_open_file_controller for parameter descriptions.

schrodinger.ui.qt.standard.widgets.path_browse_controller.make_directory_controller(*, parent: QWidget, display_type: DisplayType = DisplayType.Label, caption: str = 'Choose Directory', initial_dir: Optional[str] = None, history_id: Optional[str] = None) PathBrowseController

Create a PathBrowseController wired to a directory dialog.

See make_open_file_controller for parameter descriptions.