Create a simple class of dictionaries to make a dictionary of dictionaries. No need for generators, iterators or lambdas. Use a deck of cards for example.
There are multiple ways to do it. Some are platform dependent.The best way is probably through socket, but you can use platform and os too.
Keeping a dictionary of treerowreferences is the way to go. It makes keeping track of rows a breeze. You don’t have to worry about row locations changing over time as the treerowref keeps track of that automatically.
When you add a parent row to a treestore you get an iterator returned. …
If you want to set a cell to a pixmap, ok no problem, but what about setting individual liststore values to a pixmap? You can’t do it directly unless you’re using a gtk.STOCK_ image. Here’s a way around that little problem.
You don’t need heavyweight communication layers for very simple message passing between threads in python. It’s pretty simple to use pipes and implement your own thread class.
If you like the standard window decorations and dont need/want to create your own buttons to handle custom events, closing a dialog without destroying it is a simple one-liner in pygtk. This is helpful when you have logic that replaces individual widgets inside a dialog and you don’t want to recreate the whole dialog.
If you pass in the event when you enter a callback, you can look at event.type to determine which button was pushed and process the action accordingly. Make sure to check the event.type first for a button press as not all events will define an event.button.
If you want to check for syntax errors without actually running your code, you can compile it with py_compile. You may want to do this if your code modifies files or interacts with the network or external hardware or applications.
So you want to kill a thread… Dangerous. How about asking a thread to die instead? Of course it’s unsafe to just kill a thread dead in its tracks. What if the thread has some resource acquired or is controlling other threads itself? It’s much better to communicate with a thread and tell it to stop, then just wait for it to kill itself.
I needed to encrypt some strings before sending them out over the network to another process and I don’t want to rely on another mechanism for handling the encryption, so here’s my simple AES encryption class. You can load plain text out of the vault by providing a cipher or save an encrypted message by supplying the plain text.