joaoventura / pylibui

Pylibui is a Python 3 wrapper for the libui library.
MIT License
224 stars 24 forks source link

use of properties instead of setters/getters in wrapper #10

Open superzazu opened 8 years ago

superzazu commented 8 years ago

Hello,

As the pylibui wrapper is supposed to be pythonic, I thought it would be great to use the properties instead of defining setValue/getValue-like methods.

Here is a little implementation example for checkboxes checked attribute:

    @property
    def checked(self):
        """
        Returns whether the checkbox is checked or not.

        :return: bool
        """
        return libui.uiCheckboxChecked(self.control)

    @checked.setter
    def checked(self, checked):
        """
        Sets whether the checkbox is checked or not.

        :param checked: bool
        :return: None
        """
        libui.uiCheckboxSetChecked(self.control, checked)

That way, that would allow us to do things like:

if my_checkbox.checked:
    my_checkbox.checked = False

instead of...

if my_checkbox.getChecked():
    my_checkbox.setChecked(False)

What do you think ? Should I make a PR for this ?

Have a good day, Nicolas.

joaoventura commented 8 years ago

I think it's a good idea, but we should let it mature a little bit until we implement more things in pylibui. My rationale is that somewhere in the future we may have to decide which functions are worth wrapping as properties and which functions not and until then we won't be sure which things are common on the api.

For now, let's keep this issue open, but it's more important to continue implementing the libui ctypes wrapping functions so that we can match libui's functionality.