[pygtk] Help passing a widget to another class instance
Kim Adil
kadil at proactiveindustrial.net
Mon Jul 20 19:04:53 WST 2009
Hi,
I have a class for a glade window, that contains a notebook and I have
another class for notebook pages. I want to pass the (pointer to)
notebook widget when I create the the page object, so I can change the
notebook's tab label from a method in the page class (ie save button on
the page) but I get the error:
print self.pparent.get_current_page()
AttributeError: load_data_page instance has no attribute 'pparent'
code snips below. Question is how do you pass the widget (or pointer)
from one object to another?
Thanks,
Kim
class load_data_page:
"""__init__() functions"""
def __init__(self,pparent):
self.gladefile = "bp2.glade"
self.wTree = gtk.glade.XML(self.gladefile, "vbox4")
self.pageWidget = self.wTree.get_widget("vbox4")
self.entryDescription = self.wTree.get_widget("entryDescription")
self.entryUserid = self.wTree.get_widget("entryUserid")
self.entryUserid.set_text(os.environ['USERNAME'])
self.entryUserid = self.wTree.get_widget("entryTimestamp")
self.entryUserid.set_text(time.strftime("%d/%m/%Y %H:%M:%S",
time.localtime()))
self.buttonLoad = self.wTree.get_widget("buttonLoad")
dic = {"on_buttonLoad_clicked" : self.loadFile,
}
self.wTree.signal_autoconnect(dic)
def loadFile(self,data):
self.entryDescription.set_text('hello')
print 'zzzz'
print pparent.get_current_page()
class win_main:
"""An application to help manage things you intend to do"""
def __init__(self):
#Set the Glade file
self.gladefile = "bp2.glade"
self.wTree = gtk.glade.XML(self.gladefile, "window1")
self.wTree3 = gtk.glade.XML(self.gladefile, "toolbar2")
self.wTree2 = gtk.glade.XML(self.gladefile, "menu4")
self.wTree4 = gtk.glade.XML(self.gladefile, "label13")
self.menu41 = self.wTree2.get_widget("tbm3datafile")
dic = {"on_win_main_destroy" : self.aquit,}
self.notepad = self.wTree.get_widget("notebook1")
...
.....
More information about the pygtk
mailing list