Blogging about PHP-GTK

If you are logged in to the site (instead of passing by anonymously) you may have noticed the small, dark, lowercase "b" marks which started appearing today on the "Recent pages", "Community", and "Manual Updates" blocks in the right column of the site.

These are the most visible sign of a new feature on the site: registered members now have their own blog on the site, and blogging about a manual update, community story or recent page is just one click away.

Grabbing a screenshot with Gdk

From Widget to Pixbuf

Need to grab a screenshot in your program? Or maybe you just need to create an image from an existing GtkWidget. There's an easy way to accomplish both tasks using GdkPixbuf::get_from_drawable();

To use the method you'll need two things - an empty GdkPixbuf and the "drawable" (GdkDrawable) associated with your widget. Most widgets will have a GdkWindow located in $widget->window. You can get the entire screen, however, by using Gdk::get_default_root_window();. Now for the code examples...


GtkProgressBar example in fraction modeThis code shows how to use a GtkProgressBar in "fraction" mode, in which the progress bar advances from one side to the other.

It also demonstrates how Pango integration allows the text to be automatically ellipsized to fit within a given rectangle : try resizing the window to see what happens with the text.

Syndikovat obsah