Class: Wx::BusyInfo

Inherits:
Object
  • Object
show all
Defined in:
lib/wx/doc/gen/busy_info.rb,
lib/wx/doc/busy_info.rb

Overview

Note:

This class is untracked and should not be derived from nor instances extended!

This class makes it easy to tell your user that the program is temporarily busy.

Normally the main thread should always return to the main loop to continue dispatching events as quickly as possible, hence this class shouldn’t be needed. However if the main thread does need to block, this class provides a simple way to at least show this to the user: just call BusyInfo.busy with a block and for the duration of the execution of the block a message window will be shown. For example:

BusyInfo.busy('Working, please wait...') do
    100000.times { do_a_calculation }
  end

The displayed window is rather plain by default but can be customized by passing BusyInfo.busy an object of BusyInfoFlags class instead of a simple message. Here is an example:

Wx::BusyInfo.busy(
    Wx::BusyInfoFlags.new
      .parent(self)
      .icon(Wx::ArtProvider.get_icon(Wx::ART_PRINT,Wx::ART_OTHER, [128, 128]))
      .title("<b>Printing your document</b>")
      .text("Please wait...")
      .foreground(Wx::WHITE)
      .background(Wx::BLACK)
      .transparency(4*Wx::ALPHA_OPAQUE/5)) do |bi|
  end

This shows that separate title and text can be set, and that simple markup (Control#set_label_markup) can be used in them, and that it’s also possible to add an icon and customize the colours and transparency of the window. You may also want to call Wx.get_app.yield to refresh the window periodically (in case it had been obscured by other windows, for example) like this:

Wx::WindowDisabler.disable do
    BusyInfo.busy('Working, please wait...') do
      100000.times do |i| 
        do_a_calculation }
        Wx.get_app.yield if (i % 1000) == 0
      end
    end
  end

but take care to not cause undesirable re-entrance when doing it (see App#yield for more details). The simplest way to do it is to use WindowDisabler class as illustrated in the above example. Note that a BusyInfo is always built with the STAY_ON_TOP window style (see Frame window styles for more info).

Category: Common Dialogs

Requires:

  • USE_BUSYINFO

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.busy(message, parent = nil) {|bi| ... } ⇒ Object .busy(busy_info) {|bi| ... } ⇒ Object

Overloads:

  • .busy(message, parent = nil) {|bi| ... } ⇒ Object

    Shows busy info window with message, blocks event handling and calls the given block passing the BusyInfo instance as argument.

    Parameters:

    • message (String)
    • parent (Wx::Window, nil) (defaults to: nil)

    Yield Parameters:

  • .busy(busy_info) {|bi| ... } ⇒ Object

    Shows busy info window according to busy_info settings, blocks event handling and calls the given block passing the BusyInfo instance as argument.

    Parameters:

    Yield Parameters:



23
# File 'lib/wx/doc/busy_info.rb', line 23

def self.busy(*args) end

Instance Method Details

#update_label(str) ⇒ void

This method returns an undefined value.

Same as #update_text but doesn’t interpret the string as containing markup.

Parameters:

  • str (String)


71
# File 'lib/wx/doc/gen/busy_info.rb', line 71

def update_label(str) end

#update_text(str) ⇒ void

This method returns an undefined value.

Update the information text.

The text string may contain markup as described in Control#set_label_markup.

Parameters:

  • str (String)


66
# File 'lib/wx/doc/gen/busy_info.rb', line 66

def update_text(str) end