Refreshing GUI and Progressbar

Discussion in 'Ruby' started by Michael Gebhart, Apr 11, 2005.

  1. Hi,

    I am programming an application with ruby-gnome. My application is
    downloading some data and I wanna display a download-dialog, while the
    downloading is running. So I created a GUI, the download-dialog. This
    dialog should be displayed, when the download begins. A progressbar shows
    the current download-state. Now my problem is, that the GUI is not really
    refreshed. At my first try the download-dialog became displayed, when the
    download was finished *g* Now I added a:

    begin
    Gtk.main_iteration
    end while(Gtk.events_pending?)


    every time a part of the gui changes. This let the download-dialog
    display, when the download starts. But it does not really work as I wish.
    The progressbar becomes not refreshed in the way I hope. Maybe I did
    something wrong:

    If I wanna download 50 elements I wanna go the progressbar one step
    further, when one element is downloaded.

    So: count = 50

    Then I do:

    progressbar_download.pulse_step = (1 / count)

    And every time an element is downloaded I do a:

    progressbar_download.pulse

    Is this correct? Or did I understand something wrong?


    The progressbar becomes displayed and the first steps work, then it does
    not change, or maybe it only does not refresh. Maybe you have some hints
    for me.

    Greetings

    Mike
     
    Michael Gebhart, Apr 11, 2005
    #1
    1. Advertisements

  2. Phlip

    Phlip Guest

    Michael Gebhart wrote:

    > begin
    > Gtk.main_iteration
    > end while(Gtk.events_pending?)


    > And every time an element is downloaded I do a:
    >
    > progressbar_download.pulse
    >
    > Is this correct? Or did I understand something wrong?


    You might try this question on a Gtk+ mailing list.

    The utterly generic advise is to start a window timer, and set it to a short
    or 0 duration. In it, pump one main_iteration and one progress bar update.

    --
    Phlip
    http://industrialxp.org/community/bin/view/Main/TestFirstUserInterfaces
     
    Phlip, Apr 11, 2005
    #2
    1. Advertisements

  3. Hi,

    On Apr 11, 2005 4:19 AM, Michael Gebhart <> wrote:

    > I am programming an application with ruby-gnome. My application is
    > downloading some data and I wanna display a download-dialog, while the
    > downloading is running. So I created a GUI, the download-dialog. This
    > dialog should be displayed, when the download begins. A progressbar shows
    > the current download-state. Now my problem is, that the GUI is not really
    > refreshed. At my first try the download-dialog became displayed, when the


    (you should use ruby-gnome2-devel-en mailing-list)

    Ruby threads, being entirely in the interpreter, are in my opinion a
    particularly elegant solution for the problem of refreshing a gtk2
    application performing intensive tasks (gtk will never even see that
    multiple "threads" are executing). Check the following short example.

    -=-=-=---=-=-=---=-=-=---=-=-=---=-=-=---=-=-=--
    require 'gtk2'

    Gtk.init

    v = Gtk::VBox.new
    v.add(l = Gtk::Label.new('ready'))
    v.add(b = Gtk::Button.new('start'))
    w = Gtk::Window.new.add(v).show_all

    b.signal_connect('clicked') {
    Thread.new {
    1.upto(4) { |i|
    l.label = "downloading part #{i}"
    sleep 2
    }
    l.label = 'ready'
    }
    }

    Gtk.main
    -=-=-=---=-=-=---=-=-=---=-=-=---=-=-=---=-=-=--

    --
    Guillaume Cottenceau - http://zarb.org/~gc/
     
    Guillaume Cottenceau, Apr 11, 2005
    #3
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Maka Sili
    Replies:
    0
    Views:
    664
    Maka Sili
    Aug 25, 2004
  2. Nilton Volpato
    Replies:
    0
    Views:
    512
    Nilton Volpato
    May 8, 2006
  3. Nilton Volpato
    Replies:
    0
    Views:
    599
    Nilton Volpato
    May 7, 2006
  4. Harlan Messinger

    Self-refreshing and non-self-refreshing controls

    Harlan Messinger, Aug 4, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    631
    =?Utf-8?B?Y2xpY2tvbg==?=
    Aug 4, 2006
  5. crazytazo

    HTTPClient and Progressbar.

    crazytazo, Nov 11, 2008, in forum: Java
    Replies:
    5
    Views:
    3,622
    Roedy Green
    Nov 19, 2008
  6. OMS
    Replies:
    2
    Views:
    6,459
  7. Harlan Messinger

    Self-refreshing and non-self-refreshing controls

    Harlan Messinger, Aug 3, 2006, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    337
    Harlan Messinger
    Aug 3, 2006
  8. Hal Fulton

    GUI and non-GUI data

    Hal Fulton, Aug 5, 2004, in forum: Ruby
    Replies:
    1
    Views:
    277
    Austin Ziegler
    Aug 5, 2004
Loading...