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

Wrong signature for snake_case methods of DirectGui objects #7

Open
Augustifolia opened this issue Aug 4, 2023 · 4 comments
Open

Comments

@Augustifolia
Copy link

Hi! I've been using this project for a few months now, and it has been very helpfull. Thank you!

There seems to be an issue when calling some snake_case aliasses of DirectGui objects. Specifically when the gui-object is passed to a function. It seems to choose the wrong signature of the function. I am using version 0.3.3 of types-panda3d and Pycharm as IDE. I hope the example below illustrates the issue.

class GuiTest(ShowBase):
    def __init__(self):
        super().__init__()
        button = DirectGui.DirectButton(
            text="test"
        )

        # works as it should
        button.set_pos(0.1, 0.1, 0.1)
        button.reparent_to(base.render)

        self.button_test(button)

    def button_test(self, button: DirectGui.DirectButton):
        # complains about the arguments

        button.set_pos(0.1, 0.1, 0.1)
        # expects:
        # def set_pos(self,
        #             const_NodePath_self: Any,
        #             const_LVecBase3f_pos: Any) -> None
        # instead of def set_pos(self, pos: Vec3Like) -> None:

        button.reparent_to(base.render)
        # expects:
        # def reparent_to(self,
        #                 const_NodePath_self: Any,
        #                 const_NodePath_other: Any,
        #                 int_sort: Any,
        #                 Thread_current_thread: Any) -> None


        # works as it should
        button.setPos(0.1, 0.1, 0.1)
        button.reparentTo(base.aspect2dp)
@WMOkiishi
Copy link
Owner

I'll have to do some more investigation, but this appears to be primarily an issue with PyCharm's code analysis.

@Augustifolia
Copy link
Author

Alright, thank you for the help!

@WMOkiishi
Copy link
Owner

Bizarrely, this appears to be resolved if DirectButton is imported from direct.gui.DirectButton instead.

@Augustifolia
Copy link
Author

That is rather strange. It would also be a reasonable workaround if the issue can not be resolved.

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