Home

PyQt4: 500 lines of code later

  • May. 1st, 2008 at 7:15 PM
Taken in Portugal
Yesterday I blogged that I decided to use PyQt4 in my class. A few hundred lines of code later I start to like Python. It is quite a nice language so far. The indendation thing still drives me mad from time to time (there seems to be no sane editor for python that autoindents my code... Usually I am using VIM, but it is not correctly indenting my files for some reasons. Need to google a bit more for Python-specific vim scripts/settings, I guess.

But I have one issue I cannot resolve (in a nice way). I am loading data from a CSV file. One data set is just True/False, in the file represented by "1" and "0". The only way to make this work is this code:

liquid = bool(int(row[6]))


Without the casting from string to int the casting to bool is not working. In other words, I cannot directly cast from string to bool. I guess there is a more pythonic way, if you know it please tell me :-)

Tags:

PyQt4 success, a coding class in my school

  • Apr. 29th, 2008 at 6:54 PM
Taken in Portugal
In the next term I will (for the first time) be teaching a coding class at my school. I had a few must-have criteria for the language and toolkit of choice:

Language



  1. Has to be a scripted language as then no compiler is needed. Is easier to understand and less error-prone

  2. Has to be free as in beer and freedom

  3. Has to run on Windows 2000, XP, Vista and Linux

  4. Has to have a german reference (for my students)

  5. Has to have a good textbook (for me), if possible written in german

  6. Has to have a good Editor



  1. Perl, Python, Ruby are left

  2. Perl, Python, Ruby are still left

  3. Perl, Python, Ruby are still left

  4. Perl, Python, Ruby are still left

  5. Perl, Python, Ruby are still left

  6. Perl, Python, Ruby are still left (Notepad++ works great for all three languages)



Ok, so I looked at good toolkits for all three languages. My clear favorite is Ruby, for several reasons. I love the language, I know the language, Richard does a great job maintaining the Qt- and KDE-bindings, the PickAxe is a perfect book to learn Ruby from and so on. But I did not choose Ruby. For a very simple reason. Lets see:

    Toolkit
  1. Has to be free as in beer and freedom

  2. Has to have a good documentation for me (as I need to be a few steps ahead of my students)

  3. Has to have a german documentation for my students

  4. Has to run on Windows 2000, XP, Vista and Linux

  5. Has to have a german examples/tutorials which run out of the box (for my students)



  1. Qt, GTK and wx variants of Perl, Python and Ruby are left

  2. Qt variants of Python and Ruby are left. Sorry for wx and GTK, but there are no good documents I could use. This alone rules you out. Beside this, I'd always prefere Qt as I know that toolkit. But I would have taken wx and GTK to the next level if they had better docs. wxPython has "ok" docs, but compared to what I found for PyQt4 it is still quite thin.

  3. PyQt4 and QtRuby4 are still left. Now wxPython and PyGTK would have died anyway.

  4. PyQt4 is left. Works like a charm on Windows and Linux. I often used QtRuby on Linux and so far never on Windows. It seems it once existed but is no longer maintained. A shame, really, as Ruby is such a great language.



So it will be PyQt4.

  • Python has a great free (beer and freedom, written in german) book which I will probably buy as a dead-tree version (I hate reading a book at the screen).

  • There are many, many, many good tutorials, workshops and so on.

  • Very good class documentation.

  • Even a book for PyQt4 itself (which is a huge plus).



I guess wxPython is on the second place. It also has a good book and compared to the other options a good documentation in general. Well, PyQt4 is nice, I already wrote a few hundred lines of code with it. I hope my students will also like my choice :-)

Tags:

MP3 Player vs. Windows vs. Carsten

  • Apr. 26th, 2008 at 8:33 PM
Taken in Portugal
Today I bought 4 GB MP3-Player. First thing I did was to copy a nice playlist from Amarok to the device (on the product box Trekstor even claims the device to be Linux compatible, nice :-), of course it just worked. After a while I had sound problems when listening to Big Pimpin'/Papercut by Linkin Park/Jay Z.

I thought, ok, let's update the firmware. Of course, the software for that is Windows only (and english-only, btw, nice for those 4 billion of us not speaking english), so I switched the OS. I installed the Software and started it. It requires root-privileges. Huh?

Well, I entered the admin-password and 20 minutes later I gave up. First, Windows recoqnized the device without any problem. From one minute to the other it is an unknown device. I tried hard with all my windows-fu and failed. The is no way to connect to the device it seems...

The funny thing is that Windows Media Player is able to play songs directly from the device... Cool, right?

/me reboots to Linux where things just work (for me, at least)

PS: The sounds issues I had are fixed now, it was a headset problem.

Basic Git-foo

  • Apr. 18th, 2008 at 6:10 PM
Taken in Portugal
As I just helped Vladimir to understand the basics of Git I though I can as well blog about this and make others understand Git as well. I guess this might be a start for a tutorial on techbase.kde.org? What do you think?

Update: I did just that. Lets improve the tutorial there and make it more KDE centric.

Setting up Git



First, I started a new Git repository and added one file to it.


carsten@moinmoin:~/git> git init
Initialized empty Git repository in .git/
carsten@moinmoin:~/git> echo "Test content" > testfile


Now I will check what the status is. I will list one untracked file, that means the file has not yet been added to the repository.


carsten@moinmoin:~/git> git status
# On branch master
#
# Initial commit
#
# Untracked files:
# (use "git add ..." to include in what will be committed)
#
# testfile
nothing added to commit but untracked files present (use "git add" to track)


In the next three commands I will add the file, commit the file and then check for the status again.


carsten@moinmoin:~/git> git add testfile
carsten@moinmoin:~/git> git commit
Created initial commit 246d7aa: This is the first commit
1 files changed, 1 insertions(+), 0 deletions(-)
create mode 100644 testfile
carsten@moinmoin:~/git> git status
# On branch master
nothing to commit (working directory clean)


Ok, as you can see the file has been commited. Now I will demonstrate what happens when I am changine the contents of the file:


carsten@moinmoin:~/git> echo "new content" > testfile
carsten@moinmoin:~/git> git status
# On branch master
# Changed but not updated:
# (use "git add ..." to update what will be committed)
#
# modified: testfile
#
no changes added to commit (use "git add" and/or "git commit -a")
carsten@moinmoin:~/git> git commit -a
Created commit 14a9802: Second commit
1 files changed, 1 insertions(+), 1 deletions(-)


You see that Git noticed the changes in the file. "git-commit -a" commits all changes in the repository.

Branches are cheap in Git


git-branch shows you the branches of the repository, the one with the '*' is the active one. So lets create a new branch called "bugfix-branch" and assume we want to fix a branch there. After this fix (in this case the new file) I will merge back all the hard work into the master branch.


carsten@moinmoin:~/git> git-branch
* master
carsten@moinmoin:~/git> git branch bugfix-branch
carsten@moinmoin:~/git> git checkout bugfix-branch
Switched to branch "bugfix-branch"
carsten@moinmoin:~/git> git branch
* bugfix-branch
master
carsten@moinmoin:~/git> echo "a second file" > newfile
carsten@moinmoin:~/git> git commit -a
# On branch bugfix-branch
# Untracked files:
# (use "git add ..." to include in what will be committed)
#
# newfile
nothing added to commit but untracked files present (use "git add" to track)
carsten@moinmoin:~/git> git add newfile
carsten@moinmoin:~/git> git commit -a
Created commit 3264357: This file is here for a demonstration of Gits branch- and merge feature
1 files changed, 1 insertions(+), 0 deletions(-)
create mode 100644 newfile


Ok, the bug is fixed now. Next step: Checkout the master branch and merge the two branches:


carsten@moinmoin:~/git> git checkout master
Switched to branch "master"
carsten@moinmoin:~/git> ls
testfile
carsten@moinmoin:~/git> git merge bugfix-branch
Updating 14a9802..3264357
Fast forward
newfile | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
create mode 100644 newfile
carsten@moinmoin:~/git> ls
newfile testfile




Lets now have a look at the log of the testfile



carsten@moinmoin:~/git> git log
commit 14a9802e249413003d1fa40002baa025aa54c75f
Author: Carsten Niehaus <carsten@moinmoin.site>
Date: Fri Apr 18 18:07:18 2008 +0200

Second commit

commit 246d7aad05139314e7ff62a5becb6c930f72fb8f
Author: Carsten Niehaus <carsten@moinmoin.site>
Date: Fri Apr 18 18:06:33 2008 +0200

This is the first commit

Tags:

Step moved to kdeedu

  • Apr. 5th, 2008 at 5:26 PM
Taken in Portugal
Today, Vladimir moved Step from kdereview to kdeedu. This means that KDE 4.1 will ship it! This week I demonstrated Step to several of my students (7th and 10th grade) and got a little feedback.

This feedback already resulted in several changes including the ability to easily modify the speed of the simulation:



Other recent changes include the tutorial. Vladimirs woman added five tutorial. The following video shows one of them (the second) and also demonstrates how easy it is to "play" with Step: I added a rectangular to the simulation to see what happens when the ball bounces against it...



We hope to get more bugreports and ideas for Step, now that it is inside an official KDE repository. What we currnently would like to get from users is more tutorials and more example. Interested in helping us?

[Step] Help needed for the documentation

  • Apr. 3rd, 2008 at 9:29 PM
Taken in Portugal
The Step team has a small job to offer, everybody is well suited for this one so don't miss a chance to enter the Free Software World! You do not need to be able to code.

In Step, everything should have a small help-text. We are doing this by creating simple HTML-file like this for example. As you can see, the file is quite simple.

All you would need to do is to choose an item without a helpfile (that is pretty much everything, you can really cherry pick!), write the text and send the file to me, Vladimir or the kdeedu-list.

Interested?

[GSoC] Step, a physics simulator

  • Apr. 3rd, 2008 at 8:26 PM
Taken in Portugal
Vladimir and me discussed possible Summer of Code contributions. I just updated our ideas. I added a completly new proposal "Project: Step: different userinterfaces for different target groups".

So if you are interested, please apply!

GSoC: Kalzium and Step

  • Mar. 31st, 2008 at 6:01 PM
Taken in Portugal
As the deadline for applications has been extended I thought I should blog about the ideas we came up with for Kalzium:

http://techbase.kde.org/index.php?title=Projects/Summer_of_Code/2008/Ideas#Kalzium

In case those are not interesting for you but you'd still like to do something for kdeedu and/or a science-related project, why don't you have a look at Step?

http://techbase.kde.org/index.php?title=Projects/Summer_of_Code/2008/Ideas#Step

Resolving merge conflicts in GIT

  • Mar. 23rd, 2008 at 1:43 PM
Taken in Portugal
Sometime people say Git is very hard to use and unusable for mere mortals. Well, in parts that is true. If you ever had a merge conflict and didn't know about 'git-mergetools' it was probably quite confusing. But look what git-mergetool (together with vimdiff, but you can use other diff-viewers if you want) can do for you:

Free Image Hosting at www.ImageShack.us

QuickPost Quickpost this image to Myspace, Digg, Facebook, and others!

As you can see you have the local copy, the remote copy and the conflict in one window and can now work on the conflict.

[Update] Kalzium Plasmoid: Did You Know?

  • Mar. 22nd, 2008 at 5:18 PM
Taken in Portugal
Jarle is such a great artist! Look how nice the new Plasmoid now looks:

Free Image Hosting at www.ImageShack.us

QuickPost Quickpost this image to Myspace, Digg, Facebook, and others!

Mar. 20th, 2008

  • 2:48 PM
Taken in Portugal
I talked with Egon about Plasmoids and he came up with the idea of a second Plasmoid for Kalzium (well, acutally it is a BlueObelisk-frontend which happens to use Kalziums XML classes): Did-You-Know. Here are the two plasmoids in action:

Free Image Hosting at www.ImageShack.us

QuickPost Quickpost this image to Myspace, Digg, Facebook, and others!

If you have cool ideas what to display in those plasmoids just add comments to this blog. This is really just the beginning.

About the strange form of the testtube: I am still having issues with the layout code, I hope to fix them in the next couple of days.

[Update] Kalzium Plasmoid

  • Mar. 19th, 2008 at 4:25 PM
Taken in Portugal
Jarle contributed a nice SVG file which I am now using. Beside other fixes the Plasmoid is no no longer *really* ugly, just semi-ugly ;-)

The SVG is squeezed for some reasons I have yet to find out, I hope to fix it later today.

Free Image Hosting at www.ImageShack.us



When I won the layoutfight against Plasma this will look like this:

Kalzium Plasmoid

  • Mar. 18th, 2008 at 1:12 PM
Taken in Portugal
I created a Kalzium Plasmoid which is using a SVG for the design.

Free Image Hosting at www.ImageShack.us

QuickPost Quickpost this image to Myspace, Digg, Facebook, and others!

Well, this is not the SVG, that is a mockup. The real Plasmoid is working but just ugly, I won't even do a screenshot.

This is a call for artists: Is anybody out there who could create a nice SVG for the plasmoid?

Using QSplitters in Designer files

  • Jan. 30th, 2008 at 1:25 PM
Taken in Portugal
For a couple of month I wondered why I can no longer use QSplitter in .ui-files (Qt4). Well, it never bothered me enough to have a closer look. Frederik told me today how it works. Just read this:

http://doc.trolltech.com/4.3/designer-editing-mode.html#splitter-layouts

GIS question: Is QGIS the best tool?

  • Dec. 12th, 2007 at 5:23 PM
Taken in Portugal
Moin

I am currently working on this project: Next to where I work there is a garden (or a small park). We are working on a catalogue of all trees in the park. I have a printout of the parks streets but no GPS positions of trees or streets.

My plan is to scan the map of the park, rasterize it and use a GPS device to get some coordinates. Then I want to get the GPS coordinates of the trees and add them to the map (including the information which tree it is ("Acer campestre L" for example).

Currently QGIS stands out. But perhaps somebody reading this has better suggestions.
Taken in Portugal
We are using icecream here. My machine is connected with a cable, the others over wireless LAN. Guess what my machine is called?

Free Image Hosting at www.ImageShack.us

KDEEDU meeting in Paris (Mandriva Office(

  • Dec. 1st, 2007 at 9:45 AM
Taken in Portugal
Bon jour.

Nous sommes... No, english: We (14 KDE developers) arrived safely in Mandrivas offices in Paris. The EDU meeting just started. Bye for now.
Taken in Portugal
I have been offline for almost 7 weeks as my new ISP managed to take that long to activate my telefone and DSL line. And that in a quite big town in Germany... Well.

The comming weekend there will be the kdeedu meeting in Paris. As I was offline for a long time I could update KDE4 and didn't work on kdeedu at all... Now, Kalzium has quite some issues left for KDE 4.0. I created this page. It would be very nice if some of you would test Kalzium of KDE trunk (4.0) and add remaining issues in the wiki. That way I'd have a list I could work on in Paris.

Thanks :-)

OpenStreetMap

  • Sep. 23rd, 2007 at 10:24 AM
Taken in Portugal
Last year or so, Germany was virtually not existing in OpenStreetMap. The city I live in, Osnabrück, wasn't until yesterday. Intevation, a local FreeSoftware company (you might know the company from various KDE events like this), released the GIS-data of Osnabrück under a CC licence. Now Osnabrück is finally in OSM:

http://www.informationfreeway.org/?lat=52.268677003321734&lon=8.046990082365921&zoom=12&layers=B000F000

The database of OSM itself is not yet synced it seems, should be in a couple of days or so. This is really cool.

Step: New post-GSoC-feature: Motors

  • Sep. 15th, 2007 at 12:44 PM
Taken in Portugal
A couple of days ago, Vladimir added the first big post-GSoC-feature to
Step (please also note that the homepage has been updated recently). I just made a video which show a motor (the blue particle) and a wall. The motor gains speed (it has a torque), hits the wall. The wall bounces back. As it is connected to a spring it is "dragged" back, hits the motor again and so on. You can control the torque by the slider or by hand (mousepointer). Quite cool feature if you ask me...