NOGDUS $1670.00 has been donated to NOGDUS!
July 20, 2017, 11:42:05 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
 
   Home   Help Search Login Register  
Pages: [1]   Go Down
  Print  
Author Topic: Ruby MsgBox  (Read 4957 times)
0 Members and 1 Guest are viewing this topic.
Richard Marks
Administrator
Offline Offline

Respect: 3425
« on: September 24, 2009, 08:41:39 AM »

Ruby MsgBox

The following code is an implementation of a VBScript MsgBox in the Ruby language.

Note: The VBScript MsgBox function allowed you to specify the buttons and icons used.
This implementation gives a simple Info Icon with an OK button.

Code:
=begin
****************************************************************************
* Copyright (c) 2009, Richard Marks, CCPS Solutions,                       *
* Undefined Aeon Software.                                                 *
*                                                                          *
* Permission is hereby granted, free of charge, to any person obtaining a  *
* copy of this software and associated documentation files (the            *
* "Software"), to deal in the Software without restriction, including      *
* without limitation the rights to use, copy, modify, merge, publish,      *
* distribute, distribute with modifications, sub-license, and/or sell      *
* copies of the Software, and to permit persons to whom the Software is    *
* furnished to do so, subject to the following conditions:                 *
*                                                                          *
* The above copyright notice and this permission notice shall be included  *
* in all copies or substantial portions of the Software.                   *
*                                                                          *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.  *
* IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
* THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
*                                                                          *
* Except as contained in this notice, the name(s) of the above copyright   *
* holders shall not be used in advertising or otherwise to promote the     *
* sale, use or other dealings in this Software without prior written       *
* authorization.                                                           *
****************************************************************************
=end
require 'gtk2'
def MsgBox(text, title)
mb = Gtk::MessageDialog.new(
nil,
Gtk::Dialog::MODAL,
Gtk::MessageDialog::INFO,
Gtk::MessageDialog::BUTTONS_OK,
text)
mb.title = title
mb.run do |result|
"response=#{result}"
end
mb.destroy
end

Its use is very simple.

Code:
MsgBox "This is what will be printed in the dialog box", "This is the title"

Presto. Instant Easy MsgBox functionality for your Ruby scripts.
Logged

Tags:
Pages: [1]   Go Up
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines
.: Theme by Richard Marks :.
Valid XHTML 1.0! Valid CSS!