python - Attribute Error: HelloWorld Instance has no attribute main -


i getting error

traceback (most recent call last):     file "helloworld.py", line 66, in module          hello.main() attributeerror: helloworld instance has no attribute 'main' 

i running code given below on linux machine

#!/usr/bin/env python  # example helloworld.py import pygtk pygtk.require('2.0') import gtk  class helloworld:      # callback function. data arguments ignored     # in example. more on callbacks below.     def hello(self, widget, data=none):         print "hello world"      def delete_event(self, widget, event, data=none):         # if return false in "delete_event" signal handler,         # gtk emit "destroy" signal. returning true means         # don't want window destroyed.         # useful popping 'are sure want quit?'         # type dialogs.         print "delete event occurred"          # change false true , main window not destroyed         # "delete_event".         return false      def destroy(self, widget, data=none):         print "destroy signal occurred"         gtk.main_quit()      def __init__(self):         # create new window         self.window = gtk.window(gtk.window_toplevel)          # when window given "delete_event" signal (this given         # window manager, "close" option, or on         # titlebar), ask call delete_event () function         # defined above. data passed callback         # function null , ignored in callback function.         self.window.connect("delete_event", self.delete_event)          # here connect "destroy" event signal handler.           # event occurs when call gtk_widget_destroy() on window,         # or if return false in "delete_event" callback.         self.window.connect("destroy", self.destroy)          # sets border width of window.         self.window.set_border_width(10)          # creates new button label "hello world".         self.button = gtk.button("hello world")          # when button receives "clicked" signal, call         # function hello() passing none argument.  hello()         # function defined above.         self.button.connect("clicked", self.hello, none)          # cause window destroyed calling         # gtk_widget_destroy(window) when "clicked".  again, destroy         # signal come here, or window manager.         self.button.connect_object("clicked", gtk.widget.destroy, self.window)          # packs button window (a gtk container).         self.window.add(self.button)          # final step display newly created widget.         self.button.show()          # , window         self.window.show()      def main(self):         # pygtk applications must have gtk.main(). control ends here         # , waits event occur (like key press or mouse event).         gtk.main()  # if program run directly or passed argument python # interpreter create helloworld instance , show if __name__ == "__main__":     hello = helloworld()     hello.main() 

is indent problem? how solve it? tried searching internet, no help. same code given in pygtk tutorial. please help.

i copied code linux machine , ran it, , worked fine no errors. running command line? $python helloworld.py ? or trying run through python console session?

the indentation doesn't seem issue. version of python running?


Comments

Popular posts from this blog

user interface - Python attempting to create a simple gui, getting "AttributeError: 'MainMenu' object has no attribute 'intro_screen'" -

jquery - Common JavaScript snippet to share files on Google Drive, Dropbox, Box.net or SkyDrive -

Android Gson.fromJson error -