overThere.co.uk

Thoughts. And some software.

Bing Wallpaper Changer

About

This program will run in the system tray and check for a new daily Bing image on a user defined interval. If the URL for the image has changed since the last check the new image will be downloaded and applied as the current wallpaper.

There is also the option to run a command after the wallpaper has been applied. This is useful for anyone that uses software that overlays data onto their wallpaper, Such as BgInfo from Sysinternals.

The last two week’s worth of images is available on a History tab - just double click a thumbnail to apply a wallpaper. If using this and you want to keep an old wallpaper don’t forget to disable to the automatic updating from the main Settings tab, otherwise the wallpaper will be replaced with the daily wallpaper on the next update check.

Improving pyPdf2 with PDFtk

PyPDF2 (forked from pyPdf) is wonderful. I use it a fair bit in my job, mainly for chopping up PDFs and re-assembling the pages in a different order. It does sometimes have difficulty with non-standard PDFs though that seem fine in other programs. This can be frustrating.

The one that I’ve been battling with today from some PDFs provided by a client was:

pyPdf2.utils.PdfReadError: EOF marker not found

I managed to find a workaround using PDFtk to fix the PDF in memory at the first sign of any trouble. It works well so far, so in case anyone else is having similar issues I thought I’d write it up.

New Blog!

I’ve moved this site from WordPress to Pelican. Pelican is awesome.

WordPress is written in PHP and uses MySQL to store the data needed to build each page. The good thing about WordPress is that the pages are built as they are requested. The bad thing about WordPress is that the pages are built as they are requested.

The whole database-driven dynamic page thing can slow down a site quite a bit, especially if you’re only using a basic hosting package. If like me you also install a boatload of plugins and themes to test things out the database gets full of cruft adding to more slowdowns. I experimented with various different caching plugins and they seemed to work great for a couple of weeks and then they’d stop updating the content and serve up week-old stale pages. I never found out why.

QGraphicsView with mouse wrapping

In a document management program that I’m writing I’m displaying images in a QGraphicsView. The QGraphicsView supports a drag mode that allows a user to simply click and drag within the view to pan around, which works great when I a large image displayed and the user has zoomed in quite far.

Panning the image this way does mean that the user has to click back on the image and move the mouse again when the mouse reaches the end of the screen. I needed a way to implement mouse wrapping so that when the mouse reaches the end of the QGraphicsView during panning and the user is still holding down the left mouse button the mouse will jump to the opposite edge, giving a smooth continuous pan.

Here’s what I came up with…

Using QStyledItemDelegate on a QTableView

Most databases store dates in the format YYYY-MM-DD. When using a QTableView to display a database table in PyQt it’s useful to be able to display this in a different format. Being from the UK I’d rather have the date displayed in the UK style – DD/MM/YYYY. This is where QStyledItemDelegate comes in.

I’d put off looking into this for a while because whenever I tried to look in to using QStyledItemDelegate I saw people mentioning paint methods. I know nothing about painting in PyQt and get quite scared when I see it mentioned. I really need to get over that.

Not to worry though, because it’s not needed…

Splitting old-style JPEG encoded TIFFs

The tiffsplit program from the libtiff library does a good job of splitting multi-page TIFF files into single pages. It doesn’t seem that great at handling TIFFs saved with ‘old-style’ JPEG encoding.

It’ll produce files, and the correct number of files too, but the files are actually in JPEG format. Most image viewers won’t open them still because they’re JPEG files with TIFF headers.

Assuming you have a TIFF file made up entirely of old-style JPEG encoded images you can loop through the files that tiffsplit has exported and remove the first eight bytes to give valid JPEG files.

Windows 7 Minimal Taskbar Menu

Right clicking the taskbar in Windows 7 and selecting Toolbars and New Toolbar will let you select a folder on your computer to add as a taskbar menu. Here’s how to make the label take up less space…

Cleaning QR Codes

At work we use QR Codes. It’s a pretty recent thing. For a few clients we used to scan pages of a file and then have the scanner operator stop what they were doing to give the TIFF file a meaningful filename. Now we have the clients supply cover sheets, generated with custom software, that contain QR codes. These then get processed after scanning and before the scan of the header sheet is discarded the indexing data is decoded using ZBar through an AutoHotkey script.

A few days ago we hit a problem. We’d scanned a few thousand pages but the script was unable to decode any of the indexing data from the QR codes. Not a single page. After looking into it I found that there were quality issues with the printing of the cover sheet. I could tell that the QR code was valid because the app I use on my mobile phone could read it fine, but ZBar could not. And ZBar is what matters – I wasn’t about to sit down decoding QR codes with my phone all day.

Installing Poppler for PyQt4 on Windows

Poppler is a PDF rendering library based on the xpdf-3.0 code base. It has bindings for Qt4 which we can use through Python/PyQt. Using these libraries under most popular Linux distributions is as simple as installing the Poppler package, but under Windows I’ve found that things are a little more tricky to get working.

Native Desktop Application for Subsonic

I’ve been looking for a new personal project to work on for a while and I’ve been having trouble finding something. I wanted something that I’d use myself, otherwise my interest would quickly drop. Something that ideally I would use every day. I also wanted to write something that other people would find a use for as well. And it had to be written in Python and be something completely different to anything I’ve played with before. So I’ve decided to write a desktop client for Subsonic.