Create  Edit  FrontPage  Index  Search  Changes  History  RSS  Login


Handle Boxes


The Gtk::HandleBox widget is a type of Gtk::Bin container (just a reminder Gtk::Bin only permits one child to exist), that allows its child to be detached from from the parent window by dragging it with the mouse. When removed the child is placed in its own window without any decorations. If there are other widgets in a window which contained the Gtk::HandleBox widget which now has a child detached, they will be resized to fill the void space if possible. This widget is most commonly used to contain toolbars and other toolkit objects. Indeed, you can re-attach a child by dragging it back to the location of the dotted handle. Yo may have to look hard to spot the handle.

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

window =
window.border_width = 10
window.set_size_request(200, -1)
window.title = "Handle Box"

# The delete_event is only needed if you plan to
# intercept the destroy / quit with a dialog box.
# window.signal_connect('delete_event') { false }
window.signal_connect('destroy') { Gtk.main_quit }

handle =
label ="Detach Me");

# Add a shadow to the handle box, set the handle position
# on the left and set the snap edge to the top of the widget.

handle.shadow_type = Gtk::SHADOW_IN
handle.handle_position = Gtk::POS_TOP
# handle.handle_position = Gtk::POS_LEFT
handle.snap_edge = Gtk::POS_TOP

Used to change the appearance of an outline typically provided by a Gtk::Frame.
  • SHADOW_NONE - No outline.
  • SHADOW_IN - The outline is bevelled inwards.
  • SHADOW_OUT - The outline is bevelled outwards like a button.
  • SHADOW_ETCHED_IN - The outline itself is an inward bevel, but the frame does
  • SHADOW_ETCHED_OUT - The outline itself is an outward bevel, but the frame does
Describes which edge of a widget a certain feature is positioned at, e.g. the tabs of a Gtk::Notebook, the handle of a Gtk::HandleBox or the label of a Gtk::Scale.
  • POS_LEFT - The feature is at the left edge.
  • POS_RIGHT - The feature is at the right edge.
  • POS_TOP - The feature is at the top edge.
  • POS_BOTTOM - The feature is at the bottom edge.
Last modified:2009/02/09 10:24:23
References:[tut-gtk2-contwidg] [tut-gtk] [tut-gtk2-mnstbs-tb]