Tuesday, December 29, 2009

PyQt and py2exe

PyQt is an excellent framework for creating GUI applications in Python. It would make sense to create an executable version of these applications that would not rely on Python being pre-installed. The py2exe tool makes this process very easy for most Python applications. However, I recently ran into the problem of an executable PyQt application not acting the same as its Python interpreted counterpart. For the record, I am using Python 2.6.4.

For example, PyQt4 comes with an example application called imageviewer.pyw. After creating an executable version of this application, any attempts to open a jpg file will fail. Opening a png file, however, will work.

The solution to this problem is described in more detail here. To summarize, PyQt uses a plugin to display jpg images. This plugin is not automatically included when using the py2exe tool. To manually include these plugins, do the following:
  1. In the py2exe created dist directory, create a subdirectory named PyQt4.
  2. Copy the plugins folder from the PyQt install location (typically C:\PythonXX\Lib\site-packages\PyQt4).
  3. Paste the plugins directory into the newly create PyQt4 subdirectory.
  4. From the PyQt4 install location, copy the qt.conf file.
  5. Paste the file into the py2exe dist directory.
  6. Edit the file so that the prefix is equal to ./PyQt4
  7. Test that the application works properly.

Monday, December 14, 2009

HTC Touch Pro2 Cradle Verizon Mod


I recently bought a cradle for my Verizon HTC Touch Pro2 from Meritline.com (see link below). From the webpage, it looked like a decent cradle at a reasonable price. However, this cradle is only compatible with the models that do not include a built-in 3.5mm headphone jack. The difference is that the versions without the headphone jack must have the USB jack in the exact middle of the phone while the other versions shift the USB jack over to allow room for the headphone jack.

Not knowing this ahead of time, I was disappointed to discover that my phone was unable to fit into the cradle. Luckily, this cradle can be easily modified in less than 30 minutes to fit the headphone jack sporting models. The only tools required are a screwdriver and a razor blade.

The following steps detail how to modify the cradle. Proceed at your own risk:
  1. Pry the four circular rubber feet off the bottom. These are adhesive and can be reapplied later if removed carefully.
  2. Remove the four screws to separate the top and bottom halves of the dock.
  3. Line up the bottom of the phone with the dock, placing the phone in the recessed area. Note the offset of the USB jack on the phone with the slot on the cradle.
  4. Using the razor, elongate the slot so that the USB connector can be moved to line up properly with the phone. The plastic is soft enough to make clean cuts by hand.
  5. The USB connector on the bottom half of the cradle is attached to a PCB that is held by a slotted support that is molded into the plastic. The bottom of the PCB was glued to the plastic. Cut away the glue with the razor.
  6. Reposition the USB connector using the newly elongated slot. Press the PCB back into the plastic supports. Blind fit everything to make certain the phone will fit into the cradle.
  7. At this point, the PCB can be glued into the cradle if desired. I did not bother since the plastic supports hold it firmly.
  8. Reassemble the rest of the cradle.
Meritline product page:
http://www.meritline.com/htc-usb-dock-cradle-syn-charger-station---p-39084.aspx