How should I make gedit execute python?

I try do this but dont succes
or i can make a shortcut to run in a external console?
just something simple

this not work for me

I assume you are familiar with python and at a minimum can read instructions and debug if needed.

https://help.gnome.org/users/gedit/stable/gedit-plugin-guide.html.en#gedit-default-plugins
https://wiki.gnome.org/Apps/Gedit/PythonPluginHowTo

5 Likes

thxs but that was very complicated for me, so I use now jupyter with colab to my learning process

I never done a gedit plugin but seems somehow simple as long as you read the instructions, all is explained on the link above with file content examples, the files you need to create etc.

if you find it very complicated maybe learn with something more simple, I would just use a text editor instead of colab, colab runs in the browser and you won’t have gobject library’s there.

You also need to install python-gobject might not come by default.

You need 3 files:
youpluginname.plugin - This tells gedit how to read your plugin.
yourplugin.desktop - this is the exec desktop file that tell the plugin file were your program is.
yourplugin.py - this is actually your python plugin.

2 Likes

so its posible create a button in gedit to execute? (sorry broken english)

I find how to create a shortcut to execute python in gedit:

Steps to add your custom shortcut key and functionality in GEdit:

  1. Open the Manage External Tools.

  2. Add a tool

  3. Give the tool a name.

  4. Enter this code:

#!/bin/sh
python $GEDIT_CURRENT_DOCUMENT_PATH

For each external tool, you can specify whether the current document (or all documents) should be saved before the tool runs. To do this:

In gedit, choose Tools->Manage External Tools…
Choose a tool on the left.
Next to Save:, choose Current Document if you’d like the current document to be saved before the tool runs.

nice

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.