[PyKDE] Passing argument in QPopupMenu.insertItem(QString, reveiver)
Randy Carnahan
rcarn at chartermi.net
Mon Mar 15 23:01:01 GMT 2004
On Monday 15 March 2004 16:53, Maciej Paszta wrote:
> Hi, I have a following problem. I create QPopupMenu and then I insert some
> item. All items should have the same receiver but passing him different
> arguments.
>
> chat = QPopupMenu(self)
> chat.insertItem('Open 1', self.open)
> chat.insertItem('Open 2', self.open)
> chat.insertItem('Open 3', self.open)
>
> def open(self, a0)
> .....
>
> So I want to pass for example 1, 2 or 3 to self.open according to which
> item was selected... Is there any way I can do it, or maybe some workaround
> is needed
I would write 3 "wrapper" functions that call self.open() with whatever
arguments you want to provide.
chat = QPopupMenu(self)
chat.insertItem('Open 1', self.openOne)
chat.insertItem('Open 2', self.openTwo)
chat.insertItem('Open 3', self.openThree)
class foo:
def openOne(self):
self.open(1)
def openTwo(self):
self.open(2)
def openThree(self):
self.open(3)
--
Randy Carnahan
Charter Communications
1-888-968-3442 Opt 3.
SW::POP Michigan Region
I am Geek. Hear me Code!
More information about the PyQt
mailing list