Results 1 to 4 of 4

Thread: Need help install PyGTK for use in Python

  1. #1
    Join Date
    May 2009
    Location
    Jacksonville, Florida
    Beans
    113
    Distro
    Ubuntu Development Release

    Need help install PyGTK for use in Python

    I can't seem to use pyGTK in any of the things I'm trying to program (I'm trying to set it up so I can use it for later), and I can't understand why. I've downloaded and installed all the dependencies here: http://www.pygtk.org/downloads.html and I've copied and pasted the code sample of
    PHP Code:
    import gtk
     
    def createWindow
    ():
        
    window gtk.Window()
        
    window.set_default_size(200200)
        
    window.connect('destroy'gtk.main_quit)
     
        
    label gtk.Label('Hello World')
        
    window.add(label)
     
        
    label.show()
        
    window.show()
     
    createWindow()
    gtk.main() 
    from the PyGTK page of Wikipedia. But whenever I try to run it, I get this error:
    Code:
    Traceback (most recent call last):
      File "gtk.py", line 2, in <module>
        import gtk
      File "/home/colin/gtk.py", line 15, in <module>
        createWindow()
      File "/home/colin/gtk.py", line 5, in createWindow
        window = gtk.Window()
    AttributeError: 'module' object has no attribute 'Window'
    What do I have to do to get it run?

  2. #2
    Join Date
    Aug 2007
    Location
    127.0.0.1
    Beans
    1,800
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: Need help install PyGTK for use in Python

    Your script file is named gtk.py, rename it to something else.
    "Just in terms of allocation of time resources, religion is not very efficient. There's a lot more I could be doing on a Sunday morning."
    -Bill Gates

  3. #3
    Join Date
    May 2009
    Location
    Jacksonville, Florida
    Beans
    113
    Distro
    Ubuntu Development Release

    Re: Need help install PyGTK for use in Python

    Quote Originally Posted by Can+~ View Post
    Your script file is named gtk.py, rename it to something else.
    Did that, and it still didn't work. I changed import gtk to import pygtk, and that got rid of that error. The example demo provided with the pygtk package worked fine, so I'm starting to think that Wikipedia's example is out dated.

  4. #4
    Join Date
    May 2008
    Location
    UK
    Beans
    1,451
    Distro
    Ubuntu 8.04 Hardy Heron

    Re: Need help install PyGTK for use in Python

    don't you need to import pygtk and gtk to get gtk to work ?

    http://www.pygtk.org/pygtk2tutorial/index.html

    and specifically - for instance :

    http://www.pygtk.org/pygtk2tutorial/...sec-HelloWorld
    Last edited by Tony Flury; August 6th, 2009 at 10:26 PM.
    Tony - Happy to try to help.
    Unless otherwise stated - all code posted by me is untested. Remember to Mark the Thread as Solved.
    Ubuntu user number # 24044 Projects : TimeWarp - on the fly Backups

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •