O'Reilly logo

Sams Teach Yourself Ruby in 21 Days by Mark Slagell

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

A Full Ruby/Gtk Application

In today's final example we'll bring together some of the Gtk features we have just learned about and will add a few new ones. The goal is to build a more versatile text editor around a Gtk::Text widget, giving it drop-down menus, global search and replace, and the ability to load and save files. There will be three classes in separate files, but one of those files, messagebox.rb, we have already written.

The top-level editor class is given in Listing 18.11.

Listing 18.11. editor.rb
 001: #!/usr/bin/env ruby 002: 003: require 'gtk'; include Gtk 004: require 'findbox' 005: require 'messagebox' 006: 007: class Editor < Window 008: def initialize(initial_filename = nil) 009: 010: super() 011: (ag = AccelGroup.new).attach(self) ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required