[fxruby-users] Timer control

Joey Kinsella jkinsella at ancillaryservices.com
Wed Dec 2 12:46:59 EST 2009


Simple, hope this helps...

class ProgressDlg < FXMainWindow
  def initialize(app, caption, text)
    @app = app
    super(@app, caption, :opts => DECOR_NONE, :width => 520, :height => 40)

    FXLabel.new(self, text, :opts => LAYOUT_FILL_X | JUSTIFY_CENTER_X)
    @bar = FXProgressBar.new(self, :opts => PROGRESSBAR_NORMAL |
LAYOUT_FILL_X)
  end

  def create
    super
    show(PLACEMENT_SCREEN)
  end

  def run(limit = 100)
    @bar.setTotal(limit)
    @bar.setProgress(0)

    @app.addTimeout(1000, method(:progress_update))
  end

  def progress_update(sender, selector, data)
    @bar.increment(1)

    if @bar.progress == @bar.total
      self.close(true)
    else
      @app.addTimeout(1000, method(:progress_update))
    end
  end
end

On Mon, Nov 2, 2009 at 2:51 AM, dave L <dglnz at yahoo.com> wrote:

> Was wondering if anyone could via small piece of code show how a timer is
> envoked.
>
> Sometimes (at least for me) a worked sample (with some documentation) is
> better than having something explained in words.
>
> I would be grateful,
>
> Dave
>
>
>
> Email slow, clunky, unreliable? Switch to Yahoo!Xtra Mail, New Zealand's
> new email address.
>
> _______________________________________________
> fxruby-users mailing list
> fxruby-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/fxruby-users
>

--
If you are not the intended recipient, you are hereby notified
that any dissemination, distribution, copying or other use of
this communication is strictly prohibited.  If you have
received this communication in error, please notify us
immediately.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/fxruby-users/attachments/20091202/b2c90c30/attachment.html>


More information about the fxruby-users mailing list