-
Notifications
You must be signed in to change notification settings - Fork 0
fontlab.flWorkspace
Adam Twardoch edited this page Aug 26, 2020
·
1 revision
This script adds signals to each main menu item that prints the object name and the mouse cursor position. It shows how you can attach signals to QActions.
from fontlab import *
from PythonQt.QtGui import *
ws = flWorkspace.instance()
main = ws.mainWindow
def menuActions(menu, actions = []):
for submenu in menu.findChildren(QMenu):
actions += menuActions(submenu)
return list(menu.findChildren(QAction))
def showMenuItem(qa):
if qa.statusTip:
s = u'%s %s\n' % (qa.statusTip, QtGui.QCursor().pos())
main.doOutput(s, True)
def signalAction(qa):
if qa.objectName:
qa.statusTip = u'@mainwindow.%s' % qa.objectName
qa.hovered.connect(lambda qa=qa: showMenuItem(qa))
def signalActions(main):
for qa in menuActions(main):
signalAction(qa)
signalActions(main)