Categories
Uncategorized

Get random desktop wallpaper from Bing on Windows 7 :D

Have you heard about Bing? Yes, the wonderful search engine from Microsoft! Have you used it ? Yes? Then you probably know that Bing features a beautiful photo everyday as it’s background image and provides information snippets on different position on the image. You should check this thing if you haven’t already. The photos are just amazing!

I used to leech those photos to make my Desktop wallpaper by right clicking and saving the background images. 😛 But now we have something interesting! You just don’t need to go to Bing daily and save the images manually. You can get random photos from Bing set as your desktop background by installing a theme named “Bing Dynamic”. It downloads Bing photos from the internet and rotates on your desktop. Cool, eh? 😉

Get the “Bing Dynamic” from the official Windows 7 themes page and install it on your PC. Apply the theme and enjoy! 😀

Categories
Python

.NET Framework and IronPython

I am a Python programmer and a Python enthusiast. I love the expressive syntax of the language. I have used it for automating my tasks and developing web sites. I have developed PyQT desktop apps as well. Today I am going to focus on IronPython, another cool distribution of Python programming language. It’s based on the .NET platform introduced by Microsoft. It aims at providing a dynamic runtime language for the .NET platform.

I am using genuine Windows 7 on my Notebook PC. I’ve been trying to install Microsoft Visual Studio 2008 for the last couple of days. But I failed every time. I guess it’s happening because I am using Windows 7 64bit edition. After repeated failure with VS2008, I decided to try .NET platform with Python. So, I went to IronPython home page (see link at the bottom) and browsed the downloads section. By default, it prompted me to get IronPython 2.6 for .NET framework 4.0. I didn’t have v4.0 of .NET installed, so I downloaded the one for .NET 2.0 instead. Tell you what, .NET 4.0 is more than 40 MB download and I am running a bit tight on available data transfer 😛

The setup was pretty easy. I ran the MSI file and it installed for me. But in case, you don’t have .NET 2.0 installed, you’ll need to get that. (See link at the bottom).

After installing IronPython, I noticed a cool looking IPY (IronPython :P) console. It works just like the interactive python shell. Remember, the version I installed didn’t put IPY in the system path. So, typing “ipy ” on the command line will simply fail. Please go to: Control Panel\System and Security\System > Advanced System Setting > Environment Variables. Then append the path of IronPython to the “PATH” variable. Now restart “cmd” 😀 Now, you can execute any Python script with IPY.

Here’s a sample “Hello World!” GUI I wrote to test IPY:

You have to import the “clr” module first. Add a reference to the .NET namespace you want to use. Then use that namespace just like a Python module.

Cool. Isn’t it? So, why should you use IronPython? Good question. Most windows users will by now have .NET framework 2.0 or later installed. The IPY installer is only 6 MB. The end user of your application will need to download less and install less. Please remember PyQT and wxPython are pretty heavy. JAVA requires a huge installation as well. IronPython cares both about you and your users. You get a fantastic expressive language and an excellent platform. Your users get the ease and comfort of installation. Also remember, with Mono, IPY is now cross platform. So your programs will run on other operating systems as well.

With IronPython you can do so many things — develop ASP.NET web sites, work with Robotics and Silverlight, develop games with XNA and build robust programs. So if you’re a Python programmer, come on and mix up .NET and your python wizardry to create something awsome 😉

Resources / Links:
IronPython Home Page
IronPython Download
.NET framework 2.0 Redistributable Package
IronPython Cookbook

Categories
Linux Python

Python Script to Monitor Laptop Battery Charge (Ubuntu/Linux Mint)

I got my laptop two days ago. It’s a Compaq Presario CQ42-220TU. Battery backup is around 3 hours. I am using Linux Mint which is a variation of Ubuntu. Just a few minutes ago I wrote a Python script that monitors the battery charge and if it’s discharging, it gives a notification with remaining percentage of charge every 5 minutes.

Here’s the source codes for the curious minds 😉

Download:http://code.google.com/p/masnun/downloads/detail?name=battery.py

For convenience, I added the script to my start up applications. So whenever I log in to my lappy, it gets auto started. If you want to use this script as well, save the above source code in a file. Let’s assume you saved it in a file named “battery.py” in your home folder. Now give it execution permission. Right click on the file. Go to properties. In the “Permissions” tab, tick the option saying “Allow executing file as program”. Close the dialog box.

Now go to “Preferences” menu from Sytem menu (Ubuntu) or Mint Menu (Linux Mint). Go to Startup Applications. Click Add. Type in a name and comment. In the command field, type the full path of the file. Eg. /home/<_username_>/battery.py.

Restart your PC. 🙂

If you can’t get it working, please provide feedback here or catch me on IM. My contact details are available on https://masnun.com.