Re: I cannnot update progressbar..
- From: Naoko Shimakawa <simakawa ssd sony co jp>
- To: Andreas Scherf <scherfa fh-trier de>
- Cc: "gtk-list gnome org" <gtk-list gnome org>
- Subject: Re: I cannnot update progressbar..
- Date: Wed, 10 Jan 2001 10:54:46 +0900
Hi!
Thank you Mr.Scherf !!
I can update my progress bar!!!
Thank you very much!
My mistake is here.
> while (gtk_events_pending ())
> gtk_main_iteration ();
The FAQ wrote:
while( gtk_main_iteration() );
But it doesn't go.
I don't know why.
Thank you so much !(^-^)
Andreas Scherf <scherfa fh-trier de> wrote:
> Naoko Shimakawa wrote:
> >
> > Hello.
> > I was starting gtk 2weeks ago so I'm beginer.
> > And I'm sorry my poor English.
> >
> > I'm trying updating progressbar. But it is not success.
> > FAQ says "use while( gtk_main_iteration() );".
> > I try it and I read archives of mailing list.
> > But I cannot find my mistake.
> >
> > Please teach me something wrong...
> > Calling this function, the dialog is appeared.
> > But label and progress bar show after for loop finished.
> >
> > -----------------------------------------------------------------
> > void progressbar_test()
> > {
> > GtkWidget *dlg;
> > GtkWidget *vbox;
> > GtkWidget *lbl;
> > GtkWidget *pbar;
> > int val;
> > gfloat gflt;
> > char buf[MAX_BUF];
> >
> > //create dlg
> > dlg = gtk_dialog_new();
> > gtk_window_set_title( GTK_WINDOW( dlg ), "ProgressBar" );
> > gtk_widget_set_usize( dlg, 200, 100 );
> > vbox = GTK_DIALOG( dlg )->vbox;
> >
> > //create lbl
> > lbl = gtk_label_new( "progressbar!" );
> > gtk_box_pack_start( GTK_BOX(vbox), lbl, TRUE, TRUE, 1 );
> > gtk_widget_show( lbl );
> >
> > //progress bar
> > pbar = gtk_progress_bar_new();
> > gtk_box_pack_start( GTK_BOX( GTK_DIALOG( dlg )->action_area ),
> > pbar, TRUE, TRUE, 2 );
> > gtk_progress_set_format_string( GTK_PROGRESS( pbar ), "%p%%" );
> > gtk_widget_show( pbar );
> >
> > //show dialog
> > gdk_threads_enter();
> > gtk_widget_show( dlg );
> > gdk_threads_leave();
> >
> > //update progress bar
> > for( gflt=0; gflt<=1; ){
> > gtk_progress_bar_update( (GtkProgressBar*)pbar, gflt );
> > gflt += 0.1;
> > sleep(1);
> > if ( gflt > 1 ) break;
> > //update?
> > while( gtk_main_iteration() );
> It must be (for example):
> gtk_progress_set_value (GTK_PROGRESS (progressbar), progress_adj);
> while (gtk_events_pending ())
> gtk_main_iteration ();
Here changed.
//update progress bar
for( gflt=0; gflt<=1; ){
gtk_progress_bar_update( (GtkProgressBar*)pbar, gflt );
//update
while (gtk_events_pending ())
gtk_main_iteration ();
gflt += 0.1;
sleep(1);
if ( gflt > 1 ) break;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]