Re: gtk_widget_show_all() is not enough to show data plots
"Adrian E. Feiguin" <[email protected]> Fri, 09 Sep 2005 14:25:42 -0700
| Newsgroups | gmane.comp.scigraphica.gtkextra |
|---|---|
| Message-ID | <[email protected]> |
Oi Romildo Definitely a bug. Checkout the new CVS version. Obrigado! Saludos, <ADRIAN> [email protected] wrote: >Hello. > >I am learning gtk+extra-2, and came to the following >issue: > >If I use gtk_show_all(window), where window is the >top level window of the application, to enable >showing the window and all its components, a dataset >is not drawn. > >To test this I used the attached C program. The >dataset is not plot if lines 53 and 68 are >commented out. > >Is this a bug? > >Romildo > >--------------------- >WEBMAIL UBER INTERNET > > >------------------------------------------------------------------------ > >/* plot.c */ > >#include <gtk/gtk.h> >#include <gtkextra/gtkplot.h> >#include <gtkextra/gtkplotcanvas.h> >#include <gtkextra/gtkplotcanvasplot.h> >#include <gtkextra/gtkplotdata.h> > >#include <math.h> > >#define NPOINTS 20 > >int main(int argc, char *argv[]) >{ > GtkWidget *window; > GtkWidget *canvas; > GtkPlot *plot; > GtkPlotData *dataset; > GtkPlotCanvasChild *child; > > gdouble px[NPOINTS]; > gdouble py[NPOINTS]; > > gint i; > > gtk_init(&argc, &argv); > > /* main window */ > window = gtk_window_new(GTK_WINDOW_TOPLEVEL); > gtk_window_set_title(GTK_WINDOW(window), "Plot"); > gtk_container_border_width(GTK_CONTAINER(window), 8); > g_signal_connect(GTK_OBJECT(window), "destroy", G_CALLBACK(gtk_main_quit), NULL); > > /* canvas */ > canvas = gtk_plot_canvas_new(400, 300, 1.0); > GTK_PLOT_CANVAS_UNSET_FLAGS(GTK_PLOT_CANVAS(canvas), GTK_PLOT_CANVAS_DND_FLAGS); > gtk_container_add(GTK_CONTAINER(window), canvas); > > /* plot */ > plot = GTK_PLOT(gtk_plot_new(NULL)); > gtk_plot_set_range(plot, 0, 2*M_PI, -10, 10); > gtk_plot_set_ticks(plot, GTK_PLOT_AXIS_X, 1, 4); > gtk_plot_set_ticks(plot, GTK_PLOT_AXIS_Y, 5, 4); > gtk_plot_axis_hide_title(gtk_plot_get_axis(plot, GTK_PLOT_AXIS_TOP)); > gtk_plot_axis_hide_title(gtk_plot_get_axis(plot, GTK_PLOT_AXIS_RIGHT)); > gtk_plot_axis_set_title(gtk_plot_get_axis(plot, GTK_PLOT_AXIS_BOTTOM), "x"); > gtk_plot_axis_set_title(gtk_plot_get_axis(plot, GTK_PLOT_AXIS_LEFT), "sin(x)"); > gtk_plot_hide_legends(plot); > > /* canvas plot */ > child = gtk_plot_canvas_plot_new(plot); > gtk_plot_canvas_put_child(GTK_PLOT_CANVAS(canvas), child, 0.15, 0.15, 0.85, 0.85); > gtk_widget_show(GTK_WIDGET(plot)); > > /* plot dataset */ > for (i = 0; i < NPOINTS; i++) > { > const gdouble x = i * (2*M_PI) / NPOINTS; > px[i] = x; > py[i] = 10.0 * sin(x); > /* g_printf("%i x = %f y = %f\n", i, px[i], py[i]); */ > } > > dataset = GTK_PLOT_DATA(gtk_plot_data_new()); > gtk_plot_add_data(plot, dataset); > gtk_plot_data_set_points(dataset, px, py, NULL, NULL, NPOINTS); > gtk_plot_data_draw_points(dataset, NPOINTS); > gtk_widget_show(GTK_WIDGET(dataset)); > > gtk_plot_canvas_paint(GTK_PLOT_CANVAS(canvas)); > gtk_plot_canvas_refresh(GTK_PLOT_CANVAS(canvas)); > > gtk_widget_show_all(window); > > gtk_main(); > > return 0; >} > > ------------------------------------------------------- SF.Net email is Sponsored by the Better Software Conference & EXPO September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf