Hello,

I'm an absolute python newbie, but wanted to explore gui programming
with pygtk. Unfortunately, I can't succeed in having gtkhtml2 render
something. Whenever I execute the "self.itemview.test()" method, I get
the following error message:

(Tidbits:1484): Gtk-CRITICAL **: file gtkscrolledwindow.c: line 1307
(gtk_scrolled_window_add): assertion `bin->child == NULL' failed

(Tidbits:1484): GLib-GObject-CRITICAL **: file gobject.c: line 1290
(g_object_ref): assertion `object->ref_count > 0' failed

I'm also sure the design of the program is really really bad ... but
what would you expect after 2 hours of reading the first chapters of a
tutorial ? :)

Thanks in advance,
Coen De Roover


import pygtk
pygtk.require('2.0')

import gobject
import gtk
import gnome
import gtkhtml2
import gnome.ui
import pango

from gtk import glade

class UI:
  def __init__(self, uifile):
    self.widgets = glade.XML(uifile)
    self.signals = {} 
    self.widgets.signal_autoconnect(self.signals)
    gnome.init("Tidbits", "0.0")
    window = MainWindow(self)
    
 
class ItemView:
  def __init__(self, ui):
    self.scrolled_window = ui.widgets.get_widget('scrolledwindow1')
    self.view = gtkhtml2.View()
    self.scrolled_window.add(self.view)
  
  def test(self):
    self.document = gtkhtml2.Document()
    self.view.set_document(self.document)
    self.document.open_stream('text/html')
    self.document.write_stream('<html><head></head><body>Hello, World!</body></html>')
    self.document.close_stream()

class MainWindow:
  def __init__(self, ui):
    self.itemview = ItemView(ui)
    self.itemview.test()

class Main:
  def __init__(self):
    uifile = "tidbits.glade" 
    ui = UI(uifile)

tidbits = Main()
gtk.main()

Attachment: tidbits.glade
Description: application/glade

Reply via email to