Two options:
Use functools.partial to wrap each slot:
###
from functools import partial
...
for btn in buttons:
cbk = partial(self.mymenu, btn)
btn.customContextMenuRequested.connect(cbk)
...
def mymenu(self, btn, point):
...
###
Or check the sender of the signal in the slot:
###
def mymenu(self, point):
btn = self.sender()
###
On Thursday, December 6, 2012, Rishis3D wrote:
> [image: More message actions]
> 17:35 (less than a minute ago)
> Other recipients:
> ok.. i got my all buttons from findChildren() function
> now iter all buttons to add setContextMenuPolicy and
> customcontextMenuRequested like this
>
> for btn in button:
>
> btn.**setContextMenuPolicy(Qt.**CustomContextMenu)
> btn.**customContextMenuRequested.**connect(self.mymenu)
> menu = QtGui.QMenu()
> menu.addAction('key')
>
>
> def mymenu(self, point):
> self.menu.exec_(*btn***.ma**pToGlobal(point))
>
> customContextMenuRequested only give QPoint Information for Popup Position
>
> becoz mymenu function required btn information also..
> how do i get that button information to set my button in this line
> self.menu.exec_(*btn***.ma**pToGlobal(point))
>
> thanks
>
>
>
> --
> view archives: http://groups.google.com/group/python_inside_maya
> change your subscription settings:
> http://groups.google.com/group/python_inside_maya/subscribe
>
--
view archives: http://groups.google.com/group/python_inside_maya
change your subscription settings:
http://groups.google.com/group/python_inside_maya/subscribe