On Mon, Dec 13, 2010 at 9:58 PM, Ivanov Dmitriy <[email protected]> wrote:

> Can you tell me, how to create a button on the top panel inside a
> plugin and attach a code to it?

Take a look at makeButtons function in nav_qt.py

If you don't want icons but text, instead of:

 QtGui.QAction(icon_l, 'prev', ib_w)

do:

QtGui.QAction('prev', ib_w)

I'm pasting the whole function here for reference

    def makeButtons(self):
        ib_w = self.c.frame.iconBar.w
        if not ib_w: return # EKR: can be None when unit testing.
        icon_l = ib_w.style().standardIcon(QtGui.QStyle.SP_ArrowLeft)
        icon_r = ib_w.style().standardIcon(QtGui.QStyle.SP_ArrowRight)
        act_l = QtGui.QAction(icon_l, 'prev', ib_w)
        act_r = QtGui.QAction(icon_r, 'next', ib_w)
        act_l.connect(act_l, QtCore.SIGNAL("triggered()"), self.clickPrev)
        act_r.connect(act_r, QtCore.SIGNAL("triggered()"), self.clickNext)
        self.c.frame.iconBar.add(qaction = act_l, command = self.clickPrev)
        self.c.frame.iconBar.add(qaction = act_r, command = self.clickNext)

self.clickPrev and clickNext are the function that are run, e.g:

    def clickPrev(self):
        c = self.c
        p = c.goPrevVisitedNode()


-- 
Ville M. Vainio @@ Forum Nokia

-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/leo-editor?hl=en.

Reply via email to