Code Project: build a PyGTK language translator

Code

Once you understand the basics of PyGTK, you can make some neat apps just by drawing upon some of the incredible APIs that are available from well-known companies such as Facebook, Twitter and Yahoo. In this video tutorial you'll learn how to work with Google's Translate API, which can translate a huge range of languages on the fly, then back up your knowledge with a simple PyGTK user interface that puts a pretty face on it all.

Code Project: build a PyGTK RSS reader

Code

As we saw in part one of this video series, Python makes it easy to create GTK apps. Well, it turns out that Python also makes it easy to read XML from the web, which means we can make something like an RSS reader in no time at all. In this video tutorial you'll learn how to work with XML, using RSS as an example, while also learning how GTK handles data in multi-line text fields and combo boxes.

This tutorial is dedicated to Evan, who donated at least $50 to support free software - if you want to see more video tutorials like this one, all you have to do is donate to support the Libre Graphics Meeting. Easy!

Python + PyGTK + WebKit in 20 minutes

Code

In season 2 episode 7 of our podcast we laid down the simple challenge for each of the four podcasters - Andrew, Graham, Paul and Mike - to produce something original for the website. Paul - eager to show the world how much he, er, loves Python - has now finished his entry, and you'll find it below: a video talking you through how to get started with Python, PyGTK and WebKit. It's easier than you think!

Code Project: create an animated RSS reader with Clutter

Code

In a previous tutorial we had a look at the basics of Clutter as we used it to build a network speed monitor. This time we'll be looking at some of the very powerful animation techniques used in Clutter, how to group objects, and a little more about text actors. We will be doing this in the guise of implementing a feed reader. There isn't enough space for us to implement a complete multi-stream reader and explore the animations, but we will be covering enough ground to get you started on building such a beast, including fetching the data from the feed and applying it to the Clutter objects.

For those of you who haven't been tempted by one of these magnificent Python tutorials before, we usually try to do as much as possible in the interactive mode of Python first. It is a kinder, gentler environment than the normal mode in which programs are run, as you can type things in and experiment. The code listings in these cases include the Python prompt >>> at the beginning of the line when you have something to type in, and without it when the environment is giving you some feedback, just as it appears on screen.

(NB: don't miss our collection of free Python tutorials, and you can also try your hand at our Clutter beginners tutorial for C programmers if you're feeling adventurous!)

Code Project: monitor /proc with Python and Clutter

Code

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!

Code Project: upload pictures to Flickr with Python

Code

Python is a great way to make apps quickly, and what better source of data is there than the world wide web? We've already shown you how to control Digg with Python and how to create a Twitter bot in Python, and now we turn our beady eyes towards Flickr, the home of more cat photos than I Can Haz Cheezburger knows what to do with. If you want to try your hand at uploading photos to Flickr, while learning just a smidge of PyGTK along the way, this project is for you.

If you're desperate for even more things to code, don't forget our complete code projects archive is waiting for you...

Code Project: control Digg with Python

Code

Everyone knows that Digg is a hugely popular social news website where like-minded folks gather and flame each other to death. But if you're a Digg user and want to flex your coding skills to get a little more from the site, we've got the perfect code project for you: we're going to show you how to write a Python app to read Digg submissions and geo-locate them using GeoIP.

You should know that, even though there's a perfectly reasonable - if slightly out of date - API for Digg, we're going to create our own miniature one instead that does just what we need. If you want to go further you'll find this an easy place to start, and it also gives you some good practice in working with XML.

Make a Python game in minutes with Gloss

Code

When Hudzilla isn't busy working on his free Mono tutorials using C#, he likes to hack on one of his pet Python projects: Gloss. It's hosted right here on TuxRadar and you may already have given it a try. If not, he wrote a short tutorial for PC Plus magazine a few months ago, and took the time to repurpose it for the web.

So, if you fancy learning the fastest way to create Python games, read on as Hudzilla talks you through an example Gloss project...

Code Project: create a Qt RSS reader

Code

We're going to build a complete application that wouldn't take too much additional work to qualify for re-distribution as a bona fide open source application. It's an RSS reader which allows you to add your own feeds, lists the stories on that feed and then lets you read those stories within a browser window attached to the main application.

If you already tried our previous two Qt code projects - Create an ffmpeg front end and Create a media player - and are looking for more Qt fun, read on...

Code project: create a Python Twitter bot

Code

Once upon a time, there was a person who decided that people needed more distractions in their lives, so he created Twitter. This may not be exactly how they tell the story at Twitter HQ, but that's probably because it would create a less than glamorous image (oh, and it's also wildly inaccurate). After all, Twitter is pretty much constantly in the news. If you want to catch up with where in the world Stephen Fry is now, what everybody in North America had for lunch or precisely how smugly great Jonathan Ross thinks he is today, there's really only one place to turn.

Amazingly, Twitter can be put to useful things as well. As it happens, Twitter's application programming interface (API) is particularly convoluted - it seems to have evolved by using many different ways of doing various things. That needn't worry us, though, because there are plenty of API wrappers for Python. The one that's most suited for us is the standard Python-Twitter, which is available through most repositories and also at http://code.google.com/p/python-twitter.

Code Project: create an ffmpeg front-end

Code

There's nothing wrong with the command-line. For many of us, it's one of the best reasons for using Linux. You can accomplish almost anything by typing things out, and command-line tools will often provide an unprecedented degree of control over how they can be run. But the command-line isn't for everyone, and there there's a surprising number of Linux users who find it unfathomable and intimidating, perhaps even a reason to avoid the Linux completely. And while it's true that you no longer have to use the command-line if you don't want to, it still means that you're missing out on some great utilities.

And this is where Qt can save the day. It's the perfect tool for creating a warm and fuzzy GUI around your favourite command-line tools. It doesn't require any ace programming skills, and only a little bit of effort, but in the process you can help your command loathing friends and make your own contribution to open source application development. Creating GUIs for command line tools is one of the best ways of getting started!

If you already finished our previous Qt Creator code project, how to create your own media player, you're more than ready to tackle this...

Code Project: create a media player

Code

Amarok is a great music player for KDE when judged by both its capabilities and its size. But it's hardly a quick point and click music player - it takes several clicks and some careful GUI navigation to listen to your music collection and that takes a toll on both your CPU and your head. We're going to offer an alternative by building the most simple and straightforward music player we could think of.

We're going to take some inspiration from Apple's new iPod Shuffle, and only offer the bare minimum of controls. One button for selecting your music, another button for play and pause, and a third button for skipping to the next track. For most people, and most uses, these are the only controls you need, and it makes a refreshing contrast to the bloated frippery of players like Amarok.

Code Project: Tower of Hanoi in Python

Code

If you've already followed our previous code projects and are using the weather for wallpaper, enjoying talking RSS feeds, running your own Ruby-powered web server and chatting to your own IRC bot, here's something new to try: we're going to show you how to make a Tower of Hanoi game using Python.

Code Project: Use weather for wallpapers

Code

Not all information on the web is static, connected in a meaningful way, or even as cool as it should be. Which is why one of the post-web 2.0 movements of note is the mashup - the repurposing of data from the web into new and exciting forms. Welcome to the world of data punk.

Code Project: Build an Ncurses UI with Python

Code

Picture the scene: you're logged into a remote server via SSH, or you've installed a new graphics card and you're left staring at the command line. You need to enter a command, but you can't remember the zillion options that go along with it. You're stuck - all you can do is consult the manual pages and pore through pages of waffling technical gobbledygook. We've all been there, and no matter how experienced you are with Linux, sometimes you need to accomplish a job quickly without sifting through masses of reading material.

In this coding project, we're going to solve this problem - and have fun along the way! We'll show you how to write a dialog-based program that gives you options one-by-one so that you don't need to consult the man pages. In this guide, we'll show you how to write a nifty front-end for the useradd utility, a command which (unsurprisingly) lets you add user accounts to your Linux installation. Like many administration tools, useradd requires a long string of options and parameters; we're going to make it much simpler by creating an interactive dialog-driven version called UserMaster.

Code Project: Make talking RSS feeds

Code

On the face of it, writing a script/program to download and parse an RSS feed, and from there send news items to a speech synthesizer, sounds ambitious - even for TuxRadar. But as it turns out, it's actually rather straightforward.

Principally, this is thanks to three technologies, Python, Festival and Linux. Python, the world-dominating scripting language par-excellence makes it easy to construct a script without too much thought or effort. The open source Festival Speech Synthesis System sounds fantastic, and can be installed with just a couple of clicks from your distribution's package manager. And Linux itself; without its powerful pipes and process scheduling, we'd have to spend a lot more time writing that functionality into our program, and we'd also need to add a GUI to make it all easily accessible.

Luckily, all we need to do is write a small Python script and use a little command line magic to tie all these things together. We're going to write a simple script in Python that will output plain text news stories than can then be piped into Festival, which will then speak the news through your speaker or headphones. This gives you maximum flexibility. This two-pronged approach (Python script piped to Festival) can be modified to suit almost any purpose. In less than an hour, you'll be able to sit back and listen to the dulcet tones of a female voice synthesizer reading the latest happenings from TuxRadar.com.

Code Project: Build a mouse game with Python

Code

Most modern games take thousands of man-hours to create, not to mention an army of artists and musicians, but there's still some scope for solitary hacker to write something entertaining. After all, it didn't take a team of 500 coders and a Hollywood movie-set budget to create Tetris - Alexey Pajitnov managed pretty well on his own (until various filthy capitalist running-dogs of the West ran off with his idea, of course...)

In this tutorial, you're going to learn how to make a really simple mouse game with Python. If this is the first coding tutorial you've read - and you've certainly never written a line of Python code before - you'll be pleasantly surprised by how easy it is to understand; Python code is famous throughout the programming world for being very much self-explanatory.

Code Project: Create a web server in Ruby

Code

Most of us are aware of Ruby through its modern-day Ruby on Rails incarnation, which is a framework for developing large-scale websites. This has been used on talked-about websites such as the Basecamp, Jobster and 43 Things sites and is shipped with the latest version of OS X, Leopard.

Given Ruby's very recent step into the coding limelight, it's surprising how long the language has been in development: since 1993! Created by Yukihiro Matsumoto, Ruby was first released to the world in 1995, and was designed to reduce the menial work that programmers typically have to put in. Why should we have to battle with the syntax of a language when what we want to achieve is really very simple?

Code Project: Build a flash card app

Code

In this coding project, we're going to create a flash card program to help you remember foreign words. It displays an English word and asks you to choose its German equivalent from a list of three randomly chosen options, keeping a score as you progress.

But it's not just limited to German – you'll be able to use it for any language, or indeed for anything else you want to learn! You could even set it up to display the name of an animal, having the program test you on its species.

Username:   Password: