[fxruby-users] Timer control

3 views
Skip to first unread message

dave L

unread,
Nov 2, 2009, 2:51:01 AM11/2/09
to fxruby
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.

Joey Kinsella

unread,
Dec 2, 2009, 12:46:59 PM12/2/09
to fxruby...@rubyforge.org
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

_______________________________________________
fxruby-users mailing list
fxruby...@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.

dave L

unread,
Dec 3, 2009, 11:23:03 PM12/3/09
to fxruby...@rubyforge.org
@Joey,

Many thanks for the help.

I ended up looking at some sample source code and was able to butcher that to get me going.

REALLY appreciate your time as this list is low volume (and i am using foxGUIb) for the screen and window control display which has helped me visualise placement.

again many thanks for the time.

dave.


--- On Thu, 3/12/09, Joey Kinsella <jkin...@ancillaryservices.com> wrote:

> -----Inline Attachment Follows-----

Reply all
Reply to author
Forward
0 new messages