Saturday, January 18, 2014

A way to change a system environment variable in Python program.

In Python program we can set system environment variables by using os.environ. For example,

os.environ ["DDD"] = "..." 

But there is a problem that the variable will be disappear after the Python program exits because the variable is owned by the Python program.

The following way can solve the problem to create an environment variable with Python and share it with other programs.

-Count

Wednesday, January 15, 2014

A way to apply the HTML coding habit in wxPython sizer for UI layout.

We can use the size of wxPython to layout user interface but it is not easy to use. If we are familiar with HTML's table tags, such as TABLE, TR and TD, we can use them as a comment in Python program to help us design UI.

Because Python forbids to have free-style indents, we can use a trick of if-string to make indents.

Below is the sample.

-Count