Hi!
Could me tell anyone please, hogy to draw a line on a GTK2.Widget?
I tried the following way: ... win = builder->get_widget("drawingarea"); // A DrawingArea from a glade file gc = GTK2.GdkGC(win); win->set_background(GTK2.GdkColor(255, 0, 0)); // It's ok, the background will be red gc->set_foreground(GTK2.GdkColor(0, 0, 255)); win->draw_line(gc, 1, 1, 100, 100); // No line, but why?
builder->get_widget("mainwindow")->show_now(); ...
Thanks in advance: Thomas Menet közben használható e-mail és egyéb funkciók. Töltse le ingyen a Windows Live Hotmail programot. Regisztráljon most! _________________________________________________________________ Hotmail: Hatékony, ingyenes e-mail szolgáltatás a Microsoft által biztosított védelemmel. https://signup.live.com/signup.aspx?id=60969
You probably need to draw the line _after_ the window is shown. Windows in X normally don't have backingstore, so you need to redraw their contents whenever a previously invisible region becomes visible. I imagine there is some signal you should connect to your draw function to have it called whenever needed.
Yes, you were right, thank you.
The solution was to add a connector and to draw the line after showing the window: ... builder->get_widget("mainwindow")->show_all();
win = builder->get_widget("drawingarea"); // A DrawingArea from a glade file gc = GTK2.GdkGC(win); win->set_background(GTK2.GdkColor(255, 0, 0)); // It's ok, the background will be red gc->set_foreground(GTK2.GdkColor(0, 0, 255)); win->signal_connect("expose-event", lambda() { win->draw_line(gc, 1, 1, 100, 100); // It draws a blue line :) :) :) }); ...
Cheers: Thomas
From: 10353@lyskom.lysator.liu.se Subject: GTK2 DrawingArea question To: pike-devel@lists.lysator.liu.se Date: Sun, 2 May 2010 16:15:03 +0000
You probably need to draw the line _after_ the window is shown. Windows in X normally don't have backingstore, so you need to redraw their contents whenever a previously invisible region becomes visible. I imagine there is some signal you should connect to your draw function to have it called whenever needed.
_________________________________________________________________ Menet közben használható e-mail és egyéb funkciók. Töltse le ingyen a Windows Live Hotmail programot. https://signup.live.com/signup.aspx?id=60969
pike-devel@lists.lysator.liu.se