View Single Post
Old 02-02-2014, 06:15 PM   #1
kabirmaar
Member
kabirmaar began at the beginning.
 
Posts: 15
Karma: 10
Join Date: Feb 2014
Device: none
reference to the plugin's toolbar button

i would like to make plugin with drop-down menu (self.popup_type = QToolButton.InstantPopup) and instead of textual (q)action i would like to add custom QWidget.

i have separated code which looks like this:
Code:
class Window(QtGui.QWidget):
    def __init__(self):
        QtGui.QWidget.__init__(self)
        layout = QtGui.QHBoxLayout(self)
        self.button = QtGui.QToolButton(self)
        self.button.setPopupMode(QtGui.QToolButton.InstantPopup)
        self.button.setMenu(QtGui.QMenu(self.button))
        self.textBox = QtGui.QTextBrowser(self)
        action = QtGui.QWidgetAction(self.button)
        action.setDefaultWidget(self.textBox)
        self.button.menu().addAction(action)
        layout.addWidget(self.button)

if __name__ == '__main__':

    import sys
    app = QtGui.QApplication(sys.argv)
    window = Window()
    window.resize(100, 60)
    window.show()
    sys.exit(app.exec_())
i can't find the reference to plugin's toolbar button in calibre which i would use as equivalent to self.button (as above).

in calibre plugin development i tried things like: self.qaction.parentWidget() and few others (but rather would avoid showing it )

no luck.

any idea how to do that?
kabirmaar is offline   Reply With Quote