Python GTK Tutorial Getting Started Task

I had a problem compiling a simple and simple example of using PyGTK on a pygtk site.

This is the first example from this site: http://www.pygtk.org/pygtk2tutorial/ch-GettingStarted.html

My code is as follows:

#!/usr/bin/env python # example gtk.py import pygtk pygtk.require('2.0') import gtk class Base: def __init__(self): self.window = gtk.Window(gtk.WINDOW_TOPLEVEL) self.window.show() def main(self): gtk.main() print __name__ if __name__ == "__main__": base = Base() base.main() 

And after calling python gtk.py, I get the following error:

GTK Main Traceback (last last call): File "gtk.py", line 19, in base = Base () File "gtk.py", line 11, in init self.window = gtk.Window (gtk.WINDOW_TOPLEVEL) AttributeError : the 'module' object does not have the 'Window' attribute

I found information somewhere that it can be fixed by installing PyGTK from the source. I did it, but didnโ€™t change anything. The message remains the same.

I am using ubuntu 10.10

Do you have any idea what might be wrong? Thanks for any help!

Mike

+4
source share
1 answer

Yes, it looks like you could call your script gtk.py ".

This is a bad idea for what should be reasonably obvious reasons!

+7
source

Source: https://habr.com/ru/post/1333256/


All Articles