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

Cursor image control #595

Closed
hmaarrfk opened this issue Sep 20, 2024 · 10 comments
Closed

Cursor image control #595

hmaarrfk opened this issue Sep 20, 2024 · 10 comments

Comments

@hmaarrfk
Copy link
Contributor

I was removing some Qt-only code from our codebase and trying to replace it with wgpu/pygfx equivalents (for unifying Qt/JupyterRFB stuff) and I couldn't find a good replacement for setCursor

from qtpy.QtCore import Qt
canvas.setCursor(Qt.SizeBDiagCursor)

https://doc.qt.io/qt-6/qwidget.html#cursor-prop

thougths? ideas? maybe i'm missing something? I tried to search for "cursor" here but couldn't find anything.

@Korijn
Copy link
Collaborator

Korijn commented Sep 20, 2024

There's no good way to abstract over such GUI differences. At this point it's just too specific. For the web you need to use CSS and HTML whereas for Qt you have the right method there. Just use those.

@hmaarrfk
Copy link
Contributor Author

got it, that makes sense that certain things are likely too hard.

Could PyGFX just take over the look the of the cursor when you are hovering over the canvas?

@hmaarrfk
Copy link
Contributor Author

I guess it would be up to my application have:

  1. Front end dependent code to hide the cursor using Qt/CSS/HTML
  2. PyGFX Scene cursor.

@hmaarrfk
Copy link
Contributor Author

Honestly, the interaction I had setup for it was likely weak and buggy anyway.

Touch interfaces don't have cursors, so it doesn't work for that.

Thanks for helping me brainstorm!!! (and the awesome stuff!)

@Korijn
Copy link
Collaborator

Korijn commented Sep 20, 2024

You have a cursor within pygfx? That's pretty cool.

@hmaarrfk
Copy link
Contributor Author

You have a cursor within pygfx

not yet but i could...

@kushalkolar
Copy link
Contributor

Nice! I'm working on a crosshair tool but I could actually just add this to pygfx instead 🤔 . The idea is just a group of lines that share a buffer that can be added to multiple scenes, when added to a scene it creates the line world objects using the shared buffer.

some cursor stuff from jupyter_rfb

@hmaarrfk
Copy link
Contributor Author

wow pretty cool!

@almarklein
Copy link
Member

almarklein commented Sep 24, 2024

There's no good way to abstract over such GUI differences. At this point it's just too specific. For the web you need to use CSS and HTML whereas for Qt you have the right method there. Just use those.

That was my first impression as well. But a canvas that sits in the browser can abstract the html/css stuff, like jupyter_rfb does. I did a quick search and it looks like all our current backends support setting the cursor ...

@kushalkolar
Copy link
Contributor

kushalkolar commented Oct 18, 2024

If anyone's interested I decided to add our cursor tool to fpl itself, it quickly got pretty tedious trying to do it directly in pygfx, this is a bit more than a simple cursor since it can be added to multiple graphics and maps the same position across graphics (so it needs to keep track of a world object's viewport and scene which is managed in fpl.PlotArea that makes it easier)
https://github.com/fastplotlib/fastplotlib/blob/7836c5d229ad8014a2a63f4da11df9964e2f1d6a/fastplotlib/tools/_cursor.py

WIP PR: fastplotlib/fastplotlib#662

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

4 participants