Marco Islas Blog




gtk

  • Christine 0.6.1

    I just want to let you know that Christine 0.6.1 is in the net now You can download the sources from here: Binary Packages
  • Drawing with Cairo without flicker

    (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 :-).

    The trick is this part of the code:

            def do_expose(self, widget, event):
                    x,y,w,h = self.allocation
                    surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, w,h)
                    context = cairo.Context(surface)
                    #cleaning
                    rectangle = context.rectangle(x,y,w,h)
                    context.set_source_rgb(1,1,1)
                    context.fill()
                    value = (self.value / 100)*w
                    rectangle = context.rectangle(x,y,value,h)
                    context.set_source_rgb(0.2,0.5,0.8)
                    context.fill()
                    cr = self.window.cairo_create()
                    cr.set_source_surface(surface)
                    cr.paint()
                    return True
     

    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.




    Read More...
  • Image as background in a Gtk Application.

    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.

    The code should look like this:

    #!/usr/bin/env python
    import gtk
    def draw_pixbuf(widget, event):
            path = '/home/markuz/wallpapers/WMwall1024x768.gif'
            pixbuf = gtk.gdk.pixbuf_new_from_file(path)
            widget.window.draw_pixbuf(widget.style.bg_gc[gtk.STATE_NORMAL], pixbuf, 0, 0, 0,0)
    window = gtk.Window()
    window.set_title('Drawing Test')
    window.set_size_request(640,480)
    window.connect('destroy',gtk.main_quit)
    hbbox = gtk.HButtonBox()
    window.add(hbbox)
    hbbox.connect('expose-event', draw_pixbuf)
    button = gtk.Button('Press Me!')
    hbbox.pack_start(button, True, False, 10)
    window.show_all()
    gtk.main()
     
    And the result should be like this:

    Putting an image as background in Gtk

    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.
  • Christine running on MS Win32



    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.

    For tonight I'm happy :-)

    Some shots:

    Christine running on Win32 Christine running on Win32Coding Christine
  • Trying to compile christine on Windows




    Trying to

    Originally uploaded by markuz



    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.

  • Christine playing videos




    Christine playing videos

    Originally uploaded by markuz



    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.

  • Christine small mode




    Christine small mode

    Originally uploaded by markuz



    This is Christine in small mode (Ctrl+d).

  • Developing Christine




    Christine

    Originally uploaded by markuz




  • Working on Christine




    Christine

    Originally uploaded by markuz



    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 0.5.1 released!

    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

    Download

    Download Sources

Previous page 1 2 3 4 ... 10 Next page
91 entries




twitter logo




Recent Comments On Blog

avatar
Marco Antonio Islas Cruz on
 
avatar
Marco Antonio Islas Cruz on
 
avatar
Marco Antonio Islas Cruz on
 Getting ready
avatar
Marco Antonio Islas Cruz on
 Python: Create win32 services using Python and py2exe
avatar
jopython@gmail.com on
 Python: Create win32 services using Python and py2exe
avatar
yodenuevo on
 Holy Shit!
avatar
markuz on
 Holy Shit!
avatar
yo on
 Holy Shit!
avatar
Gustavo on
 Things that happen last week
avatar
Marco Antonio Islas Cruz on
 Christine: rola_christine.py