Reputation: 47
I am new to python and am trying to run a simple program I found on the web. I have installed the pyGTK All In One Download and cannot (after searching on the web for a month or so) find gtk.py anywhere.
It does not exist on my computer no matter how many times i run pygtk-all-in-one-2.24.2.win32-py2.7.msi Here is my code
import pygtk
pygtk.require('2.0')
import gtk
class Simple:
def destroy(self, widget, data=None):
gtk.main_quit()
def __init__(self):
win = gtk.Window(gtk.WINDOW_TOPLEVEL)
win.connect("destroy", self.destroy)
win.set_title("Simple")
win.set_position(gtk.WIN_POS_CENTER)
win.show_all()
Simple()
gtk.main()
I searched this forum and many others as well. If you have this file, could you post the code so I can copy it? If someone can help I would be very grateful. Thank You for listening. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! It seems that I have found the answer from the following link at http://www.slideshare.net/BaabtraMentoringPartner/importerror-dll-load-failed-is-not-a-valid-win32-application-python-mysql. I uninstalled the 64 bit version and installed the 32 bit version. When I run it from the command line the little window comes up! The error still shows up in Netbeans though so maybe the problem is in the Netbeans IDE?
Upvotes: 0
Views: 201
Reputation: 83
Uninstall your all-in-one and try with this other all-in-one:
https://sourceforge.net/projects/pygobjectwin32/files/
Then:
import gi
gi.require_version('Gtk', '2.0')
from gi.repository import Gtk
Upvotes: 0
Reputation: 47
I guess that using python(64bit ) for Windows 7 was the main problem. So I uninstalled the 64 bit version and installed the 32 bit version and it seems to work fine now. Thanks to everyone for your help. I would like to mark this question as answered but I don't exactly know how.
Upvotes: 0
Reputation: 721
If you have another gtk app (like GIMP) you may have problem with enviroment. Also, I hope that the indentation is broken only here, not in your script. And tell us what is the error.
Upvotes: 0
Reputation: 121944
The gtk
code is in
C:\Python27\Lib\site-packages\gtk-2.0
There is no single file named gtk.py
. (There is a _gtk.pyd
, which is like a dll).
However, you should generally not need to access the source code for the libraries you install. Python will handle that for you when you import gtk
, then you can just use those features within your script.
Upvotes: 2