On Tue, 18 May 2010 09:22:08 -0500
Terry Brown <[email protected]> wrote:
> > Right click on a @button icon on the toolbar and choose to go to
> > the @button node with the code.
>
> Hmm, having just been playing around with code in that area while fixing
> qt_nav I thought I'd look at that, but it seems more complicated than I
> expected.
I've pushed at 3090 code which implements this. I changed to closure to a
callable class that behaves the same way, and decided to ignore my not
understanding why a position is sufficiently durable in this case, as obviously
it is.
Edward might want to decide if this change is too radical. It seems to still
work find in tk, I was going to run unit tests, but unitTest.leo says:
Running unit tests from test.leo is easy, provided you have enabled the
Scripting plugin. When this plugin is enabled Leo will create a blue 'script
button' in the icon bar called 'unit test'.
- To run all unit tests, select the node in test.leo called 'Unit tests...',
then do <alt-4>
but test.leo doesn't contain a node called 'Unit tests...', so I didn't.
Cheers -Terry
=== modified file 'leo/plugins/mod_scripting.py'
--- leo/plugins/mod_scripting.py 2010-01-17 22:29:23 +0000
+++ leo/plugins/mod_scripting.py 2010-05-18 17:26:28 +0000
@@ -674,11 +674,22 @@
# Now that b is defined we can define the callback.
# Yes, executeScriptFromButton *does* use b (to delete b if requested
by the script).
- def atButtonCallback
(event=None,self=self,p=p.copy(),b=b,c=c,buttonText=buttonText):
- self.executeScriptFromButton (p,b,buttonText)
- if c.exists: c.outerUpdate()
-
- self.iconBar.setCommandForButton(b,atButtonCallback)
+ # 20100518 - TNB replace callback function with callable class instance
+ # so qt gui can add 'Goto Script' command to context menu for button
+ class atButtonCallback(object):
+ def __init__(self,controller,p,b,c,buttonText):
+ self.controller = controller
+ self.p = p
+ self.b = b
+ self.c = c
+ self.buttonText = buttonText
+
+ def __call__(self, event=None):
+
self.controller.executeScriptFromButton(self.p,self.b,self.buttonText)
+ if self.c.exists: self.c.outerUpdate()
+
+ cb =
atButtonCallback(controller=self,p=p.copy(),b=b,c=c,buttonText=buttonText)
+ self.iconBar.setCommandForButton(b,cb)
=== modified file 'leo/plugins/qtGui.py'
--- leo/plugins/qtGui.py 2010-05-07 20:30:30 +0000
+++ leo/plugins/qtGui.py 2010-05-18 17:26:28 +0000
@@ -4030,6 +4030,16 @@
# button is a leoIconBarButton.
QtCore.QObject.connect(button.button,
QtCore.SIGNAL("clicked()"),command)
+
+ # 20100518 - TNB command is instance of callable class with
+ # a c and p attribute, so we can add a context menu item...
+ def goto_command(command = command):
+ command.c.selectPosition(command.p)
+ command.c.redraw()
+ b = button.button
+ b.goto_script = rb = QtGui.QAction('Goto Script' ,b)
+ b.addAction(rb)
+ rb.connect(rb, QtCore.SIGNAL("triggered()"), goto_command)
#...@-node:ekr.20081121105001.274:setCommandForButton
#...@-others
#...@-node:ekr.20081121105001.266:class qtIconBarClass
--
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.