Hi
I'm trying to create a tool that when the user graphically inputs points the cursor changes to a haircross shape so...if I try in FreeCAD's python console:
from PySide import QtCore, QtGui
QtGui.QApplication.setOverrideCursor(QtGui.QCursor(QtCore.Qt.CrossCursor))
on:
OS: Windows XP
Platform: 32-bit
Version: 0.14.3389
Python version: 2.6.2
Qt version: 4.5.2
Coin version: 3.1.0
SoQt version: 1.4.1
OCC version: 6.5.1
I get a nice haircross cursor shape... but if I try
on;
OS: Ubuntu 13.10
Platform: 32-bit
Version: 0.14.3559 (Git)
Branch: master
Hash: 1fffc978b4c2873da5826c1de12207f3b292c4cf
Python version: 2.7.5+
Qt version: 4.8.4
Coin version: 4.0.0a
SoQt version: 1.5.0
OCC version: 6.7.0
I get nothing.
What do you think could be wrong?
I want it to work both on Windows and Ubuntu (Lubuntu actually) because I use both OS's depending on where I am working.
Should I not use PySide for this?
Really apreciated your inputs
Vitor T
Changing cursor shape to haircross
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
Re: Changing cursor shape to haircross
Hard to say. Does any other cursor type like WaitCursor, ForbiddenCursor, BusyCursor, ... work?What do you think could be wrong?
This has nothing to do with PySide. It's just a Python wrapper and the actual stuff happens inside Qt.Should I not use PySide for this?
Re: Changing cursor shape to haircross
Hi wmayerHard to say. Does any other cursor type like WaitCursor, ForbiddenCursor, BusyCursor, ... work?
I've tried all but none work.
I've tried something stupid say "StupidCursor" and python says:
' Traceback (most recent call last):
File "<input>", line 1, in <module>
AttributeError: type object 'PySide.QtCore.Qt' has no attribute 'StupidCursor'
If I change "from PySide import ..." to "from PyQt4 import ..." they all work except, obviously, the "StupidCursor" that gives:
' Traceback (most recent call last):
File "<input>", line 1, in <module>
AttributeError: type object 'Qt' has no attribute 'StupidCursor'
I'm not familiar with wrappers and how they work I'm just trying the FreeCAD API so I can't help much here except experimenting and share results.
For now I'll stick to PyQt4.
I'll keep trying PySide in the next releases and see if it works.
Vitor T
Re: Changing cursor shape to haircross
Oh, interesting. Then maybe there is indeed something wrong with PySide.
What does this give you?
The expected value must be 2.
If this is not 2 (then it's of course a bug in Pyside) and you could try this:
What does this give you?
Code: Select all
from PySide import QtCore, QtGui
int(QtCore.Qt.CrossCursor)
If this is not 2 (then it's of course a bug in Pyside) and you could try this:
Code: Select all
from PySide import QtCore, QtGui
QtGui.QApplication.setOverrideCursor(QtGui.QCursor(QtCore.Qt.CursorShape(2)))
Re: Changing cursor shape to haircross
Hello wmayer
Using the same code with PyQt4, then I get the the cross cursor.
Hope this helps.
Using the Draft module toolbar (line, DraftWire, circle, etc,...) the Cross Cursor shows up and that's the kind of thing I'm after. I haven't figured out how Yorik did it (node, child ??).
Cheers
Vitor T
Well this gives me 2 as you say.What does this give you?Code: Select all
from PySide import QtCore, QtGui int(QtCore.Qt.CrossCursor)
This gives me nothing, no error message, nothing. The cursor remains arrow, just like previously with 'QtCore.Qt.CrossCursor' .If this is not 2 (then it's of course a bug in Pyside) and you could try this:Code: Select all
from PySide import QtCore, QtGui QtGui.QApplication.setOverrideCursor(QtGui.QCursor(QtCore.Qt.CursorShape(2)))
Using the same code with PyQt4, then I get the the cross cursor.
Hope this helps.
Using the Draft module toolbar (line, DraftWire, circle, etc,...) the Cross Cursor shows up and that's the kind of thing I'm after. I haven't figured out how Yorik did it (node, child ??).
Cheers
Vitor T
Re: Changing cursor shape to haircross
Look in DraftSnap.py, at the setCursor() function... But I use a custom image there, not the default Qt cross, maybe that's the problem.vitort wrote:Using the Draft module toolbar (line, DraftWire, circle, etc,...) the Cross Cursor shows up and that's the kind of thing I'm after. I haven't figured out how Yorik did it (node, child ??).
Re: Changing cursor shape to haircross
I'll look in DraftSnap.py and see if I can reproduce somehow in my script.
Thanks Yorik and Wmayer
Thanks Yorik and Wmayer