Writing Qt apps in python

July 2nd, 2007 by exhuma.twn

Writing Qt apps in Python with Qt3 worked. Somewhat. I never found the energy to get it all set up. Finally with Qt4 we have something that “just works”. At least on Ubuntu and Windows (haven’t tested anywhere else).

Yes, since version 4, trolltech finally decided to release Qt as well under the GPL. To most of you it’s all old news. But hey…. just felt like writing it down again 😉

The problems with SIP are finally gone. So you just install python, Qt4 and pyqt4 and off you go.

Read the rest of this entry »

Posted in Python | No Comments »

Using the LAB color space

June 27th, 2007 by exhuma.twn

The LAB color space offers some very powerful ways to manipulate the coloring of a photo. With a little bit of imagination, one can achieve very interesting results even. I am currently working on some examples but it’s not all finished yet.

The examples are done in The Gimp! It should also be possible to adapt those examples to Adobe Photoshop as it also supports the LAB colorspace. Details may vary though.

A boring example of brightening up an image will follow soon.

To get you started:

0 <= L <= 100
-128 <= A <= 128
-128 <= B <= 128

L denotes the lightness such that 0 is black and 100 is white.
A separates magenta/red and green such that -128 is green, 0 is neither red nor green and 128 is red.
B separates cyan/blue and yellow such that -128 is cyan, 0 is neither cyan nor yellow, and 128 is yellow

A fun fact: With LAB you can specify impossible colors. Let’s say, you can crank up B to the maximum positive value, to obtain yellow. What happens if you reduce the L-value? Well it becomes “dark-yellow” which does not exist. Dark-Yellow looks brown to the human eye. Yet you can specify it. The same way you can specify “bright-green”.

Posted in Photo Voodoo | No Comments »

Using the ltree module in PostgreSQL

June 27th, 2007 by exhuma.twn

PostgreSQL offers the very interesting module ltree. It’s used to represent a tree structure within the database. One could represent a tree quite easily as a table which references itself. However, if you ever went along that road, you will know that it becomes very slow with larger trees. In addition, the SQL queries that reference themselves are very unhandy.

If you want to know more, what ltree can do for you, I suggest you go ahead and read the usage examples on the ltree homepage.

Installing ltree

This is the part that eluded me. On the homepage it only states:

  cd contrib/ltree
  make
  make install
  make installcheck

Read the rest of this entry »

Posted in Coding Voodoo | 2 Comments »

Runnning a twisted application as windows service

June 27th, 2007 by exhuma.twn

Currently I am a bit busy, so I will just dump the post I found on usenet. Eventually I will clean it up…

On Wed, 22 Oct 2003 12:24:42 -0600
"Justin Johnson" <justinjohnson@fastmail.fm> wrote:

> The general consensus on the mailing list archives seems to be that
> I'd need to setup my code to not require twistd but just run
> standalone.

Uh. *Maybe* that's the consensus, but it's not actually correct. You can
have a tap or tac run as a NT service.

Lets say you have  a script "server.py" that is runnable with "twistd
-y", you can do (and similar code will work for TAPs):
import sys, os
import win32serviceutil, win32service

class MyService(win32serviceutil.ServiceFramework):
    """NT Service."""

    _svc_name_ = "MyService"
    _svc_display_name_ = "MyService server"

    def SvcDoRun(self):
        import server
        f = open(os.path.join(server.rootPath, "cyberhigh.log"), 'a')
        from twisted.python.log import startLogging
        from twisted.application.app import startApplication
        from twisted.internet import reactor
        startLogging(f)
        startApplication(server.application, 0)
        reactor.run()

    def SvcStop(self):
        self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING)
        from twisted.internet import reactor
        reactor.stop()

if __name__ == '__main__':</pre>
    win32serviceutil.HandleCommandLine(MyService)</pre>
--
Itamar Shtull-Trauring    http://itamarst.org/
Available for Python & Twisted consulting


Posted in Python | No Comments »

Next Entries »

Pages

Recent Posts

Categories

Links


Archives

Meta