Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
superzazu opened this issue Jun 14, 2016 · 1 comment
Open

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

superzazu opened this issue Jun 14, 2016 · 1 comment

Comments

@superzazu
Copy link
Contributor

superzazu commented Jun 14, 2016

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
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants