Tuesday, July 31, 2007

First bits of PyQt

Yesterday I wrote my first PyQt application. It is really simple program, called "tray", which lives in system tray and notifies user of new messages at my favorite social network Vkontakte.ru (Russian clone of FaceBook.com).
The program is less than 170 lines of code. You can try it if you are registered at vkontakte.ru, but the program doesn't matter now.
I am very pleased with simplicity of creation of portable rich GUI applications with PyQt, but as always there are some issues on Windows. I created the program on my favorite old Linux box with vim, so there I had no problems with PyQt4 installation and no need of packaging, because the program consists of one file and three icons.
Then I decided to try it on Windows. First of all I installed newest PyQt 4.3.0. This new version is now packed in self-installing archive, which includes Qt and Eric4 IDE, so now you shouldn't have problems which I described in this post.
After that the program worked perfectly, but I needed to create standalone version for people who don't have Python and PyQt on their PCs.
This is rather simple task, but I've spent several hours fighting some issues.
I used py2exe to create standalone executable. The problem was to include PyQt into it. The idea is simple: I needed to specify that PyQt should be included. So I used solution from py2exe.org. I created file called setup.py with following contents:

from distutils.core import setup
import py2exe
setup(windows=[{"script":"tray.py"}], options={"py2exe":{"includes":["sip"]}})

Then I ran python setup.py install py2exe.
But I received errors like "module import failed: _qt". So I decided to mention inclusion explicitly: python setup.py install py2exe --includes=PyQt4,sip. It didn't help, but error message changed to "cannot find QApplication". Then I tried to reorganize imports in my code:

import sys
from PyQt4.Qt import *
from PyQt4 import QtCore, QtGui

gave correct result, and the executable was created.
I believe that this problem with imports is temporary and will be fixed in near future.

So then I used Inno Setup to create setup package and it was really easy.

Conclusion
It is really easy to create portable applications with great GUI with PyQt4.
The only trade off is the size of installed application on Windows: for my 170 lines of code project I've got 5 Mb setup package, which extracts into 17 Mb application.
The reason is simple - lack of common packaging system with dependencies on Windows, so the program needs it's own copy of Python and PyQt.

Friday, July 13, 2007

My PCs

Today I will try to retrospect history of my home PCs. It is rather personal, so please leave the page immediately if you are not interested :)

For those, who haven't left yet.
My father is a software engineer, so there is nothing unusual that we'd got first home computer as soon as was possible. It was in 1990 or 1991, when the Soviet Union still existed, so there were some problems with foreign devices. Our first computer was hand-made ZX Spectrum clone, which was assembled from different foreign and Russian chips by my father's friend. It had rather peculiar hand-made keyboard, and used Kometa-212 tape-recorder for data storage:
,
and monochrome TV Kaskad-203 as the display, which looked like this:

I'd just started to play chess in local center for youth creativity and enjoyed playing with this computer very much. I was unable to beat it at that time, since I was only six or seven years old :)
Also I tried to do some programming in built-in Basic, but without much success, since I was unable to save entered program on the tape.
I will try to find and photograph remains of that computer.

It's a pity that couple of years after our old TV ceased to function, so we bought another TV, which was incompatible with computer output.

So for couple of years we had no working computer at home. I should mention, that the beginning of 1990s was rather hard time in Russia, so IBM PCs were to expensive for us. They cost more than $1000, and it was very big money. The average wage at that time was about 50-100 USD a month.

When I was eleven, I started study programming in Palace of Youth Creation. I was taught Turbo Pascal 7.0. So I was really happy when we bought a computer as a New Year gift at the end of 1996.

It was rather good and expensive machine with AMD K5 75 MHz processor, 8 megabytes of RAM, 600 megabytes hard drive and brand new Windows 95 OS and 14" CRT monitor GoldStar 1468.

I still use this monitor, which has rather decent picture quality and 800x600/75Hz resolution.

We also bought a printer HP DeskJet 400, which is really cool, I used it last time just two years ago, when I had no time to buy a cartridge for new printer.

I enjoyed playing Warcraft II and programming in Turbo Pascal. But the OS was a complete disaster, it showed Blue Screen of Death several times a day. May be it was due to the lack of system resources, since OS became more stable when we added 8 more megabytes of RAM a year later, or may be because the system was cracked, not bought legally. As you remember, couple hundreds of bucks were a lot of money in Russia in that time :)

In the end of 1997 we added 8 megs of RAM, sound card, CD-ROM and 1.2 Gb hard drive to our PC. Nevertheless, by the end of 1998 it became completely obsolete.
So we "upgraded" it by replacement of main board, processor, RAM, and hard drive. We used the box of old PC, and also bought new LG Flatron 795FT monitor.

New computer was pretty cool, it was based on AMD K6-2/350Mhz processor, with 64 megs of RAM (128 more megabytes was added a year later), 6 Gb Seagate Medalist hard drive and great USR Courier 56k modem. Modem was really good on our old phone line. We had almost no breaks, but rather slow (33,6k) connection because of old hardware at local exchange.

In 1999 computer section in Palace of Youth Creation switched from DOS/Windows 3.11 to FreeBSD, so I started to study C, C++ and Perl, and installed RedHat Linux 5.2 and later 6.0 and 6.2 on our first hard drive, which was 600 megabytes. It's funny that there were enough space for X11, KDE, XEmacs, LaTeX, kernel sources and so on. I also enjoyed Fallout 2 game.

In the end of the year 2000 we decided that we need new PC, so we bought completely new AMD Athlon XP 1733+ MHz with 256 megs of RAM and 40 Gigs IBM hard drive. We plugged newer LG monitor into new PC, and old GoldStar to older one. So for the first time we had more than one working computer :)

Well, later we added new hard drives to new PC, 512 megabytes of RAM, CD-RW/DVD-RW drives, new Canon PIXMA iP4000 printer, Epson scanner and so on, but that is not very interesting. In the beginning of this year 40 Gb IBM hard drive on older PC failed, so that computer became Linux only box. I installed KUbuntu 7.04 on it and I use it now everyday for software development, and it is rather fast :) It can host Apache, MySQL and PHP, also I do C++ and Python development on it. It even can play Youtube movies :) The only thing that I've done for optimization was the replacement of KDE with Fluxbox.

Thursday, July 5, 2007

QFT on non-commutative spaces



Fiore and Wess in their article ”On full twisted Poincare’ symmetry andQFT on Moyal-Weyl spaces” shows that non-commutative QFT withproperly enforced ”twisted symmetry” is equivalent to ordinary commutativeQFT. They start from enforcing space non-commutativity in most simleway:

[xˆμ, ˆxν] = iΘ μν
(1)

Where   μνΘ  is a constant matrix. So the limit   μνΘ   →  0  gives ordinarycommutative space. Then algebra ˆA  generated by ˆx  is equivalent to algebra offunctions A Θ   on commutative space with deformed product, called star-product.Such star product is introduced using twist F  :

a ⋆ b := (ℱ-(1) ⊳ a)(ℱ-(2) ⊳ b)
(2)

Properly chosen ℱ gives

[xμ,x ν]⋆ = iΘ μν
(3)

as required.

There are whole classes of equivalent twists, which lead to the same starproduct, so the theory doesn’t depend on the choice of particular twist. ThenFiore and Wess show how to construct QFT starting with A Θ   . To obtain properself-consistent theory they have to change Poincare-invariance with invariancewith respect to deformed Poincare group, obtained from deformation of Poincarealgebra with the same twist ℱ , as was used to deform algebra of functionsA  .

After the introduction of Wightman axioms and study of Wightman andGreen’s functions it turns out, that this functions coincide with their undeformedcounterparts at least perturbatively. So deformed Poincare symmetry works as”compensation” of space non-commutativity, and theory gives no newphysics.

But there are another possibilities. We can use more complex non-commutativespace, for example, we can start from deformation of Poincare symmetry toκ  -Poincare, then introduce a twist on κ  -Poincare and build non-commutativespace with twisted κ  -Poincare symmetry.

I hope to study this case in details in the next several days.