python3 is not supporting gtk module
17,426
Solution 1
try:
from gi.repository import Gtk
and replace gtk
by Gtk
in your code
or
from gi.repository import Gtk as gtk
see also : Python GTK+ 3 Tutorial : Getting Started
Solution 2
Use the GObject introspection based Python3 bindings for Gtk and friends:
from gi.repository import Gtk, GObject
That needs the package python3-gi
which is installed by default.
Some names have changed since PyGTK. The Python GObject Introspection API Reference should help you to find the new names (and other changes).
Related videos on Youtube
Author by
mrudula
Updated on September 18, 2022Comments
-
mrudula about 1 year
I have Ubuntu 14.04 with python-2.7 and python-3 support. I am porting my python application from python-2.7 to python-3. I have
example.py
file which is importing below modules. and I#!/usr/bin/python3
as python evn variable.import gtk, gobject, time, sys, os, subprocess, signal **ImportError: No module named 'gtk'**
I am getting above error, when trying to run with python3.
Any idea what is missing here?
-
mrudula almost 8 yearsThank you for suggestion. I am not able to import many modules which been supported for 2.7 like gtk, gobject, time, sys, os, subprocess, signal. please share any document which has details and helpful for porting py-2 to py-3.
-
Luis A. Florit over 3 yearsI get an error:
AttributeError: 'gi.repository.Gtk' object has no attribute 'combo_box_new_text'
-
Luis A. Florit over 3 years...and many many more errors.