|
The Code Project
The Code Project is a website that contains articles and database project. Code project is also computer programmers with random algorithms and Mega Base. Code project with www.p-world.info reffer to perl
programs. Nearly every article is accompanied with source code and examples which can be downloaded independently. Both are released under the Code Project Open License (CPOL).
Once a visitor has registered a user account on The Code Project, they may write and upload their own articles and code for other visitors to view. The Code Project employs rating and comment system
that helps to filter the good articles from the poor. It also has massive active forums, and is a reasonably good resource for resolving difficult software development issues.
Code Project: monitor /proc with Python and Clutter
If you already read our beginner's guide to the Clutter toolkit and wished it were available in something
other than C, then good news: we're putting together a tutorial series covering PyClutter, the Python binding to Clutter, which merges all the power and beauty of the Clutter toolkit with the simplicity and
brevity of Python.
So, let's start with a simple project to get things going: you're going to produce a network monitor that
monitors data transfer and displays it all on the screen using Clutter. It's nice and easy, but we're going to be adding more
involved PyClutter tutorials in the coming months, so you should get started while the learning curve is shallow!
The first thing you need to get to grips with in Clutter is the basic terminology. Unlike other GUI toolkits, which usually
define objects like windows or panel, Clutter refers to the visual area as a 'stage'. To continue the analogy, objects that
appear on (or actually, in, but it sounds weird to say it) the stage are called 'actors'. It makes more sense when you start
coding it, and the names don't seem so strange after a while. The thing about the actors is that they have more properties than a standard widget because they actually exist in a 3D environment, rather than a 2D one.
What should I care about Clutter?
Clutter is a GPL graphics and GUI library that was originally developed by the OpenedHand team. It was later sold to Intel, which is committed to further development and deployment.
The great thing about Clutter is that it's a simple, fast and powerful way to deliver 3D or 2D graphics on a number of
platforms. The back-end is essentially OpenGL, but by using the Clutter library developers can take advantage of a fast,
efficient and friendly way to develop graphically rich apps without messing around with more technical aspects of the OpenGL libraries.
Clutter also forms an integral part of Moblin, the latest attempt to deliver a lightweight but powerful graphical version of
Linux to run on mobile devices. Moblin is primarily aimed at Intel Atom based devices, although it will run on other hardware.
When you're done, click in the Close gadget on the window that opened. I know it didn't do anything amazing, but it does
have the potential to! Let's take a look at what just happened. The first line obviously loaded the Clutter module. In turn,
Clutter opens a few more modules itself - back-end stuff that links into display libraries to be able to put things on the
screen. Next up we created a stage object. the stage is like a viewport - an area where your actor objects can play.
 |
It's a bit dark in here... could be the promising start of a 3D adventure game, perhaps. Or your first Clutter effort!
Setting the attributes is as simple as calling some methods for the stage class, in this case a size and a colour. The
parameters for the size method are x and y dimensions, and the colour is taken from the clutter.Color object (which takes
values for RGB and alpha). As with other GUI toolkits, we should cause the object to be shown before any of it is drawn on the screen, which is what the final command does.
|