<div dir="ltr">Hi Henning,<br><br>Thanks for your replies. (I&#39;m returning the conversation to the pyqt list as I like using old archives for looking for answers to my own questions. :-) )<br><br>First of all, let me describe what I am striving for. A while back I wrote an application called GemTcl that loads user interfaces built through the Glade Gui builder. GemTcl lets the user right click on all the buttons, which popups up a context menu which allows the user to edit the a callback script that is called when left clicking on the button.<br>
<br>And that&#39;s what I wanted to replicate in PyQt.<br><br>Regarding contextMenuPolicy, how would you use that. I tried the following, but it didn&#39;t work...<br><span style="font-family: courier new,monospace;">class MyApp(QtGui.QWidget):</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">    def clicked(self):</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">        print &quot;Processing left button&quot;</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">    def context_menu(self):</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">        print &quot;Processing context menu&quot;</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">    def __init__(self, parent=None):</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">        QtGui.QWidget.__init__(self, parent)</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">        self.setGeometry(300, 300, 250, 150)</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">        self.setWindowTitle(&#39;Icon&#39;)</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">        self.button = MyButton(self)</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">        self.button.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">        self.connect(self.button, QtCore.SIGNAL(&#39;clicked()&#39;), self.clicked)</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">        self.connect(self.button, QtCore.SIGNAL(&#39;customContextMenuRequested()&#39;), self.context_menu)</span><br style="font-family: courier new,monospace;"><br>Thanks,<br>
Dov<br><br><div class="gmail_quote">2009/7/30 Henning Schröder <span dir="ltr">&lt;<a href="mailto:henning.schroeder@gmail.com">henning.schroeder@gmail.com</a>&gt;</span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
I forgot to mention that every widget also has a<br>
customContextMenuRequested signal. This gets emitted if you set the<br>
contextMenuPolicy to Qt.CustomContextMenu.<br>
</blockquote></div><br><div style="display: none;" id="divCleekiAttrib"></div></div>