- fixed some issues in the convert_units

- added a new GUI element, a radio button that can change a setting in the self.defaults preferences dict
- made sure that the update of the default properties tab (in the Notebook) is done only for certain keys in self.defaults not for all
This commit is contained in:
Marius Stanciu
2021-08-25 02:31:44 +03:00
committed by Marius Stanciu
parent b6e669f1bc
commit 9ed8306c5f
4 changed files with 67 additions and 12 deletions

View File

@@ -109,6 +109,40 @@ class RadioSet(QtWidgets.QWidget):
option['radio'].setDisabled(val)
class RadioSetDefaults(RadioSet):
def __init__(self, choices, dictionary=None, key_spec=None, orientation='horizontal', stretch=None, parent=None):
"""
When a choice is made then the selected value is set in the key key_spec from the dictionary 'dictionary'
The choices are specified as a list of dictionaries containing:
* 'label': Shown in the UI
* 'value': The value returned is selected
:param choices: List of choices. See description.
:param orientation: 'horizontal' (default) of 'vertical'.
:param parent: Qt parent widget.
:type choices: list
:param dictionary:
:type dictionary: "dict"
:param key_spec:
:type key_spec: 'str'
"""
super(RadioSetDefaults, self).__init__(choices=choices, orientation=orientation, stretch=stretch, parent=parent)
self.dictionary = dictionary
self.key_spec = key_spec
def on_toggle(self, checked):
if checked:
self.group_toggle_fn()
ret_val = str(self.get_value())
if self.dictionary is not None and self.key_spec is not None:
self.dictionary[self.key_spec] = ret_val
self.activated_custom.emit(ret_val)
return
# class RadioGroupChoice(QtWidgets.QWidget):
# def __init__(self, label_1, label_2, to_check, hide_list, show_list, parent=None):
# """

View File

@@ -4,7 +4,7 @@ from PyQt6 import QtWidgets
from PyQt6.QtCore import QSettings
from appGUI.GUIElements import RadioSet, FCSpinner, FCCheckBox, FCComboBox, FCButton, OptionalInputSection, \
FCDoubleSpinner, FCLabel, FCGridLayout
FCDoubleSpinner, FCLabel, FCGridLayout, RadioSetDefaults
from appGUI.preferences.OptionsGroupUI import OptionsGroupUI
import gettext
@@ -35,8 +35,9 @@ class GeneralAppPrefGroupUI(OptionsGroupUI):
self.unitslabel.setToolTip(_("The default value for the application units.\n"
"Whatever is selected here is set every time\n"
"FlatCAM is started."))
self.units_radio = RadioSet([{'label': _('MM'), 'value': 'MM'},
{'label': _('IN'), 'value': 'IN'}])
self.units_radio = RadioSetDefaults(
choices=[{'label': _('MM'), 'value': 'MM'}, {'label': _('IN'), 'value': 'IN'}]
)
grid0.addWidget(self.unitslabel, 0, 0)
grid0.addWidget(self.units_radio, 0, 1)