Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

natatos

macrumors regular
Original poster
Hi, I'm trying to learn how to program so I'm really new to this and I thought python would be good because it seemed simple and its cross platform, so I was watching a tutorial on YouTube for making a window.
Heres the code
Code:
#!/usr/bin/env Python

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()
        
if __name__ == "__main__":
    base = Base()
    base.main()

When I try to run it it says 'No module named pygtk' I'm used Text Wrangler for it and got that result but if I write it in Terminal I get basically the same thing. So I'm wondering how would I have it find the pygtk, or not need it?
 
If you want to write GUI code using GTK (and follow the GTK tutorials), you cannot be without pygtk unfortunately. OS X support for pygtk is either through X11 or through a very early native port that requires building GTK yourself :

http://faq.pygtk.org/index.py?req=show&file=faq01.019.htp

Of course, you probably want PyObjC instead. You'll have to find tutorials on it obviously and can't use the pygtk stuff, but Apple seems to have a good primer here :

http://developer.apple.com/cocoa/pyobjc.html

BTW, yes, Python is a good place to start coding. I would however suggest you put aside the GUI stuff for now and concentrate on learning to code. Just use a text mode interface using only the print function.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.