Re: pygtk - What is the best way to change the mouse pointer

Discussion in 'Python' started by MRAB, Aug 26, 2009.

  1. MRAB

    MRAB Guest

    Ido Levy wrote:
    > Hello All,
    >
    > I am writing a dialog which one of its widget is a gtk.ComboBoxEntry (
    > let's assume widget in the example below is its instance )
    > When the user select one of the values from the gtk.ComboBoxEntry I need
    > to run some calculations that takes a few seconds.
    > In order to reflect calculation time to the user I want to switch the
    > mouse pointer to an hour glass and back to arrow what it finish the
    > calculation.
    >
    > I use the following code but it doesn't seems to work in a deterministic
    > way. From time to time it skips the last line and keep the mouse pointer
    > as an hour glass.
    >
    > watch = gtk.gdk.Cursor(gtk.gdk.WATCH)
    > widget.window.set_cursor(watch)
    >
    > calculation code
    >
    > widget.window.set_cursor(None)
    >
    > I would appreciate your advice on the right way to implement this.
    >

    Could the calculation code be raising an exception? Try adding some
    logging to see whether the last lien is actually being called. You could
    also use a try...finally... block to ensure that the last line is
    called:

    watch = gtk.gdk.Cursor(gtk.gdk.WATCH)
    widget.window.set_cursor(watch)
    try:
    calculation code
    finally:
    widget.window.set_cursor(None)
    MRAB, Aug 26, 2009
    #1
    1. Advertising

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. Oscar

    Change mouse pointer

    Oscar, Apr 15, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    3,301
    Andrew L. Van Slaars
    Apr 15, 2005
  2. Replies:
    9
    Views:
    2,601
  3. samiam@boston

    How do I change mouse pointer with DropDownList control?

    samiam@boston, Jun 30, 2005, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    257
    samiam@boston
    Jun 30, 2005
  4. Paulo Carvalho

    Change mouse pointer

    Paulo Carvalho, Oct 16, 2007, in forum: Ruby
    Replies:
    0
    Views:
    120
    Paulo Carvalho
    Oct 16, 2007
  5. Stefan Mueller
    Replies:
    0
    Views:
    371
    Stefan Mueller
    Jan 28, 2006
Loading...

Share This Page