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

WxWgpuWindow object has no attribute 'add_event_handler' #485

Open
cansik opened this issue Mar 28, 2024 · 4 comments
Open

WxWgpuWindow object has no attribute 'add_event_handler' #485

cansik opened this issue Mar 28, 2024 · 4 comments

Comments

@cansik
Copy link
Contributor

cansik commented Mar 28, 2024

At least on MacOS, it seems that the WxWgpuWindow integration seems not to work. The example found here can not be run because of the following issue:

Traceback (most recent call last):
  File "/pyfx_image_viewer.py", line 11, in <module>
    canvas = WgpuCanvas()
  File "/venv/lib/python3.9/site-packages/wgpu/gui/wx.py", line 146, in __init__
    self._subwidget.add_event_handler(weakbind(self.handle_event), "*")
AttributeError: 'WxWgpuWindow' object has no attribute 'add_event_handler'

Versions:

  • pygfx 0.1.18
  • wgpu 0.15.0
  • wxpython 4.2.1
  • python 3.9.18
@Korijn
Copy link
Collaborator

Korijn commented Mar 28, 2024

Are you experienced with Wx? We're looking for maintainers for the wx backend.

@cansik
Copy link
Contributor Author

cansik commented Mar 28, 2024

It seems that the issue is related to the wgpu-py package. I am not even sure why this has been added (7dcd6ae), it seems to it has been added to wx and qt as well. Do you have more information about that line?

If this line is removed, there is another issue inside the timer start. At the moment 0 can be passed as wait time, even that is not an allowed value. Adding a max(1, ...) and converting to int solves this issue:

  def _request_draw(self):
      # Despite the FPS limiting the delayed call to refresh solves
      # that drawing only happens when the mouse is down, see pygfx/pygfx#209.
      if not self._request_draw_timer.IsRunning():
          self._request_draw_timer.Start(
              max(1, int(self._get_draw_wait_time() * 1000)), wx.TIMER_ONE_SHOT
          )

@Korijn I wouldn't call myself experienced, however, I would like to have pygfx support in wx.

@Korijn
Copy link
Collaborator

Korijn commented Mar 28, 2024

Indeed the gui backends are implemented in wgpu-py. You'd have to fix this there. I'll transfer the issue for you.

@Korijn Korijn transferred this issue from pygfx/pygfx Mar 28, 2024
cansik added a commit to cansik/wgpu-py that referenced this issue Mar 28, 2024
cansik added a commit to cansik/wgpu-py that referenced this issue Mar 28, 2024
@cansik
Copy link
Contributor Author

cansik commented Mar 28, 2024

@Korijn I have created a PR to fix this in wgpu and another one which updates the wx example in pygfx. Would be great if you could have a look.

Korijn pushed a commit that referenced this issue Mar 29, 2024
* fixed request draw timer wait time for wx backend #485

* removed inexistent add_event_handler call in wx backend #485

* added .idea to gitingore for pycharm developers

* removed unused weakbind import
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