Launches preferences dialog and returns dict with preferences

def get_preferences_from_user(self):
        """Launches preferences dialog and returns dict with preferences"""

        dlg = PreferencesDialog(self.main_window)

        change_choice = dlg.ShowModal()

        preferences = {}

        if change_choice == wx.ID_OK:
            for (parameter, _), ctrl in zip(dlg.parameters, dlg.textctrls):
                if isinstance(ctrl, wx.Choice):
                    value = ctrl.GetStringSelection()
                    if value:
                        preferences[parameter] = repr(value)
                else:
                    preferences[parameter] = repr(ctrl.Value)

        dlg.Destroy()

        return preferences