Viewing Category : programming

Post thumbnail of Avoid looping through treeview iterators with row references
27 September 2011
Continue reading Avoid looping through treeview iterators with row references

Avoid looping through treeview iterators with row references

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. …

Post thumbnail of Make stock gtk icons from your own images and pixbufs
19 September 2011
Continue reading Make stock gtk icons from your own images and pixbufs

Make stock gtk icons from your own images and pixbufs

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.

Post thumbnail of Hide a dialog without destroying - pygtk one-liner
2 September 2011
Continue reading Hide a dialog without destroying - pygtk one-liner

Hide a dialog without destroying - pygtk one-liner

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.

Post thumbnail of isset() php function equivalent in python
20 June 2011
Continue reading isset() php function equivalent in python

isset() php function equivalent in python

If you need this, you’re probably doing it wrong. But if you really must check to see if a variable has been assigned yet, there’s nothing really stopping you. Here’s one way of implementing it.

Post thumbnail of Thread control in python - how to safely stop a thread
20 June 2011
Continue reading Thread control in python - how to safely stop a thread

Thread control in python - how to safely stop a thread

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.

Post thumbnail of Use gtk settings to make buttons show their icons again
17 May 2011
Continue reading Use gtk settings to make buttons show their icons again

Use gtk settings to make buttons show their icons again

ou may have noticed gtk has stopped showing images for buttons by default. Many apps have not bothered to check the default settings and just assumed that defining an image for a button meant it would show. Too bad the gtk devs decided to change the default value. But never fear, for there is a way to make sure the image shows without modifying the system or user preferences outside of your application!

Post thumbnail of Boost lexical_cast throws bad_lexical_cast when converting types
20 April 2011
Continue reading Boost lexical_cast throws bad_lexical_cast when converting types

Boost lexical_cast throws bad_lexical_cast when converting types

Using boost to convert one type to another. Take int8_t integer for example. Will this even work? No, because int8_t is a char. You will get a bad_lexical_cast exception. You must static cast to an integer type first:

Post thumbnail of Print without a newline in Python
24 February 2011
Continue reading Print without a newline in Python

Print without a newline in Python

With python 3 you can override the print function’s delimiter value to make it null or whatever else you want. But if you’re stuck with 2.5 or 2.6 like the rest of us, try this on for size. The only problem with this is when you want to use it like a progress bar. If you do this in a loop over time, you will get the expected output, but over time it won’t be the way you expected.

Post thumbnail of Bottle: Python Web Framework Made Simple
17 January 2011
Continue reading Bottle: Python Web Framework Made Simple

Bottle: Python Web Framework Made Simple

It doesn’t get much easier than this. However, you must add routes for static files such as style sheets and images. These are things that you may take for granted if you’re used to relying on standalone web servers.

Post thumbnail of Use Bash to do Math
7 January 2011
Continue reading Use Bash to do Math

Use Bash to do Math

You don’t need calculators or other languages and compilers to do math. You can do a lot in bash (GNU Bourne-Again SHell), and it’s really easy!

 Page 1 of 7  1  2  3  4  5 » ...  Last » 
Powered by Wordpress   |   Lunated designed by ZenVerse