Ruby/TK - Combobox Widget

Advertisements


Description:

A Combobox combines an entry with a list of choices available to the user. This lets them either choose from a set of values you've provided (e.g., typical settings), but also put in their own value.

Syntax:

Here is a simple syntax to create this widget:

Tk::BWidget::ComboBox.new(root){
  .....Options....
}

Options:

Combobox combines the options related to TkEntry and TkListbox widgets.

Event Bindings:

Combobox inherits event bindings from TkEntry and TkListbox widgets.

Examples:

require 'tk'
require 'tkextlib/bwidget'

root = TkRoot.new
root.title = "Window"

combobox = Tk::BWidget::ComboBox.new(root)
combobox.values = [1, 2, 3, 4]
combobox.place('height' => 25,
               'width'  => 100,
               'x'      => 10,
               'y'      => 10)

Tk.mainloop

This will produce the following result:

Ruby/Tk Combobox


Advertisements
Advertisements