Categories
Python

Building GUI with Python and Tk

I have been looking for a decent GUI toolkit to develop some desktop programs. I worked with Java. Didn’t like the idea of typing that much to develop a app. Used php with WinBinder and PHP-GTK. Liked the first one, but the binary I have won’t load the winbinder extension. To use it, I will have to go back to php4. Again I don’t like the idea of using php4 for GUI while using php5 for web development. So again I had to make a swtich. This time I went for wxPython for Python 2.6.0. Alas, though wxPython used to work fine on my XP, it no longer runs on Windows Vista.

Finally, I deceided to work with TK which comes pre-installed with Python. The IDLE, Module Docs and other GUI tools which comes with a standard Python installations are most often developed using TK on Python.

I liked TK quite a bit because the process of developing TK GUI apps are damn easy and great fun. While learning TK, I converted my old console twitter publisher to a TK powered GUI app. Here’s the sourcecode:

Python 3 Source Code:

It’s very comfortable to work on TK. Write less, do more. A good set of widgets and a powerful language like Python as the backend… It’s simply cool 🙂

Categories
Python

Simple Console Clock for Windows with Python

The code is self explanatory:

Python 3 Source Code:

It displays a clock on Windows Command Prompt and updates it every second. It mainly demonstrates the Timer object of threading library.

Categories
PHP

PHP-GTK: App to update Twitter

People who have been in touch for a while might have noticed how much twitter addict I have suddenly become. Today, I wrote a php-gtk program to update my twitter status. I developed it using php-gtk2 and cURL.

I was having a lot of troubles developing it. I was using “thread safe” php while GTK is “nts (non thread safe)”. I managed a non thread safe php5 but problems raised with the cURL library. The required dependencies for cURL and mysql were not available with that package. I had to copy those specific files from another package. Again, I was getting confused as the app failed to load cURL repeatedly though I had it enabled in php.ini. Later I found out that when I copied the dependencies, I have also copied a “php-cli.ini” which was substituting the default php.ini since php was running in the CLI mode.

Finally it’s done. I am still a beginner at php-gtk. I didn’t write the program from scratch. I copy-pasted some codes from my other projects and php-gtk manual. But this program is going to be a good source of inspiration for me. I really like php-gtk. I am gonna dig a bit deeper whenever I get some time to spare.

Download: http://masnun.googlecode.com/files/twitter_php_gtk.php