Archive for December, 2011

A simple wxPython image viewer

Sunday, December 11th, 2011

For a project I needed to display an image in a GUI. As I have used wxPython in the past, I choose to use it again. Although the toolkit is extremely simple and easy to use, I still needed some time to write this simple image viewer. The problem was, that I expected to be able to attach a wx.Image to a Sizer. It took me sometime to figure out, that I needed to turn it into a wx.StaticBitmap first.

Here is a very small and simple image viewer with wxPython, may it be of help to the internet ;)

#!/usr/bin/env python
import wx
class FooApp(wx.App):
	# called when the 'change' button is pressed
	def changeImage(self,event):
		img = wx.Image("foo.jpg")
		self.image = wx.StaticBitmap(self.panel, wx.ID_ANY, wx.BitmapFromImage(img))
	def __init__(self):
		# setup code for the window
		self.frame = wx.Frame(None, title='Demo')
		self.panel = wx.Panel(self.frame)
		# load an image
		img = wx.Image("bla.jpg")
		self.image = wx.StaticBitmap(self.panel, wx.ID_ANY, wx.BitmapFromImage(img))
		# create a Sizer to hold one (or more) button
		self.buttons = wx.BoxSizer(wx.VERTICAL)
		self.changeButton = wx.Button(self.panel, -1, "Change")
		self.mainSizer = wx.BoxSizer(wx.VERTICAL)
		# more generic setupcode
if __name__ == '__main__':
    app = FooApp()

Just for the record: here are the websites that helped me write this code:


Installing the NVIDIA driver for multiple kernels

Thursday, December 1st, 2011

I know it is totally obvious, but I never tried to figure out how to build the NVIDIA driver for more than one kernel. I always just reinstalled it and assumed it has to be that way. As it turns out I was wrong. With the -k switch you can build the driver for any not-running kernel:

sh -K -k -a

-K builds only the kernel module and does not uninstall the current driver

-a accepts the license

-k is the uname -r output of the kernel to build (you can also use the name of the directory in /lib/modules)