Ruby/TK - Message Box Widget

Advertisements


Description:

A MessageBox is a widget that displays a simple dialog with predefined buttons.

Syntax:

Here is a simple syntax to create this widget:

Tk.messageBox {
  .....Widget-specific Options....
}

Standard Options:

NA

Widget-specific Options:

SNOptions with Description
1icon => String
Specify the icon of the messageBox. Valid values are error, info, question, or warning.
2type => String
Specify the type of the messageBox. Valid values are abortretryignore, ok, okcancel, retrycancel, yesno, or yesnocancel. The type determines the buttons to be shown.
3default => String
Specify the default button. This must be one of abort, retry, ignore, ok, cancel, yes, or no, depending on the type of the messageBox previously specified.
4detail => String
Specify text for the detail region of the messageBox.
5message => String
Specify the message text of the messageBox.
6title => String
Specify the title of the messageBox.

Event Bindings:

NA

Examples:

require 'tk'

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

msgBox = Tk.messageBox(
  'type'    => "ok",  
  'icon'    => "info", 
  'title'   => "This is title",
  'message' => "This is message"
)
Tk.mainloop

This will produce the following result:

Ruby/Tk MsgBox


Advertisements
Advertisements