Sunday, May 5, 2024
 Popular · Latest · Hot · Upcoming
2
rated 0 times [  2] [ 0]  / answers: 1 / hits: 2217  / 2 Years ago, mon, april 25, 2022, 7:10:32

I'm using Ubuntu 12.04 with python 2.7.3 and PyGObject and I'd like to develop plugins for Gedit in python. I found a simple looking tutorial for this sort of thing here.



According to the tutorial, I need the Gedit module to interact with the plugin interface:



from gi.repository import GObject, Gedit


I keep getting an import error when trying to import the Gedit module. So, my question is: what package do I need to install to get this module?



I've tried: gedit-dev , gedit-plugins



Edit: Here is the full traceback for the above statement:



ERROR:root:Could not find any typelib for Gedit
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: cannot import name Gedit

More From » python

 Answers
3

To answer your question, the typelib you need for developing gedit plugins is contained in the gedit package itself.



$ apt-file search Gedit-3.0.typelib
gedit: /usr/lib/gedit/girepository-1.0/Gedit-3.0.typelib


But when using python either interactively or from a script, from gi.repository import Gedit searches /usr/lib/girepository-1.0/ rather than /usr/lib/gedit/girepository-1.0. That is the cause of the import error.



You'll need to create the appropriate .plugin and .py files in ~/.local/share/gedit/plugins and run your code by selecting the plugin in the gedit preferences dialog.


[#35684] Tuesday, April 26, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
eballxeye

Total Points: 370
Total Questions: 91
Total Answers: 139

Location: Suriname
Member since Sat, Jan 1, 2022
2 Years ago
;