Fork me on GitHub
  1. Filesystem Watch with PyQt4

    I decided to write a generic program that can watch a folder or some files and run a command when changes occur.

    Most of the work is done by PyQt4's QFileSystemWatcher.

    qfsw = QtCore.QFileSystemWatcher()
    qfsw.addPaths([path1, file2 ... ])
    
    QtCore.QObject.connect(qfsw,QtCore.SIGNAL("directoryChanged(QString)"),function)
    QtCore.QObject.connect …
    read more

    There are comments.

  2. Text extents with Python Cairo

    I needed this and could not find it. So I share it here (and even better if Google'd index it!)

    def textwidth(text, fontsize=14):
        try:
            import cairo
        except Exception, e:
            return len(str) * fontsize
        surface = cairo.SVGSurface('undefined.svg', 1280, 200)
        cr = cairo.Context(surface)
        cr.select_font_face('Arial', cairo …
    read more

    There are comments.

  3. Colored Output in Console with Python

    Playing around with ANSI in a color capable terminal.

    #!/usr/bin/env python
    import sys
    
    BLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE = range(8)
    
    #following from Python cookbook, #475186
    def has_colours(stream):
        if not hasattr(stream, "isatty"):
            return False
        if not stream.isatty():
            return False # auto color only on …
    read more

    There are comments.

  4. Static build of Cairo and librsvg

    Why ?

    • Convert SVG files to PDF or PNG, with full Unicode support (right-to-left languages), transparency, gradients, PDF image compression, ...
    • Cairo and librsvg are the best in town.
    • Cairo and librsvg are very modern libraries which became famous only in the past 3 years. Thus, GNU/Linux distributions do not always …
    read more

    There are comments.

« Page 11 / 11

social