Wednesday, 15 June 2011

python - Two key shortcuts -



python - Two key shortcuts -

i trying set two-key shortcuts without modifiers in pyside/pyqt4.

i have tried various combinations of qevents , qkeysequences, no avail.

what this:

def keypressevent(self, event): if (event.key() == qtcore.qt.key_o) , (event.key() == qtcore.qt.key_p ): print('shortcut op accepted')

or

filemenu.addaction(qtgui.qaction("open project", self, shortcut=qtgui.qkeysequence("p" , "o"),triggered=self.openproject))

where users presses, o, p , action occurs.

does know firstly if possible , if how it?

for me "o, p" arguments qkeysequence job.

example:

from pyside import qtgui def beep(): print('beep') app = qtgui.qapplication([]) toolbar = qtgui.qtoolbar() toolbar.show() action = qtgui.qaction("action", toolbar, shortcut=qtgui.qkeysequence("o, p"), triggered=beep) toolbar.addaction(action) app.exec_()

python pyqt4 pyside

No comments:

Post a Comment