Nuitka: DearPyGUI callback raises number arguments error

Python code using dearpygui that works in the interpreter, is raising a num arguments error for the Nuitka compiled version. Tested on Windows and Ubuntu with Python 3.9 and 3.10 with the same results - implying the issue is not related to Python version, c compiler, or OS.

I tried two versions of Nuitka, 0.7.7 and 0.8rc9,

$ python -m nuitka --version
0.7.7
Commercial: None
Python: 3.10.4 (main, Mar 31 2022, 08:41:55) [GCC 7.5.0]
Flavor: Anaconda Python
Executable: /home/martin/miniconda3/envs/dearpygui/bin/python
OS: Linux
Arch: x86_64
Distribution: Ubuntu (based on Debian) 20.04.4

$ python -m nuitka --version
0.8rc9
Commercial: None
Python: 3.10.4 (main, Mar 31 2022, 08:41:55) [GCC 7.5.0]
Flavor: Anaconda Python
Executable: /home/martin/miniconda3/envs/dearpygui/bin/python
OS: Linux
Arch: x86_64
Distribution: Ubuntu (based on Debian) 20.04.4

pip was used to install Nuitka.

dearpygui version is 1.5.1. Install: pip install dearpygui. dearpygui

Reproducible snippet,

import dearpygui.dearpygui as dpg

dpg.create_context()
dpg.create_viewport(height=200, width=200)
dpg.setup_dearpygui()

# works
def cb_button1(sender, app_data, user_data):
    print(f"sender: {sender} {app_data} {user_data}")


class myClass(object):

    def __init__(self):
        pass

    # throws num arguments error
    def cb_button2(self, sender, app_data, user_data):
        print(f"sender: {sender} {app_data} {user_data}")


myclass = myClass()

with dpg.window(label="Example", height=100, width=100):
    dpg.add_text("Hello world")
    dpg.add_button(tag="b1", label="Button1", callback=cb_button1)  
    dpg.add_button(tag="b2", label="Button2", callback=myclass.cb_button2)  


dpg.show_viewport()
dpg.start_dearpygui()
dpg.destroy_context()

Output of program,

$ ./nuitka_01.bin
sender: b1 None None
TypeError: myClass.cb_button2() takes 4 positional arguments but 5 were given
  • Provide in your issue the Nuitka options used
python -m nuitka --standalone --onefile nuitka_01.py

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Comments: 18 (11 by maintainers)

Most upvoted comments

Seems the fix got reverted, but I don’t know why now. Very sad. Offered my help in the mentioned issue of PyDearGUI.

The fix for this is in DPG, nothing Nuitka itself can do about it.

Well, or you could add a fake self argument to eat up the self they provide, but I understand there is an upstream patch in the works. Thanks for this, helps me a lot. I wouldn’t have the time to do it, glad you are taking it on.