Hi list,
I'm trying to subclass a gtk.Window just to understand the concept of code
reusing.
I'm doing like this, but it doesn't work, in the first file:
import gtk
class Win(gtk.Window):
def __init__(self, width, height, title):
self.wind = gtk.Window()
self.wind.set_title(title)
self.wind.set_default_size(width, height)
In the second file I import the first and try to pass the argument to the
first class:
#!/usr/bin/env python
import pygtk
pygtk.require('2.0')
import gtk
import first
class SecondWin:
def __init__(self):
self.win = first.Win(150, 300, "example")
self.win.connect("delete_event", self.delete_event)
self.win.connect("destroy", self.destroy)
self.hbox = gtk.HBox(gtk.TRUE, 0)
self.win.add(self.hbox)
self.button = gtk.Button("Hello World")
self.button.connect("clicked", self.hello, None)
self.button.connect_object("clicked", gtk.Widget.destroy, self.win)
self.button1 = gtk.Button("Hello")
self.button1.connect("clicked", self.hello, None)
self.button1.connect_object("clicked", gtk.Widget.destroy, self.win)
self.hbox.pack_start(self.button, gtk.TRUE, gtk.TRUE, 0)
self.hbox.pack_start(self.button1, gtk.TRUE, gtk.TRUE, 0)
self.win.show_all()
def hello(self, widget, data=None):
print "Hello, World"
def delete_event(self, widget, event, data=None):
return gtk.FALSE
def destroy(self, widget, data=None):
return gtk.main_quit()
def main(self):
gtk.main()
if __name__ == "__main__":
second = SecondWin()
second.main()
The window open but doesn't take any parameter, most likely is a mistake in
subclassing but I haven't understood where is the mistake.
If someone can help I thank him/her in advance.
Regards
Lq
_______________________________________________
pygtk mailing list [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/