wxGlade wxPython and custom components

A reminder to me of how to use custom components in a wxGlade Project.
I had a Panel which contained controls for a Matplotlib Project. The panel contained the plotting surface and some combo boxes to set parameters. I wanted to use this on multiple packages of a notebook to present different data views. This was a good canditiate for being re-used and subclassed. But how to to do that using wxGlade…..

This assumes a component based upon a Panel called a nineGraafTabPage_M
Where the component is first used
Properties->Common->Class nineGraafTabPage_M
Properties->Common->BaseClasse(s) tick and set to wx.Panel (not NOT wxPanel)

How to reuse the Component

Now if we wish to reuse that panel somewhere else, for example on a notebook page. Then on the page you wish to use it. First of all inset a normal panel. Then
Properties->Common->Class NewNameWhatever
Properties->Common->BaseClasse(s) tick and set to nineGraafTabPage_M
Then also add on
Properties->Common->Code tick Extra code for this widget
and in the extra code section
from nineGraafTabPage_M import nineGraafTabPage_M
(important follow this with a carriage return)
Then click on the add properties button and set a property of id with a value of -1

General

In the application property page also tick
Code Generation Separate file for each class

Posted in coding, computing, python, wxGlade | Tagged , | Comments Off on wxGlade wxPython and custom components

Matplotlib, BaseMap, Pyinstaller

(brief random notes, that may help someone else)
A brief tale of getting a matplotlib and basemap to work with pyinstaller. There are two strands to this the Linux and Windows.

This is mostly the linux story.

Step by step, to how I got working.

I was trying to build a single directory solution and a single file solution.
Final conclusion was best to make the application single file and dont include the BaseMap data. then supply the basemap data separately.

This makes it easier to share the basemap data with other applications.

Dependent upon whether you are working on a machine that has matplotlib/basemap installed or not did change how things behaved.

In what follows dev_machine is my dev machine with all packages installed, the target machine is the users machine and has none of the dev tools installed.
Things needed…
On target machine it needed a matplotlibrc,
As a fiddle (thanks to this post http://ubuntuforums.org/archive/index.php/t-1506538.html) I copied my dev machine /etc/matplotlibrc to the directory in which the exectuable was stored on the target machine

the next problem was

IOError: proj data directory not found. Expecting it at: /usr/share/basemap/data

This required a tweak to /usr/share/pyshared/mpl_toolkits/basemap/pyproj
in new install ended up in /usr/local/lib/python2.7/dist-packages/mpl_toolkits/basemap

as per this post http://code.google.com/p/pyproj/issues/detail?id=40&q=PROJ_DIR

Which boils down to around line 239, replace this line


pyproj_datadir = '/usr/share/basemap/data'

with

if 'PROJ_DIR' in os.environ:
   pyproj_datadir = os.environ['PROJ_DIR']
else:
    pyproj_datadir = os.sep.join([os.path.dirname(__file__), 'data'])

The setting an enviroment variable to wherever you have the basemap data
in my setup this was in a folder where the executable was
export BASEMAPDATA=./basemap/data

Next rebuild the pyinstaller files and try again….
export PROJ_DIR=./basemap/data

just didnt work!
copied /etc/matplotlibrc from dev machine into the same folder as the executable and
it worked!….As long as I supplied the basemap data in a folder called basemap/data

Posted in computing, matplotlib, python, Uncategorized | Comments Off on Matplotlib, BaseMap, Pyinstaller

Pyinstaller, Matplotlib and BaseMap

Having big problems persuading a python,matplotlib and Basemap project to freeze using Pyinstaller.

On doze and Linux,

Basemap kept looking in the site distribution for the data files.

Workround I found was the addition of this environment variable PROJ_DIR via a tweak to proj.py
as per this post http://code.google.com/p/pyproj/issues/detail?id=40&q=PROJ_DIR

Which boils down to around line 239, replace this line


pyproj_datadir = '/usr/share/basemap/data'

with

if 'PROJ_DIR' in os.environ:
   pyproj_datadir = os.environ['PROJ_DIR']
else:
    pyproj_datadir = os.sep.join([os.path.dirname(__file__), 'data'])

I still needed to copy the mpl_tools folder across top where the pyinstaller produced single file executable was stored.

Then set these env variables as always ymmv

(looking round in basemaps proj.py and pyproj.py for where folders get set can be fruitful )as well)

I will document this more fully sometime,along with all the useful links I found on the way meantime this may help you get working

set BASEMAPDATA=p:\dist\mpl_toolkits\basemap\data

set PROJ_DIR=P:\dist\mpl_toolkits\basemap\data

Posted in coding, linux, matplotlib, pandas | Tagged , , | Comments Off on Pyinstaller, Matplotlib and BaseMap

XBMC Raspberry Pi

Following a less than successful experience of using an Android based TV box, the Pi got re-deployed to act as an XBMC device.

Rough notes, proper post later, various flavours of player for the Pi. I chose to use

http://www.raspbmc.com/download/

For BBC iPlayer you need to install a Plugin .. See How to add iPlayer

http://www.stus.net/blog/2012/08/16/add-bbc-iplayer-to-raspbmc-or-any-xbmc-illustrated-instructions/

Sorting DHCP

http://choorucode.wordpress.com/2012/08/14/how-to-assign-a-static-ip-address-to-raspbmc/

Extra notes for using it on old eeePCs

http://forum.xbmc.org/showthread.php?tid=141369

Fixing WiFi

http://forum.xbmc.org/showthread.php?tid=81858

Some stuff on forcing the WiFi to Play nice

http://forum.stmlabs.com/showthread.php?tid=3830

Random handy commands that fixed things

amixer set ‘Front’ on

Posted in linux, Raspberry Pi | Comments Off on XBMC Raspberry Pi

mkv conversion

Following some real pain playing video files on an Android Set-top box, the only way to get decent sync between video and audio was to convert all files to .mkv format.

So here is a reminder, quick way to convert files to mkv format(on linux )

a)install mkvmerge

b)mkvmerge -o output.mkv input.avi (or mp4 or whatever)

 

Posted in android, computing | Comments Off on mkv conversion

Simple Microprocessor Simulator

CPU Simulator/Demonstrator
CPU Simulator/Demonstrator

To assist some students in their understanding of simple microprocessors, programming and binary I put this simulator together.

If you think it would be useful for your demonstrations or teaching drop me an email.

(theres a short video here )

NineMicroMain

Posted in coding, computing | Tagged , , , , , , | Comments Off on Simple Microprocessor Simulator

RPi, AutoLogin, Auto start an application, Disable Screen blanking.

These notes are for use when it is required that a device automatically starts, runs an x-session and then runs a particular task.
For example an information display. In those situations it may also be required that the screen does not blank.
Auto Login

Notes from http://elinux.org/RPi_Debian_Auto_Login

sudo nano /etc/rc.local

su whateverusername -c startx

Stop the screen saver

Notes from http://raspberrypi.stackexchange.com/questions/752/how-do-i-prevent-the-screen-from-going-blank

install xset apt-get install x11-xserver-utils

open or create ~/.xinitrc


xset s off # don't activate screensaver
xset -dpms # disable DPMS (Energy Star) features.
xset s noblank # don't blank the video device

exec /etc/alternatives/x-session-manager # start lxde

Auto run

Notes from http://blog.flowbuzz.com/2012/07/raspberry-pi-and-autostart.html

cd ~/.config

mkdir autostart

then creat file called .desktop

format of contents is

[Desktop Entry]
Type=Application
Exec=/filetorun
Posted in linux, Raspberry Pi, Uncategorized | Comments Off on RPi, AutoLogin, Auto start an application, Disable Screen blanking.