Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I am having some trouble adding a page to a Notebook widget. The error I get is this:

AttributeError: 'function' object has no attribute 'append_page'

I assume this means the object pages in the following code has not been set to a Gtk.Notebook class.

def add_page(self, pages):
    textview = Gtk.TextView()
    textbuffer = textview.get_buffer()
    textbuffer.set_text("")
    pages.append_page(textview, Gtk.Label("New Page"))

The code that calls that is:

def on_btn_new_page_activate(self, widget):
    self.add_page(self.get_pages)

The method get_pages() is following (Probably where the problem is):

def get_pages(self):
    subjectNum = self.subjects.get_current_page()
    pages = self.subject.get_nth_page(subjectNum)
    return pages

The subjects variable is a valid Notebook fetched by the following:

self.subjects = self.builder.get_object("subjects")

Thanks.

EDIT: Now the following error occurs:

Traceback (most recent call last):
File "/home/nja/notetaker/notetaker/NotetakerWindow.py", line 100, in on_btn_new_page_activate
self.add_page(self.get_pages())
File "/home/nja/notetaker/notetaker/NotetakerWindow.py", line 73, in get_pages
pages = self.subject.get_nth_page(subjectNum)
AttributeError: 'NotetakerWindow' object has no attribute 'subject'
share|improve this question
2  
@Nick - It has also been quoted from the FAQ a billion times: "We welcome questions about: Development on Ubuntu." –  hbdgaf Jun 23 '12 at 12:30

1 Answer 1

up vote 4 down vote accepted

The fix is:
self.add_page(self.get_pages())

not self.add_page(self.get_pages)

the latter passes in the function self.get_pages not its return value

Edit:

from: pages = self.subject.get_nth_page(subjectNum)

to: pages = self.subjects.get_nth_page(subjectNum)

This is a simple typo we all make from time to time.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.