Getting Started

Here are the tools we’re going to use in this tutorial:

I’m not going into details about how to install these tools, but I am going to tell you how to configure them.

There are a lot of IDEs out there that support Python, but for this tutorial I’m going to use my personal favorite, Aptana Studio. First start Aptana Studio, go to File>New>Project and from the list select PyDev and click on Next. Enter a project name, like “player”, select Python as the project type 2.7 as the grammar version and if your interpreter is not configured click to configure it. Finally select the option to create ‘src’ folder.

You should see in the package explorer tab the project “player”. Left-click on the ‘src’ folder and select new>PyDev module then in the window that appears enter the name ‘player’ and select the template <Empty>. Click Finish and save your project.

Now I want you to go in the folder in which you have your project and create 3 new folders: ‘dist’, ‘res’ and ‘ui’. The first one will contain your compiled app, ‘res’ will contain resource files like images and docs, and in ‘ui’ we’ll save our GUI.

Now open QtCreator, from the menu select File>New File or Project> from the list select a Qt file, then choose the “Widget” template, name the Form file MainForm.ui. Save MainForm.ui in the ‘player/ui’ folder.

If you want some icons for play, stop, open, save, shuffle, delete and clear playlist buttons, create a new folder in ‘res’ called ‘images’ and save your icons there. I use this site for free icons:  but there are a lot of sites where you can get the icons you like.

In your ‘/res’ folder create a new folder ‘docs’. In this folder save the folowing as ‘index.html’

<!DOCTYPE html>
 <title>Tick Player</title>
 <script type="text/javascript" src=""></script>
 <script type="text/javascript">
 var player;
 function onYouTubePlayerAPIReady(){
 player = new YT.Player('embDiv', {
 height: '390',
 width: '640',
 playerVars: { 'autoplay': 1 },
 events: {
 'onStateChange': onPlayerStateChange,
 'onError' : onPlayerError
 function showVideo(vid){
 function onPlayerError(event){
 function onPlayerStateChange(event) {
 if ( == YT.PlayerState.ENDED) {
 function stopVideo() {
 <div id="embDiv">

In your ‘/res’ folder create a new file res.qrc. This is an XML file that will contain a list of all your resources. Here’s mine as an example:

 <qresource prefix="/res">
 <qresource prefix="/res">

PySide uses 2 scripts to compile the resources and GUI into python files.
You need to run these from a terminal in your ‘/player’ folder:

pyside-uic ui/MainForm.ui > src/
pyside-rcc res/res.qrc > src/

In Linux I’ve made a script witch i can double click and does the job for me so I don’t have to open a terminal every time. If you use linux save this in ‘/player’ in a file called ‘genScript’ (you can name it anything you like)

pyside-uic ui/MainForm.ui > src/
pyside-rcc res/res.qrc > src/

The project in Aptana should look like this:

I’ve uploaded all the files you should have by now here:

I made a video:

Feel free to ask questions or post other comments.

Next Part of the totorial: GUI

This entry was posted in PySide, Python, TubePlayer and tagged , , , , , , , , , , , , , , , , , , . Bookmark the permalink.

3 Responses to Getting Started

  1. Pingback: Intro | CodeForce

  2. toto says:

    don’t undertstand what you mean with Pyside ?
    have we to open QtDesigner and make a Mianwindow file for do it?

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s