module SimpleTk

A real cheap wrapper around the Ruby Tk bindings.

Constants

VERSION

Public Class Methods

alert(message, icon = :info) click to toggle source

Creates a basic alert message box.

message

The message to display.

icon

The icon to display (one of :info, :error, :question, or :warning).

Returns true.

# File lib/simple_tk.rb, line 24
def self.alert(message, icon = :info)
  Tk::messageBox message: message, icon: icon.to_s
  true
end
ask(message, icon = :question, ok_cancel = false) click to toggle source

Creates a basic yes/no message box.

message

The message to display.

icon

The icon to display (one of :info, :error, :question, or :warning).

ok_cancel

Set to true to make the buttons OK and Cancel instead of Yes and No.

Returns true for ‘Yes’ (or ‘OK’) or false for ‘No’ (or ‘Cancel’).

# File lib/simple_tk.rb, line 40
def self.ask(message, icon = :question, ok_cancel = false)
  %w(ok yes).include?(Tk::messageBox(message: message, type: ok_cancel ? 'okcancel' : 'yesno', icon: icon))
end
run() click to toggle source

Runs the Tk application.

# File lib/simple_tk.rb, line 11
def self.run
  Tk.mainloop
end