Re: adding external tools

241 views
Skip to first unread message

anatoly techtonik

unread,
Jul 16, 2012, 4:45:56 PM7/16/12
to spyd...@googlegroups.com
On Friday, July 13, 2012 10:41:12 PM UTC+3, nicolas wrote:
Hi everydoby.
I'm using Spyder for few weeks for small Python programs.
I want to know if it's possible (ans then how) to add new shortcut in the Tools/External tools menu.
There is only Python(x,y) (not active) and QtDesigner (active) on this menu, and I would like to add, for example QtLinguist.

Starting from 2.2.x in Internal Console:

>>> CMD = 'df'
>>> from spyderlib.utils.qthelpers import create_action
>>> from spyderlib.utils import programs
>>> from spyderlib.config import get_icon
>>> from spyderlib.utils.qthelpers import add_actions
>>> action = create_action(spy.window, "Launch '%s'" % CMD, icon=get_icon('advanced.png'), triggered=lambda: programs.start_file(programs.find_program(CMD)))
>>> add_actions(spy.window.external_tools_menu, [action])

On Linux this will add menu entry to run 'df' command, which (in my case) is seen in console that I started Spyder from. You can place this code into Spyder plugin http://code.google.com/p/spyderlib/wiki/SpyderPlugins to be executed on load.

BTW, I can see that QtLinguist autodetection is in the source, so you should have QtLinguist in the menu if `linguist` or `linguist-qt4` executables are installed correctly.

nicolas

unread,
Jul 17, 2012, 5:35:50 AM7/17/12
to spyd...@googlegroups.com
Hi.
Thanks for your reply.

If I run in command line 'linguist-qt4', Qt Linguist (version 4.8.2) starts and runs perfectly.

I try to install Spyder from source (version 2.1.10, last one was 2.1.6), and still no link to QtLinguist in external tools.

I try your different commands, but I have a mistake with the line :
action = create_action(spy.window, ...

I then obtain the following message :
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'spy' is not defined

Any idea ?
I run Spyder on Fedora 17 64 bits.

Regards,
Nicolas

nicolas

unread,
Jul 17, 2012, 5:37:06 AM7/17/12
to spyd...@googlegroups.com

anatoly techtonik

unread,
Jul 17, 2012, 6:25:27 AM7/17/12
to spyd...@googlegroups.com
You need version 2.2.x for internal console to work, which is not released yet.
http://code.google.com/p/spyderlib/wiki/NoteForBetaTesters

For 2.1.x the only way is to write a plugin.
http://code.google.com/p/spyderlib/wiki/SpyderPlugins
Yes, the doc need improvements. Comments and patches are welcome.

I see that detection code in 2.2.x and in 2.1.x is the same, so if there is no
entry in 2.2.x try to see what is going on in internal console:

from spyderlib.utils.qthelpers import create_program_action
for name in ("linguist-qt4", "linguist"):
print create_program_action(self, _("Qt Linguist"),
'qtlinguist.png', "linguist")

You may need to modify spyderlib.utils.qthelpers.create_program_action
and restart Spyder to debug the issue.
> --
> You received this message because you are subscribed to the Google Groups
> "spyder" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/spyderlib/-/OVISe5fM0FoJ.
>
> To post to this group, send email to spyd...@googlegroups.com.
> To unsubscribe from this group, send email to
> spyderlib+...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/spyderlib?hl=en.
Reply all
Reply to author
Forward
0 new messages