# Gtkhtml2 blank window

**URL:** <https://www.ruby-forum.com/t/gtkhtml2-blank-window/79062>\
**Category:** Ruby\
**Created:** [December 11, 2006, 11:18pm UTC](https://www.ruby-forum.com/t/gtkhtml2-blank-window/79062 "2006-12-11T23:18:18Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![pjpatten](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/e47c2d/32.png) [@pjpatten](https://www.ruby-forum.com/u/pjpatten)\
**Post date:** [December 11, 2006, 11:18pm UTC](https://www.ruby-forum.com/t/gtkhtml2-blank-window/79062/1 "2006-12-11T23:18:18Z")

</div>

hi ho ml :-),

i run into a new problem while writing an gtk application. a lot of  
things are working now, but not the gtkhtml2. i tried to put some html  
code into the html-document, but i get an blank window only.

i’ve written a working (or better: not working) example. everyone with  
an idea is really welcome :-). any suggestion for tutorials, examples or  
documentation is also very welcome - google wasn’t really useful. i  
found an example on [http://koti.welho.com/jpakaste/blog/2002/index.html](http://koti.welho.com/jpakaste/blog/2002/index.html)

thanks,  
patrick

ps. sorry for my tripple sending of my last mail, i had trouble with the  
email server

require ‘gtk2’  
require ‘gtkhtml2’

Gtk::init

window = Gtk::Window.new  
window.border\_width = 10  
window.set\_size\_request(600, 400)  
window.add(box = Gtk::VBox.new(false, 0))

htmlview = Gtk::HtmlView.new()  
document = Gtk::HtmlDocument.new()  
document.clear  
document.open\_stream(“text/html”)  
document.write\_stream(“titlebody”)  
document.close\_stream()

window.signal\_connect(‘delete\_event’) do  
Gtk::main\_quit  
false  
end

box.pack\_start(htmlview)  
window.show\_all  
Gtk::main

---

<div class="post-metadata">

**Author:** ![pjpatten](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/e47c2d/32.png) [@pjpatten](https://www.ruby-forum.com/u/pjpatten)\
**Post date:** [December 12, 2006, 12:24am UTC](https://www.ruby-forum.com/t/gtkhtml2-blank-window/79062/2 "2006-12-12T00:24:32Z")

</div>

Patrick,

I may be missing something, but it looks like you never add htmlview to  
your window, or the vertical box that you’ve created.

-trevor

---

<div class="post-metadata">

**Author:** ![pjpatten](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/e47c2d/32.png) [@pjpatten](https://www.ruby-forum.com/u/pjpatten)\
**Post date:** [December 12, 2006, 12:26am UTC](https://www.ruby-forum.com/t/gtkhtml2-blank-window/79062/3 "2006-12-12T00:26:33Z")

</div>

Patrick,

I was indeed missing something. That’ll teach me to reply before I  
finish  
reading code 🙂

-trevor

---

<div class="post-metadata">

**Author:** ![pjpatten](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/e47c2d/32.png) [@pjpatten](https://www.ruby-forum.com/u/pjpatten)\
**Post date:** [December 12, 2006, 12:38am UTC](https://www.ruby-forum.com/t/gtkhtml2-blank-window/79062/4 "2006-12-12T00:38:38Z")

</div>

Patrick,

I read into it, and it looks like you never connect htmlview and  
document.  
If you add this somewhere after document is created, I would think it  
would help… I’m not sure of the syntax on this one, given that the  
article you referenced seems to do things just slightly differently. I  
assumed the underscore, just because it’s Ruby, but I could be wrong…

htmlview.set\_document(document)

I even read through all the code this time, and feel that this is a  
valid  
suggestion 🙂

Hope this works!

-trevor

---

<div class="post-metadata">

**Author:** ![pjpatten](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/e47c2d/32.png) [@pjpatten](https://www.ruby-forum.com/u/pjpatten)\
**Post date:** [December 12, 2006, 12:44am UTC](https://www.ruby-forum.com/t/gtkhtml2-blank-window/79062/5 "2006-12-12T00:44:39Z")

</div>

Trevor Elliott wrote:

> Patrick,
> 
> I was indeed missing something. That’ll teach me to reply before I finish  
> reading code 🙂

maybe i should begin with the signal handler next time this could make  
the code easier to read.

greetings,  
patrick

---

<div class="post-metadata">

**Author:** ![pjpatten](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/e47c2d/32.png) [@pjpatten](https://www.ruby-forum.com/u/pjpatten)\
**Post date:** [December 12, 2006, 1:00am UTC](https://www.ruby-forum.com/t/gtkhtml2-blank-window/79062/6 "2006-12-12T01:00:44Z")

</div>

Trevor Elliott schrieb:

> I even read through all the code this time, and feel that this is a valid  
> suggestion 🙂

yes, that’s it! thanks :-). it works fine now, i just forgot to connect  
the document. the following both lines do the same thing (just for the  
archive):

htmlview.set\_document(document)  
htmlview.document = document

thanks again and if you will be in germany one time, i’ll get you a  
coffee or a tea if you wish 🙂

patrick
