Sign up ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

I am using this method to save a file:

def save(self):
    file_data = ConfigParser.ConfigParser()
    subjects_number = self.subjects.get_n_pages()
    si = range(1, subjects_number)
    for sn in si:
        subject_content = self.subjects.get_nth_page(sn)
        subject_name = self.subjects.get_tab_label(subject_content)
        file_data.add_section(subject_name) #Line 153
        pages_number = self.subjects.get_nth_page(sn)
        pi = range(1, pages_number)
        for pn in pi:
            page_content = subject_content.get_nth_page(pn)
            page_name = pages.get_tab_label(page_content)
            c_buffer = page_content.get_buffer()
            c_format = c_buffer.register_serialize_tagset()
            serial = c_buffer.serialize(c_format, c_buffer.get_start_iter(), c_buffer.get_end_iter())
            file_data.set(subject_name, page_name, serial)
    with open(self.current_file, "wb") as this_file:
    print "File Saved:" + self.current_file

However when ran I get this traceback in the Terminal window:

Traceback (most recent call last):
  File "/home/nja/notetaker/notetaker/", line 251, in on_btn_save_clicked
  File "/home/nja/notetaker/notetaker/", line 153, in save
  File "/usr/lib/python2.7/", line 260, in add_section
    if section.lower() == "default":
AttributeError: 'Label' object has no attribute 'lower'

These methods create the tabs in the Gtk.Notebook() widgets:

def add_page(self, pages = None, label = None):
    if pages is None:
        pages = self.get_pages()
    if label is None:
        label = "New Page"
    textview = Gtk.TextView()
    textbuffer = textview.get_buffer()
    pages.append_page(textview, Gtk.Label(label))

def add_subject(self, label = None):
    if label is None:
        label = "New Subject"
    pages = Gtk.Notebook()
    self.subjects.append_page(pages, Gtk.Label(label))

What do I need to do to resolve this error?

share|improve this question

1 Answer 1

up vote 2 down vote accepted

self.subjects.get_tab_label(subject_content) gets you a Gtk.Label instance but file_data.add_section expects a string as parameter.


subject_name = self.subjects.get_tab_label(subject_content).get_text()
share|improve this answer
Thanks. There are tons more bugs in my saving script, but I'll keep that debugging fun to myself. :) – njallam Sep 1 '12 at 19:27

Your Answer


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.