(py)Gtk provides a quick way to get a cairo context using the gtk.DrawingArea widget, this widget let you draw everythin you want into your application using the widget.window drawable area.
It help you to create custom widgets (you can also use this with buttons or any other widget), the problem with the usage of this context is that everything you ask it to draw it will draw it as soon as it can.
If you draw several lines or you draw the same thing very often (an animation for example) your draw may flick, making your application looks ugly.
There is an easy way to avoid this, using a surface to draw and when you are done put your draw into the context using the set_source_surface method.
In the next example you have a windows, with a custom "progressbar" using gtk.DrawingArea and a slide that is supposed to change the value of the progressbar but I'm so lazy to move a slide that let the computer do the work :-).
We create a surface using cairo.ImageSurface and then create a cairo context from it, draw on that context and at the end use the widget.window.cairo_create to create a context for the drawing_area and use set_source_surface to get all the stuff
we drew into the DrawingArea context. At the en just paint it.
This time I'm going to talk about putting an image as the application background in Gtk. In Gtk we are used to leave the colors of the application to the theme, but sometimes we will need to use an image as background. I already wrote how to draw a pixbuf in a gtk.DrawingArea (Esp), we could use that, but we will "draw" directly on the widget window instead.
Yes, I said the widget's window instead the widget itself. You should know that every widget that has been packed in a container has a gtk.gdk.window object and is the responsible for containing your widget. Well, we can draw on that object.
What we need is to create a simple gtk.gdk.Pixbuf and call the gtk.gdk.window.draw_pixbuf method using your widget.window object on the expose-event.
It is just a window with an HBoxButton as container and a Button in the middle. The button draws normal, but the HButtonBox is drawing its gtk.gdk.window with a pixbuf.
Finally!!!, Christine, my beloved media player is running on Windows, this is something that I really wanted to do for the next release. I had spend the last nights trying to compile it, first I tried to compile GStreamer, then I realized that there are binaries in the GStreamer WinBuilds project, with a little less work, I tried to compile Christine using cygwin, but it didn't worked. Then using the Python's distutils I compiled the C modules and I created a binary with Py2exe
There it is, running. I still have a lot of work to do, because Christine is written for UNIX and several technologies like Dbus are not in win32, although it seems to be in progress.
I'm running it on a virtual machine and I haven't tested if it really plays something, I'll give a try tomorrow.
Last night I was trying to compile christine on windows using cygwin, I didn't made it but I think I know why, I will try to make it work this tonight.
I was playing with gstreamer video sinks, I found that using cacasink and aasink you can play videos in ascii mode ;-) funny even when (for me) has no good use.
Tonight I have been working on the display widget. That part of christine that displays the title and lenght of the song you are playing. I have set up a background to make it look less simple.
I also put the control buttons, the volume control and the search entry (which is hided in this screenshot) in a toolbar.
What do you think about this small changes?
Christine is a small and functional media player written in Python using PyGtk as GUI toolkit and Gstreamer as backend.
It supports all the media files that your gstreamer installation can support, being MP3, OGG, AVI, MPG. It saves the URIs and Meta tags in a database and let you browse them quickly.
Christine also provides early support for Radio Stations and have its own DBus interface which let you control christine with your media keyboard buttons as they are configured on GNOME.
The early access to Plugins will let you tweet the music you are listening to, put it on your pidgin status and use notifications while you change your current song.
Bug fix release
Several bugs have been fixed, you can find the bug list and release notes here
Recent Comments On Blog
Marco Antonio Islas Cruz on
Marco Antonio Islas Cruz on
Marco Antonio Islas Cruz on
Getting ready
Marco Antonio Islas Cruz on
Python: Create win32 services using Python and py2exe
jopython@gmail.com on
Python: Create win32 services using Python and py2exe
yodenuevo on
Holy Shit!
markuz on
Holy Shit!
yo on
Holy Shit!
Gustavo on
Things that happen last week
Marco Antonio Islas Cruz on
Christine: rola_christine.py