May2010

Force gui updates during long callbacks or internal operations in pygtk or gtk

This faq is the most useful pygtk resource you will find. The full documentation is great for looking up which methods to use or what’s available in one class or another, but it’s the little nooks and crannies that are always left out by most pygtk resource sites that I find really annoying.

http://faq.pygtk.org/index.py

====How can I force updates to the application windows during a long callback or other internal operation?====

If you have a long-running callback or internal operation that tries to modify the application windows incrementally during its execution, you will notice that this doesn’t happen; the windows of your app freeze for the duration.

This is by design: all gtk events (including window refreshing and updates) are handled in the mainloop, and while your application or callback code is running the mainloop can’t handle window update events. Therefore nothing will happen in the application windows.

The trick here is to realize where your operation can take a while to return, or where it is dynamically changing the window contents, and add a code fragment like this wherever you want an update forced out:

while gtk.events_pending():
gtk.main_iteration(False)

This tells gtk to process any window events that have been left pending. If your handler … Read More »

Custom udev rules and external program debugging

In udev rules, the %k, %b, %n variables are nice and all, but you can also use the variables you’re comparing and setting such as ID_FS_TYPE, KERNEL, SUBSYSTEM, PHYSDEVPATH, etc. When you run a command in a udev rule, there’s nothing stopping you from calling a shell and executing a few commands without actually calling a standalone script to do the dirty work. If you write out the array of environment variables from inside an external program, you can get a better understanding of just which part of the device discovery is matching your rule and getting processed.

Google’s playable Pacman videogame without Flash

Today, the logo on Google’s homepage changed to their first interactive doodle – a playable game of Pacman, and you don’t even need flash to play it. Yet another nail in the flash coffin? Hit Insert Coin again and you can play as Mrs. Pacman with the WASD keys while player 1 uses the arrow keys!

Python memory management

Object creation and deletion is handled for you, but have you ever thought about how it works, when is memory freed, etc.? Think of everything in python as an object. Even something as simple as this, and since’s its a string, you can invoke any string method. When you lose access to some object, that memory is freed on its own. If you assign a string to a variable, you will find the memory locations are the same. Calling __del__ only removes access to the object from the local or global namespace. It does not mean the memory location has been freed.

Stack Smashing Detected by parted trying to write to read-only device

I haven’t run into this fancy little kernel output before. While automating the writing of partition tables and file systems to removable storage devices, I thought i’d test the case of a read-only file system. This error comes from trying to write a partition label to /dev/sr1 which is the cdrom device. *** stack smashing detected ***: unknown terminated. backtrace and memory map…

Automatic upload of photos and video from your phone

The idea that you can take a picture in an emergency situation and have it instantly uploaded is handy. If you were attacked by a mugger or witness some type of assault or accident, the pictures are instantly backed up online. But what about privacy issues? Putting your media online creates the potential for problems that are outside of your control.

RealTek RTL series Ethernet kernel driver for Linux howto

If you’re running an older distribution of Linux or you just find that the kernel module is unavailable because your RealTek RTL series PCI-Express Ethernet card is just too new, then you’ll need to install the driver manually.