def on_btn_new_subject_activate(self, widget):
    self.subjects.append_page(Gtk.TextView(), "Testing")

I am trying to create a new tab on a text area but I whenever the signal is called by the event (I click the button), this happens:

TypeError: Expected Gtk.Widget, but got GObjectMeta

I have also tried variations on this like "Gtk.GtkTextView()" and "GtkTextView()" with no success

What am I supposed to be using to get a text area in that tab?


I think you must initialize Gtk.TextView() before use.... I was also facing same problem 2 days before.... Just check following code

        self.textview = Gtk.TextView()
        self.textbuffer = self.textview.get_buffer()
        self.textbuffer.set_text("This is some text inside of a Gtk.TextView. "
            + "Select text and click one of the buttons 'bold', 'italic', "
            + "or 'underline' to modify the text accordingly.")

Refer: http://python-gtk-3-tutorial.readthedocs.org/en/latest/textview.html

| improve this answer | |
  • I'm not getting the error, but it is not adding a page to the Notebook. – njallam Jun 22 '12 at 15:46
  • What is widget type of subject? – gau1991 Jun 22 '12 at 15:55
  • subjects is a Notebook widget – njallam Jun 22 '12 at 16:02
  • It is now called pages, but it is still the same thing. – njallam Jun 22 '12 at 16:12
  • This is my structure: askubuntu.com/questions/154687/… – njallam Jun 22 '12 at 16:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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