NodeGraphQt icon indicating copy to clipboard operation
NodeGraphQt copied to clipboard

Decimal point shoud be specified in QLocale

Open FooDawn opened this issue 2 years ago • 2 comments

A lot of countries use decimal comma (0,1), and not decimal point (0.1).

I am using PySide2. Qt sets QLocale object initialized to the system locale. On Windows and Mac, this locale will use the decimal/grouping characters and date/time formats specified in the system configuration panel. So in _NumberValueMenu in NodeGraphQt/custom_widgets/properties_bin/custom_widget_value_edit.py _convert_text would have problems.

For me specifying it in the beginning help solve this problems

    def set_locale(self):
        """ Due to different locale (decimal point is ,) in some countries
            So for decimal point being . for all users it must be Specified here the beginning
        """
        want_locale = QtCore.QLocale(QtCore.QLocale.English, QtCore.QLocale.Europe)
        QtCore.QLocale.setDefault(want_locale)
        print('Now my locale decimal point is:', QtCore.QLocale().decimalPoint())

FooDawn avatar Aug 20 '23 13:08 FooDawn

Hi @FooDawn, I've just made a new release does this work out for you? https://github.com/jchanvfx/NodeGraphQt/releases/tag/v0.6.23

jchanvfx avatar Sep 13 '23 11:09 jchanvfx

Hello @jchanvfx I just saw this and I saw that you did regex splinting. I tested the newest while it works in Vector2 (while it works for integers, since somehow you cannot write . or , in it). But if I try to open node with

self.create_property(self.threshold_id,
                             value=127,
                             widget_type=NodePropWidgetEnum.INT.value)

I get AttributeError: 'IntValueEdit' object has no attribute 'set_name' error and Property is not show in Propery Bin. similar with FLOAT.

From what I seen in code and you added get_name() and set_name() functions in classes PropComboBox, PropTextEdit, PropLineEdit, PropLabel, PropSpinBox, BaseProperty, but you missed _NumberValueEdit.

PS: I tried version 0.6.22 and in _NumberValueEdit signal value_changed is different then in BaseProperty in BaseProperty is value_changed = QtCore.Signal(str, object) and when it emits in PropFilePath for example it's self.value_changed.emit(self.get_name(), value)

but in _NumberValueEdit it's value_changed = QtCore.Signal(object) and when it emits it's self.value_changed.emit(self.get_value()) and when changing value in Properies Bin you get following error TypeError: _on_property_changed() missing 1 required positional argument: 'value'

FooDawn avatar Feb 13 '24 20:02 FooDawn