Is it posibble to add an icon to my mouse cursor? I mean, how would i go
about showing an icon when I hover over a button that has a context menu as
Maya does with its own popupMenus (showing a little icon next to the mouse
cursor)? This way users can tell if there is a context menu attached to
some UI.


########################################################################################
########################################################################################

import sys
from PyQt4 import QtGui, QtCore

class MainForm(QtGui.QMainWindow):
    def __init__(self, parent=None):
        super(MainForm, self).__init__(parent)

        # create button
        self.button = QtGui.QPushButton("test button", self)
        self.button.resize(100, 30)

        # set button context menu policy
        self.button.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
        self.connect(self.button,
QtCore.SIGNAL('customContextMenuRequested(const QPoint&)'),
self.on_context_menu)

        # create context menu
        self.popMenu = QtGui.QMenu(self)
        self.popMenu.addAction(QtGui.QAction('test0', self))
        self.popMenu.addAction(QtGui.QAction('test1', self))
        self.popMenu.addSeparator()
        self.popMenu.addAction(QtGui.QAction('test2', self))

    def on_context_menu(self, point):
        # show context menu
        self.popMenu.exec_(self.button.mapToGlobal(point))

form = MainForm()
form.show()



########################################################################################
########################################################################################


I would like to add some visual cue to the button to show that it has a
context menu.

Cheers.

-- 
You received this message because you are subscribed to the Google Groups 
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to