Source code for diplomat.wx_gui.settings_dialog

"""
Provides a dialog for displaying an arbitrary set of configurable settings to the user to be changed. Utilizes
the :class:`~diplomat.wx_gui.labeler_lib.SettingWidget` API for specifying dialog settings and retrieving results.
"""
from typing import Any, Callable, List, Optional
import wx
from diplomat.processing import Config
from diplomat.wx_gui.labeler_lib import SettingWidget, SettingCollection, SettingCollectionWidget
import platform






[docs] class SettingsDialog(wx.Dialog): """ A dialog of settings. Allows displaying a :class:`~diplomat.wx_gui.labeler_lib.SettingCollection` to a user in a dialog. """
[docs] def __init__(self, *args, title: str = "Settings", settings: SettingCollection, **kwargs): """ Create a new dialog. :param title: The title of the dialog. :param settings: The settings to display. Additional positional and keyword arguments are passed directly to :class:`wx.Dialog` constructor. """ super().__init__(*args, title=title, style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER, **kwargs) self._parent_layout = wx.BoxSizer(wx.VERTICAL) self._settings = settings self._setting_widget = SettingCollectionWidget(self, title=title, collapsable=False) self._setting_widget.set_setting_collection(settings) self._parent_layout.Add(self._setting_widget, proportion=1, flag=wx.EXPAND | wx.ALL) self._buttons = self.CreateButtonSizer(wx.OK | wx.CANCEL) self._parent_layout.Add(self._buttons, proportion=0, flag=wx.EXPAND | wx.ALL) self.SetSizerAndFit(self._parent_layout)
[docs] def get_values(self) -> Config: """ Get the values selected by the user in the settings dialog. :return: A :class:`~diplomat.processing.containers.Config` object, containing the values selected by the user. """ return self._settings.get_values()