[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]
Re: 答复: A question about GTK Scale
- From: "Alvis Koon" <alviskoon gmail com>
- To: "Ke Jin" <jinkea gmail com>
- Cc: gtk-app-devel-list gnome org
- Subject: Re: 答复: A question about GTK Scale
- Date: Thu, 17 Apr 2008 21:42:03 +0800
Hi,
No, you should not use closed loop for GTK application when you expect
responses.
Use gtk timeout mechanism instead of the dead while loop with sleep.
Try that, I am quite sure that would help.
Yours faithfully,
Alvis Koon
On 16/04/2008, Ke Jin <jinkea gmail com> wrote:
> The problem is solved. Thanks!
>
> But it is still a little strange that I have tried the
> while(gtk_events_pending()) gtk_main_iteration(); before which didn't work.
> But after I changed:
> slider = gtk_vscale_new_with_range(0,1000,0.1);
> to
> GtkObject *adj1;
> adj1 = gtk_adjustment_new (0.0, 0.0, 1001, 0.1, 1.0, 1.0);
> slider = gtk_vscale_new (GTK_ADJUSTMENT (adj1));
>
> it did work.
>
> Any idea why?
>
>
> -----邮件原件-----
> 发件人: Christopher Backhouse [mailto:cjbackhouse gmail com]
> 发送时间: 2008年4月16日 9:40
> 收件人: Ke Jin
> 抄送: gtk-app-devel-list gnome org
> 主题: Re: A question about GTK Scale
>
>
> Perhaps it takes 2 iterations of the main loop for the vscale to update.
> What happens if you try
> while(gtk_events_pending()) gtk_main_iteration();
> instead?
>
> Ke Jin wrote:
> > Dear All,
> > I have a VScale in my interface and I created button named "Play" that
> > once the button is clicked, the scale will move automatically.
> >
> > Below is the function connected to the button. And it performed strangely.
> > The scale was not updated every iteration of the loop, which means the
> value
> > of the scale changed from 0 to 2 then to 4 then 6....and jumped over
> > 1,3,5...
> >
> > Does anyone have any idea why this happened?
> >
> > void playClick(GtkWidget *widget, VScale *slider)
> > {
> > double interval = 1;
> > double currentTime = gtk_range_get_value((GtkRange*)(slider));
> >
> >
> > while(currentTime<=20)
> > {
> > currentTime += interval;
> > usleep(1000000);
> > printf("current Time: %f\n",currentTime);
> > gtk_range_set_value((GtkRange*)(gtkE->slider),currentTime);
> > gtk_main_iteration();
> > }
> > }
> >
> > Many Thanks,
> > Ke
> >
> > _______________________________________________
> > gtk-app-devel-list mailing list
> > gtk-app-devel-list gnome org
> > http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
> >
>
> _______________________________________________
> gtk-app-devel-list mailing list
> gtk-app-devel-list gnome org
> http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]