GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Sat Nov 01, 2014 9:46 am

All times are UTC




Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: gtk Error
PostPosted: Tue Sep 04, 2012 9:07 pm 
Offline

Joined: Tue Sep 04, 2012 8:28 pm
Posts: 1
Hey Guys!

Today I programmed some lines of pygtk code. Everything was fine until I tried to rename, resave, or even copy and paste my python-file. When I do that, I get the following error message:

Quote:
self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
AttributeError: 'module' object has no attribute 'Window'


Only the original file works and I really have NO clue whats wrong about the others.

I trimmed my code to be easier to read - still the same error occurs of course:

Code:
import pygtk
pygtk.require('2.0')
import gtk

class Base:
    def __init__(self):
        self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
        self.window.set_position(gtk.WIN_POS_CENTER)
        self.window.set_size_request(200,160)
        self.window.set_title("kb-handler")
       
        self.button1 = gtk.Button("Exit")
        self.button1.connect("clicked",self.close)
               
        fixed = gtk.Fixed()
        fixed.put(self.button1,20,350)
       
        self.window.add(fixed)

        self.window.show_all()
        self.window.connect("destroy",self.close)
     
    def close(self,widget,data=None):
        print "Closed"
        gtk.main_quit()
                                                               
    def main(self):
        gtk.main()

if __name__ == "__main__":
    base = Base()
    base.main()


I'm sorry, but I can't tell you what version of PyGTK I really use. I installed PyGTK with PyCairo and PyGObject via a all in one installation from this website: http://www.pygtk.org/downloads.html
The version number of the package I used is 2.24.2 which is a 32bit Python 2.7 version.

As mentioned, I especially don't understand why the original version works and the renamed or saved ones not. I allready tried to figure out whats wrong about my code and it seems that this problem is not that uncommon. But the usual problems are:
- typing errors
- the file name is also the name of an imported modul (which is obviously not the case because I named them version1, version2,...)
- wrong versions of PyGTK,... (which to my opinion is also not the case, because the original version works)

I really hope you can help me, I would be very greatful.
Thank's a lot guys!
Joe


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC


Who is online

Users browsing this forum: Google [Bot] and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group