Module: Zerenity
- Defined in:
- lib/zerenity/base.rb,
lib/zerenity/info.rb,
lib/zerenity/list.rb,
lib/zerenity/entry.rb,
lib/zerenity/error.rb,
lib/zerenity/scale.rb,
lib/zerenity/warning.rb,
lib/zerenity/calendar.rb,
lib/zerenity/progress.rb,
lib/zerenity/question.rb,
lib/zerenity/textinfo.rb,
lib/zerenity/messagedialog.rb,
lib/zerenity/colorselection.rb
Overview
Zerenity provides a number of simple graphical dialogs.
Global Options
- :title
-
The text displayed in the title bar.
- :text
-
The text that will be displayed in the dialog (if needed).
- :activatesDefault
-
If set to false disables the firing of the OK button when the Enter key is pressed.
Defined Under Namespace
Classes: Base, Calendar, ColorSelection, Entry, Error, Info, List, MessageDialog, Progress, ProgressProxy, Question, Scale, TextInfo, Warning
Constant Summary collapse
- CLICKED =
"clicked"
Class Method Summary collapse
-
.Calendar(options = {}) ⇒ Object
Creates a calendar dialog allowing the user to select a date.
-
.ColorSelection(options = {}) ⇒ Object
Displays a color selection dialog.
-
.Entry(options = {}) ⇒ Object
Displays a text entry box.
-
.Error(options = {}) ⇒ Object
Displays an error dialog.
-
.Info(options = {}) ⇒ Object
Displays an informational popup dialog on the screen.
-
.List(options = {}) ⇒ Object
Displays a list dialog on the screen.
-
.Progress(options = {}, &block) ⇒ Object
Displays a progress bar which can be updated via a processing block which is passed a ProgressProxy object.
-
.Question(options = {}) ⇒ Object
Displays a question dialog.
-
.Scale(options = {}) ⇒ Object
Displays a sliding scale.
-
.TextInfo(options = {}) ⇒ Object
Displays text in a multiline text info box.
-
.Warning(options = {}) ⇒ Object
Displays a warning dialog on the screen.
Class Method Details
.Calendar(options = {}) ⇒ Object
10 11 12 |
# File 'lib/zerenity/calendar.rb', line 10 def self.Calendar(={}) Calendar.run() end |
.ColorSelection(options = {}) ⇒ Object
Displays a color selection dialog. Returns the value of the color selected as #rrrrggggbbbb, where r, g and b are hex digits representing the red, green and blue components respectively
====Example Usage:
Zereity::ColorSelection( :title => "Select a color" )
10 11 12 |
# File 'lib/zerenity/colorselection.rb', line 10 def self.ColorSelection( = {} ) ColorSelection.run( ) end |
.Entry(options = {}) ⇒ Object
12 13 14 |
# File 'lib/zerenity/entry.rb', line 12 def self.Entry(={}) Entry.run() end |
.Error(options = {}) ⇒ Object
7 8 9 |
# File 'lib/zerenity/error.rb', line 7 def self.Error(={}) Error.run() end |
.Info(options = {}) ⇒ Object
8 9 10 |
# File 'lib/zerenity/info.rb', line 8 def Zerenity::Info(={}) Info.run() end |
.List(options = {}) ⇒ Object
Displays a list dialog on the screen. Items in the list can be selected. Returns the rows which were selected or nil if Cancel is clicked.
Options
- :columns
-
The names which will be displayed at the top og
each column. This option is mandatory.
- :data
-
The data for the list, with each row being another array.
- :radiolist
-
If this is set true the first column of the list will be rendered as a radiobutton. The first element of every data array should either be a true or false.
- :checklist
-
If this is set true the first column of the list will be rendered as a checkbox. The first element of every data array should either be a true or false. When this is set mutiple rows can be selected and an array of selected rows are returned.
Note :radiolist and :checklist are mutually exclusive. If both are set true an exception is thrown. An exception is also thrown if the data rows are not equal length or they differ in length with the number of columns.
Example Usage
choice = Zerenity::List(:columns=>["Food","Energy"],:data=>[["Chips","200KJ"],["Chocolate","300KJ"]])
28 29 30 |
# File 'lib/zerenity/list.rb', line 28 def self.List(={}) List.run() end |
.Progress(options = {}, &block) ⇒ Object
Displays a progress bar which can be updated via a processing block which is passed a ProgressProxy object.
Options
- :autoClose
-
The dialog will automatically close once the progressing block is complete.
- :cancellable
-
If set to true the Cancel button is enabled and the ProgressProxy#cancelled? will be set to true if it is clicked. It is the responsibility of the processing block to monitor this attribute and perfom the necessary actions when it is ckicked.
Example Usage
Zerenity::Progress(:text=>"Processing...",:cancellable=>true,:title=>"Processing Files") do |progress|
files.each_with_index do |file,index|
progress.cancelled ? break : nil
process_file(file)
progress.update(index/files.size,"#{((index/files.size)*100).round}% Complete")
end
if progress.cancelled?
progress.text = "Cleaning up..."
cleanup_files(files)
end
end
27 28 29 |
# File 'lib/zerenity/progress.rb', line 27 def self.Progress(={},&block) Progress.run(,&block) end |
.Question(options = {}) ⇒ Object
11 12 13 |
# File 'lib/zerenity/question.rb', line 11 def self.Question(={}) Question.run() end |
.Scale(options = {}) ⇒ Object
Displays a sliding scale. Returns the value selected or nil if cancel is pressed.
Options
- :min
-
The minimum value of the sliding scale. Defaults to 0.
- :max
-
The maximum value of the sliding scale. Defaults to 100.
- :step
-
The size of the value increment of the sliding scale for keyboard shortcuts. Defaults to 1.
- :initial
-
The initial value of the sliding scale. Defaults to 0.
Example Usage
value = Zerenity::Scale(:text=>"Please select a value", :min => 1, :max => 250, :step => 3)
14 15 16 |
# File 'lib/zerenity/scale.rb', line 14 def self.Scale(={}) Scale.run() end |
.TextInfo(options = {}) ⇒ Object
Displays text in a multiline text info box.
Options
- :editable
-
If set to true the text info box is editable.
- :scrollable
-
If the size of the text does not fit in the height and width constraints, the text info box will become scrollable
- :height,:width
-
The height and width of the text box, in pixels. Note this is not the height and weidth of the full window.
- :text
-
The text to be displayed in the text info box.
Example Usage
Zerenity::TextIfno(:text=>File.new($0).read)
17 18 19 |
# File 'lib/zerenity/textinfo.rb', line 17 def self.TextInfo(={}) TextInfo.run() end |