Create  Edit  FrontPage  Index  Search  Changes  History  RSS  Back  Login

tut-gtk2-txtw-textview - History

  • Added words are showed as here.
  • Removed words are showed as here.
= The Text View Widget
{{link "tut-gtk2-txtw-scrolledwin", "tut-gtk2-txtw", "tut-gtk", "tut-gtk2-txtw-itrsmrks"}}

= Sorry still under construction

== Text Views


The Gtk::TextView widget is used to display multiple lines of a text document. it provides many ways to customize the text within the widget. You can even insert Gdk::Pixbuf objects and other child widgets into a document. Gtk::TextView is the first  reasonably involved widget we've encountered so far and in this session we will explore most of its interesting features. It is a versatile widget that you will exploit in many GTK+ applications.

At the first glance you may think that this widget may only be used  to display simple text, however that is not the case. It can also be used to display many types of rich text, and interactive documents used by a variety of different applications. This is what we will learn here in the following few articles.

Let us start with a simple example of Gtk::TextView widget inside a Gtk::ScrolledWindow widget:


#!/usr/bin/env ruby
require 'gtk2'

window =
window.resizable = true
window.title = "Text Views"
window.border_width = 10
window.signal_connect('delete_event') { Gtk.main_quit }
window.set_size_request(250, 150)

textview =
textview.buffer.text = "Your 1st Gtk::TextView widget!"

scrolled_win =
scrolled_win.border_width = 5
scrolled_win.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_ALWAYS)

Last modified:2022/01/18 09:40:01