GtkBuilder and GtkTextView buffer text



Hello GTK+ list,

I am a newbie to GTK development so apologies if I've overlooked something large. I'm trying to build a simple GUI from a glade file. However, whenever I try to set the text of a GtkTextView object, I get a segmentation fault. Here's my basic workflow:

---
#!/usr/bin/env python3

from gi.repository import Gtk

class Handler:
   def __init__ ( self, builder ):
     self.builder = builder

   destroy = Gtk.main_quit

   def on_button_clicked ( self, button ):
     buf = self.builder.get_object('TextViewInPane').get_buffer()
     buf.set_text("Hello, World!")  # this appears to work.  However

     # ... after returning from this callback function, Gtk core
     # dumps.  :-(  why?

def main ( ):
   builder = Gtk.Builder()
   builder.add_from_file('gui.glade')
   builder.connect_signals( Handler( builder ) )
   builder.get_object('MainWindow').show_all()

   return Gtk.main()

main()
---

In the case that I may have messed up my Glade file, I've attached it in the Zip archive.

Any pointers for a newbie?

Many thanks,

Kevin

Attachment: simple_crashing_program.zip
Description: Zip archive



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]