<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Harsh J</title>
	
	<link>http://www.harshj.com</link>
	<description>Memoirs of a QWERTY Keyboard</description>
	<lastBuildDate>Sat, 04 Jul 2009 00:50:32 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" href="http://feeds.feedburner.com/HarshJ" type="application/rss+xml" /><feedburner:emailServiceId>HarshJ</feedburner:emailServiceId><feedburner:feedburnerHostname>http://feedburner.google.com</feedburner:feedburnerHostname><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com" /><item>
		<title>Anna University B.E. B.Tech (UG) Even Semester Results for May-June 2009</title>
		<link>http://feedproxy.google.com/~r/HarshJ/~3/goV4K0L5XxY/</link>
		<comments>http://www.harshj.com/2009/07/03/anna-university-be-btech-ug-results-for-may-june-2009/#comments</comments>
		<pubDate>Fri, 03 Jul 2009 16:10:35 +0000</pubDate>
		<dc:creator>Harsh</dc:creator>
				<category><![CDATA[Personal]]></category>
		<category><![CDATA[2009]]></category>
		<category><![CDATA[Anna Affiliated]]></category>
		<category><![CDATA[Anna University]]></category>
		<category><![CDATA[College]]></category>
		<category><![CDATA[Even Semester]]></category>
		<category><![CDATA[Results]]></category>
		<category><![CDATA[Scores]]></category>
		<category><![CDATA[University]]></category>

		<guid isPermaLink="false">http://www.harshj.com/?p=669</guid>
		<description><![CDATA[Results for all even semesters B.E. and B.Tech (Engineering Degrees, for IT, CSE, ECE, EEE, ME, E&#38;I, etc.) (2nd, 4th, 6th, 8th) will be out in the coming weeks of July 2009, as most rumours go. These are for the exams that stretched from April/May 2009, to June 2009.
(So far only final year results are [...]]]></description>
			<content:encoded><![CDATA[<p>Results for all even semesters B.E. and B.Tech (Engineering Degrees, for IT, CSE, ECE, EEE, ME, E&amp;I, etc.) (2nd, 4th, 6th, 8th) will be out in the coming weeks of July 2009, as most rumours go. These are for the exams that stretched from April/May 2009, to June 2009.</p>
<p>(So far only final year results are out &#8211; 8th semester)</p>
<p>Here&#8217;s a list of potential websites you can check for your results. Comment if you know some other ones!</p>
<p>(I shall keep updating the links once results are out)</p>
<p><script type="text/javascript"><!--
google_ad_client = "pub-6470447295952949";
//Big-Posts-Journalist
google_ad_slot = "1391165574";
google_ad_width = 336;
google_ad_height = 280;
//--></script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
<ol>
<li><a title="Anna University UG Results 2009 May June Server 1" href="http://result.annauniv.edu/result/re09.html" target="_blank">Anna University Official Website (Results Page) for 2009 Even Semester (B.E./B.Tech) </a></li>
<li>Anna University Official Website Links (Site <a title="Site I Anna University May June Results 2009" href="http://result.annauniv.edu/result/re09.html" target="_blank">I</a>, <a title="Anna University UG Results 2009 May June Server 2" href="http://result1.annauniv.edu/result/re09.html" target="_blank">II</a>)</li>
<li><a title="Webdunia UG Anna Results 2009 May June (Link to be updated)" href="http://tamil.webdunia.com/results/au_index.htm" target="_blank">Webdunia Anna University results for UG 2009</a></li>
<li><a title="Chennai Online UG Anna Results 2009 May June" href="http://archives.chennaionline.com/results/annauniv/" target="_blank">Chennai Online Results for Anna University UG 09</a></li>
<li> <script type="text/javascript"><!--
google_ad_client = "pub-6470447295952949";
//Big-Posts-Journalist
google_ad_slot = "1391165574";
google_ad_width = 336;
google_ad_height = 280;
//--></script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></li>
<li><a title="WinEntrance Online Results for 2009 May June Anna University UG" href="http://www.winentrance.com/results/anna_university/" target="_blank">WinEntrance Online Results for Anna University UG 09</a></li>
<li><a title="India Results UG Results for Anna University 2009 May June" href="http://www.indiaresults.com/TamilNadu/anna/default.asp?inst=Anna" target="_blank">India Results results page for Anna University UG 09 May June</a></li>
<li><a title="WorldColleges results page for even sem Anna University UG 2009 May June" href="http://www.worldcolleges.info/results-all/index.php" target="_blank">WorldColleges results page for Anna Univ. UG 2009</a></li>
<li><a title="Anna Univ results from Sivaji TV for 2009 May June" href="http://sivajitv.com/annaunivlogin.do" target="_blank">Sivaji TV results for Anna Univ UG 2009</a></li>
</ol>
<p>More will be added once results get out.</p>

<p><a href="http://feedads.g.doubleclick.net/~a/cw2lwnp_oQVC4aq_ZZeSkISHY4g/0/da"><img src="http://feedads.g.doubleclick.net/~a/cw2lwnp_oQVC4aq_ZZeSkISHY4g/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/cw2lwnp_oQVC4aq_ZZeSkISHY4g/1/da"><img src="http://feedads.g.doubleclick.net/~a/cw2lwnp_oQVC4aq_ZZeSkISHY4g/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/HarshJ?a=goV4K0L5XxY:Kdq86KxeUKo:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/HarshJ?i=goV4K0L5XxY:Kdq86KxeUKo:D7DqB2pKExk" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/HarshJ/~4/goV4K0L5XxY" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.harshj.com/2009/07/03/anna-university-be-btech-ug-results-for-may-june-2009/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		<feedburner:origLink>http://www.harshj.com/2009/07/03/anna-university-be-btech-ug-results-for-may-june-2009/</feedburner:origLink></item>
		<item>
		<title>MPlayer doesn’t expand videos in Fullscreen-mode</title>
		<link>http://feedproxy.google.com/~r/HarshJ/~3/B_zmskIbIIA/</link>
		<comments>http://www.harshj.com/2009/06/24/mplayer-doesnt-expand-videos-in-fullscreen-mode/#comments</comments>
		<pubDate>Wed, 24 Jun 2009 05:48:39 +0000</pubDate>
		<dc:creator>Harsh</dc:creator>
				<category><![CDATA[Personal]]></category>
		<category><![CDATA[fullscreen]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[mplayer]]></category>
		<category><![CDATA[Video]]></category>
		<category><![CDATA[zoom]]></category>

		<guid isPermaLink="false">http://www.harshj.com/2009/06/24/mplayer-doesnt-expand-videos-in-fullscreen-mode/</guid>
		<description><![CDATA[If your mplayer doesn&#8217;t seem to be zooming into, or expanding a video to fit the screen under fullscreen mode (Shows black bands all around the video, preserving its actual size), then it&#8217;s probably because of the video driver your mplayer is using. I had set mine to xv sometime back in order to play [...]]]></description>
			<content:encoded><![CDATA[<p>If your mplayer doesn&#8217;t seem to be zooming into, or expanding a video to fit the screen under fullscreen mode (Shows black bands all around the video, preserving its actual size), then it&#8217;s probably because of the video driver your mplayer is using. I had set mine to xv sometime back in order to play a few Real media files, and though it did zoom in on those files it confounded me when I tried other normal video files like AVI, etc on it.</p>
<p>The solution is to switch the video driver (Preferences &#8211; Video tab) to x11, which supports zoom.</p>

<p><a href="http://feedads.g.doubleclick.net/~a/SMDMuk1VorqPAlRgxX-bmJF4rLY/0/da"><img src="http://feedads.g.doubleclick.net/~a/SMDMuk1VorqPAlRgxX-bmJF4rLY/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/SMDMuk1VorqPAlRgxX-bmJF4rLY/1/da"><img src="http://feedads.g.doubleclick.net/~a/SMDMuk1VorqPAlRgxX-bmJF4rLY/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/HarshJ?a=B_zmskIbIIA:-hQDkauqTcY:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/HarshJ?i=B_zmskIbIIA:-hQDkauqTcY:D7DqB2pKExk" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/HarshJ/~4/B_zmskIbIIA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.harshj.com/2009/06/24/mplayer-doesnt-expand-videos-in-fullscreen-mode/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		<feedburner:origLink>http://www.harshj.com/2009/06/24/mplayer-doesnt-expand-videos-in-fullscreen-mode/</feedburner:origLink></item>
		<item>
		<title>Install Python Packages locally</title>
		<link>http://feedproxy.google.com/~r/HarshJ/~3/B8nWBeNYz00/</link>
		<comments>http://www.harshj.com/2009/05/21/install-python-packages-locally/#comments</comments>
		<pubDate>Thu, 21 May 2009 05:30:40 +0000</pubDate>
		<dc:creator>Harsh</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://www.harshj.com/?p=653</guid>
		<description><![CDATA[There&#8217;s a great feature in Python versions 2.6 and up that I hardly see being used; it&#8217;s the ability to install modules and packages in a per-user local directory. I like this feature since it doesn&#8217;t have any super-user power requirements and lets me install packages, modules and even scripts in my own Home directory [...]]]></description>
			<content:encoded><![CDATA[<p>There&#8217;s a great feature in Python versions 2.6 and up that I hardly see being used; it&#8217;s the ability to install modules and packages in a per-user local directory. I like this feature since it doesn&#8217;t have any super-user power requirements and lets me install packages, modules and even scripts in my own Home directory and use it just as normally as the other global files.</p>
<p>To do so, one must first create the local site-packages directory, and then place the required package or module file or folder under it. The following commands are all for UNIX. <strong>~/</strong> expands to the user&#8217;s <strong>$HOME</strong> automatically.</p>
<pre class="brush: bash;"># To create the required directory
mkdir -p ~/.local/lib/python2.6/site-packages</pre>
<p>Now place the module or package folder under this directory, or link to it for achieving the same installation effect as you would with a global site-packages directory. For example, for my django copy from svn I&#8217;d do:</p>
<pre class="brush: bash;">ln -s ~/.django-svn/django-trunk/django ~/.local/lib/python2.6/site-packages/django</pre>
<p>Running the Python interpreter (in the same user account) will show this working:</p>
<pre class="brush: python;">Python 2.6.2 (release26-maint, Apr 19 2009, 01:56:41)
[GCC 4.3.3] on linux2
Type &quot;help&quot;, &quot;copyright&quot;, &quot;credits&quot; or &quot;license&quot; for more information.
&gt;&gt;&gt; import django
&gt;&gt;&gt; </pre>
<p>So there you have it, when you want a package just for your user account while developing just put it under the local site-packages directory. Python automatically adds this to its path (PYTHONPATH).<br />
<!--adsense--><!--adsense--><br />
References: <a title="PEP 370 -- Per user site-packages directory" href="http://www.python.org/dev/peps/pep-0370/" target="_blank">PEP 370</a> (Has notes for OS X and Windows users)</p>

<p><a href="http://feedads.g.doubleclick.net/~a/bmn9xcFNTTbIT48CjJvm1qjurbA/0/da"><img src="http://feedads.g.doubleclick.net/~a/bmn9xcFNTTbIT48CjJvm1qjurbA/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/bmn9xcFNTTbIT48CjJvm1qjurbA/1/da"><img src="http://feedads.g.doubleclick.net/~a/bmn9xcFNTTbIT48CjJvm1qjurbA/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/HarshJ?a=B8nWBeNYz00:tsLZzqAffoM:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/HarshJ?i=B8nWBeNYz00:tsLZzqAffoM:D7DqB2pKExk" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/HarshJ/~4/B8nWBeNYz00" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.harshj.com/2009/05/21/install-python-packages-locally/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		<feedburner:origLink>http://www.harshj.com/2009/05/21/install-python-packages-locally/</feedburner:origLink></item>
		<item>
		<title>Clearing all log files in /var/log</title>
		<link>http://feedproxy.google.com/~r/HarshJ/~3/kKj0JnjHRCw/</link>
		<comments>http://www.harshj.com/2009/05/19/clearing-all-log-files-in-varlog/#comments</comments>
		<pubDate>Mon, 18 May 2009 22:01:49 +0000</pubDate>
		<dc:creator>Harsh</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Personal]]></category>
		<category><![CDATA[Bash]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Script]]></category>

		<guid isPermaLink="false">http://www.harshj.com/?p=645</guid>
		<description><![CDATA[Stupid things you end up writing when you worry about filling disk spaces at 3 AM in the morning of the day right before your exams begin. The following will delete all your log files in a safe manner, by simply rewriting them to null.

cd /var/log
for file in `find .`
do
	if [ -f $file ];
	then
		cat /dev/null [...]]]></description>
			<content:encoded><![CDATA[<p>Stupid things you end up writing when you worry about filling disk spaces at 3 AM in the morning of the day right before your exams begin. The following will delete all your log files in a safe manner, by simply rewriting them to null.</p>
<pre class="brush: bash;">
cd /var/log
for file in `find .`
do
	if [ -f $file ];
	then
		cat /dev/null &gt; $file
	fi
done
</pre>
<p>Suggest better methods if known, and thank you!</p>
<p><!--adsense--></p>
<p>Optionally, get in there and delete those now-stagnant <strong>.gz</strong> files with the following:</p>
<pre class="brush: bash;">find /var/log -name &quot;*.gz&quot; | xargs rm</pre>
<p><!--adsense--></p>
<p>P.s. So much for BS code highlight plugins printing angled brackets in HTML notations when asked to do bash.</p>

<p><a href="http://feedads.g.doubleclick.net/~a/1hDHvGz1daaOFKybhd8k5J_-51k/0/da"><img src="http://feedads.g.doubleclick.net/~a/1hDHvGz1daaOFKybhd8k5J_-51k/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/1hDHvGz1daaOFKybhd8k5J_-51k/1/da"><img src="http://feedads.g.doubleclick.net/~a/1hDHvGz1daaOFKybhd8k5J_-51k/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/HarshJ?a=kKj0JnjHRCw:EWuPSCP7rDQ:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/HarshJ?i=kKj0JnjHRCw:EWuPSCP7rDQ:D7DqB2pKExk" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/HarshJ/~4/kKj0JnjHRCw" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.harshj.com/2009/05/19/clearing-all-log-files-in-varlog/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.harshj.com/2009/05/19/clearing-all-log-files-in-varlog/</feedburner:origLink></item>
		<item>
		<title>Get rid of all PulseAudio problems – Use OSS</title>
		<link>http://feedproxy.google.com/~r/HarshJ/~3/RUqdNs2s5m8/</link>
		<comments>http://www.harshj.com/2009/05/16/get-rid-of-all-pulseaudio-problems-use-oss/#comments</comments>
		<pubDate>Sat, 16 May 2009 15:40:01 +0000</pubDate>
		<dc:creator>Harsh</dc:creator>
				<category><![CDATA[Computing Issues]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[ALSA]]></category>
		<category><![CDATA[Guide]]></category>
		<category><![CDATA[New Releases]]></category>
		<category><![CDATA[Open Sound System]]></category>
		<category><![CDATA[Operating Systems]]></category>
		<category><![CDATA[OSS]]></category>
		<category><![CDATA[OSSv4]]></category>
		<category><![CDATA[PulseAudio]]></category>
		<category><![CDATA[Sound]]></category>
		<category><![CDATA[Ubuntu]]></category>

		<guid isPermaLink="false">http://www.harshj.com/?p=603</guid>
		<description><![CDATA[You might think, like I did: Isn&#8217;t OSS dead? Didn&#8217;t ALSA replace it ages ago?
The answer, as I learnt, was both yes and no. It did die, only to be revived later by 4Front Technologies who developed it under a commercial license for quite sometime. It went GPL only recently, although with a paid premium-support [...]]]></description>
			<content:encoded><![CDATA[<p>You might think, like I did: <strong>Isn&#8217;t OSS dead? Didn&#8217;t ALSA replace it ages ago?</strong></p>
<div class="wp-caption aligncenter" style="width: 170px"><strong><strong><img title="Open Sound System - Much better!" src="http://img213.imageshack.us/img213/1322/thnormaldjtux3overlord5.jpg" alt="Open Sound System - Much better!" width="160" height="160" /></strong></strong><p class="wp-caption-text">Open Sound System - Much better!</p></div>
<p>The answer, as I learnt, was both yes and no. It did die, only to be revived later by 4Front Technologies who developed it under a commercial license for quite sometime. It went GPL only recently, although with a paid premium-support and on certain platforms only. The improvements made in it are simply amazing. I&#8217;ll leave the rest of the mystery to be covered by 4Front&#8217;s own <a title="OSS is dead, long live OSS." href="http://4front-tech.com/hannublog/?p=5" target="_blank">blog post</a>. It&#8217;s a nice read <img src='http://www.harshj.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>The following guide on how to shift to OSS from PulseAudio/ALSA is for Ubuntu (Jaunty Jackalope, 9.04*) users alone. A proper guide to ArchLinux&#8217;s solution might be found <a href="http://wiki.archlinux.org/index.php/OSS">here</a>.<br />
<span id="more-603"></span></p>
<h2>Getting OSSv4</h2>
<p><a href="http://www.4front-tech.com/download.cgi">Download OSSv4</a> from 4Front&#8217;s website directly. Click <a href="http://www.4front-tech.com/release/oss-linux-4.1-1052_i386.deb">here</a> for the current DEB package. This one package is enough for installing the whole of OSS 4.x.<br />
<!--adsense--><br />
Now to prepare for our installation, issue the following commands:</p>
<pre>
<pre>sudo apt-get install build-essential binutils linux-headers-`uname -r` gawk
sudo apt-get install libtool libgtk2.0-dev libesd0 libsdl1.2debian-oss</pre>
</pre>
<p>These packages are necessary for installing the downloaded DEB package. Next, issue these to disable ALSA from loading next time.</p>
<pre>
<pre>sudo cat /lib/linux-sound-base/noALSA.modprobe.conf &gt;&gt; /etc/modprobe.d/blacklist.conf</pre>
</pre>
<p>And,</p>
<pre>
<pre>sudo echo "blacklist snd_hda_intel
blacklist snd_mixer_oss
blacklist snd_pcm
blacklist snd_timer
blacklist snd_page_alloc
blacklist snd_hwdep
blacklist snd
blacklist soundcore" &gt;&gt; /etc/modprobe.d/blacklist.conf # One whole command</pre>
</pre>
<p>Finally,</p>
<pre>
<pre>sudo dpkg-reconfigure linux-sound-base # Choose OSS in the list shown.</pre>
</pre>
<p>Now reboot your PC so we can stop ALSA from loading. This ensures it doesn&#8217;t interfere with the OSS installation.</p>
<h2>Installing the Open Sound System</h2>
<p>Since double-clicking the DEB (GDebi) won&#8217;t work with our downloaded file, go to the <strong>Terminal</strong>, and in the directory of your downloaded .deb issue:</p>
<pre>
<pre>sudo dpkg -i oss-linux*.deb</pre>
</pre>
<p>That&#8217;s it, let the installation complete and you would have an OSS-enabled environment ready. Test it out with various applications, games and even Flash in the browser! MPlayer has an option in its preferences to set its audio system to OSS, so do some other applications in case they don&#8217;t seem to work.<br />
<!--adsense--><br />
Flash issues, if present, might be cleared if you purge and re-install <em>libflashsupport</em>.<br />
No more PulseAudio server issues, sound stuttering, connection errors, etc.!</p>
<h2>Finishing Up</h2>
<p>In your <strong>System &#8211; Preferences &#8211; Sounds</strong>, ensure all the settings are set to OSSv4 as shown via this <a title="Sound Preferences" href="http://img223.imageshack.us/img223/1548/screenshotsoundpreferen.png" target="_blank">screen-shot</a>.</p>
<p>Go to your <strong>GNOME-Volume-Control (via the volume applet)</strong> and from the Preferences list there, tick on all the settings you need and also <strong>vmix0-src</strong>. Then get back to the main dialog and in the <a title="Options for vmix0-src" href="http://img39.imageshack.us/img39/2024/screenshotvolumecontrol.png" target="_blank">Options tab</a> set vmix0-src as <strong>Production</strong> for the best quality of sound (Might be a tad too loud, you can also play around to see which is best for you).</p>
<p><strong>Bonus</strong>: Run the <strong>oss<em>x</em>mix</strong> application after you&#8217;re done for a lovely control panel!</p>
<p>References: <a title="For suggesting the switch!" href="http://kalpiknigam.com" target="_blank">Kalpik</a> | <a title="Community Documentation on installing OSSv4" href="https://help.ubuntu.com/community/OpenSound" target="_blank">Ubuntu Wiki</a></p>
<p>* Might work with Intrepid Ibex too. Earlier versions would require certain ESD libraries.</p>

<p><a href="http://feedads.g.doubleclick.net/~a/_dgpiJ_S3pvYIbS_RW59S2alWYE/0/da"><img src="http://feedads.g.doubleclick.net/~a/_dgpiJ_S3pvYIbS_RW59S2alWYE/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/_dgpiJ_S3pvYIbS_RW59S2alWYE/1/da"><img src="http://feedads.g.doubleclick.net/~a/_dgpiJ_S3pvYIbS_RW59S2alWYE/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/HarshJ?a=RUqdNs2s5m8:NdufIpXvuoA:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/HarshJ?i=RUqdNs2s5m8:NdufIpXvuoA:D7DqB2pKExk" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/HarshJ/~4/RUqdNs2s5m8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.harshj.com/2009/05/16/get-rid-of-all-pulseaudio-problems-use-oss/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		<feedburner:origLink>http://www.harshj.com/2009/05/16/get-rid-of-all-pulseaudio-problems-use-oss/</feedburner:origLink></item>
		<item>
		<title>PyQt – Signals, Slots and Layouts Tutorial</title>
		<link>http://feedproxy.google.com/~r/HarshJ/~3/mnzqWMHYby0/</link>
		<comments>http://www.harshj.com/2009/05/14/pyqt-signals-slots-and-layouts-tutorial/#comments</comments>
		<pubDate>Thu, 14 May 2009 06:07:32 +0000</pubDate>
		<dc:creator>Harsh</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[PyQt]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[Qt]]></category>
		<category><![CDATA[Signals]]></category>
		<category><![CDATA[Slots]]></category>

		<guid isPermaLink="false">http://www.harshj.com/?p=551</guid>
		<description><![CDATA[Having seen how a simple PyQt application code looks, let&#8217;s delve into user-interaction. We&#8217;ll learn about Qt&#8217;s signal-to-slot connection model for processing input and other events, and layouts for proper placement of widgets on a window.
The PyQt Class Hierarchy
PyQt is completely built upon the Object-Oriented concepts, so it is important to understand how all classes [...]]]></description>
			<content:encoded><![CDATA[<p>Having seen how a simple PyQt application code looks, let&#8217;s delve into user-interaction. We&#8217;ll learn about Qt&#8217;s signal-to-slot connection model for processing input and other events, and layouts for proper placement of widgets on a window.</p>
<h1>The PyQt Class Hierarchy</h1>
<p>PyQt is completely built upon the <strong>Object-Oriented concepts</strong>, so it is important to understand how all classes are related to each other in it.</p>
<p>Almost all GUI classes extend upon their Abstract class which defines common behaviour for similar widgets. These abstract classes, or any widget class, inherit <strong>QWidget</strong>, the base class of all drawable GUI components. QWidget inherits <strong>QObject</strong>, a class that has nothing to do with GUI but forms the <strong>base class of every PyQt class</strong> and helps provide the framework-related features.</p>
<p>The following hierarchy diagram depicts this clearly for the <strong>QPushButton</strong> class:</p>
<div class="wp-caption aligncenter" style="width: 216px"><img title="The QPushButton Class Hierarchy " src="http://pyqt.wordpress.com/files/2009/05/qpushbutton.png" alt="The QPushButton Class Hierarchy" width="206" height="161" /><p class="wp-caption-text">The QPushButton Class Hierarchy</p></div>
<p><strong></strong>The QPaintDevice class helps draw (or paint) things on the screen, thus its also used with anything that&#8217;s drawable &#8211; We&#8217;ll learn more about Painting in a later article.</p>
<p>References: <a title="QWidget Documentation Page" href="http://doc.trolltech.com/latest/qwidget.html" target="_blank">QWidget</a><br />
<span id="more-551"></span></p>
<h1>Signals and Slots</h1>
<p>All user-interaction with widgets can be performed using the concept of Signals and Slots. When a user performs an action over the widget, be it a click, a key press or even a mouse hover, an event is generated each time. These common events can be handled using the concept of signals and slots.</p>
<p>Basically a <strong>signal</strong> is something that&#8217;s <strong>generated each time an event occurs</strong>. The signal is &#8216;emitted&#8217; by PyQt&#8217;s classes internally. To handle such signals we use the concept of slots. Each signal is given a slot to connect to. Once connected to a slot, whenever the signals are generated the slot captures it and executes a pre-specified function to process the event.</p>
<p>So in short words signal is something the framework emits each time an event occurs and a slot is something that receives this signal with its arguments and executes a routine.</p>
<p>To demonstrate the concept of signals and slots in PyQt, lets use a QPushButton along with a QWidget for the window.</p>
<p>The following code runs an application with a <strong>button</strong>, which <strong>when clicked</strong> upon <strong>will quit the application</strong>.</p>
<p>This is done by connecting the &#8220;clicked&#8221; signal of the button to the application&#8217;s &#8220;quit&#8221; slot.</p>
<div class="wp-caption aligncenter" style="width: 220px"><img title="Signals and Slots" src="http://pyqt.wordpress.com/files/2009/05/screenshot-signals.png" alt="Signals and Slots Example" width="210" height="66" /><p class="wp-caption-text">Signals and Slots Example</p></div><br />
<!--adsense--></p>
<pre>
<pre class="brush: python;">
# Program 02 - Signals
from PyQt4 import QtGui, QtCore
import sys

if __name__=='__main__':

	app = QtGui.QApplication(sys.argv)

	window = QtGui.QWidget()
	# Create our main window using a plain QWidget.
	window.setWindowTitle(&quot;Signals&quot;)
	# Set our window's title as &quot;Signals&quot;.
	button = QtGui.QPushButton(&quot;Press&quot;, window)
	# Create, with &quot;Press&quot; as its caption,
	# a child button in the window.
	# By specifying a parent object,
	# this new widget is automatically added to the same.
	button.resize(200, 40)
	# Resize our button to (200, 40) -&gt; (X, Y)
	button.connect(button, QtCore.SIGNAL(&quot;clicked()&quot;),\
		app, QtCore.SLOT(&quot;quit()&quot;))
	# Connect the button's click signal to the QApplication's quit() slot.
	window.show()
	# Show our window.

	app.exec_()
</pre>
</pre>
<p><!--output--></p>
<h1>Connecting a Signal to a Slot</h1>
<p>Connection is performed to enable particular events call their respective slots. All QObject derived classes support connections of signals and slots.</p>
<p>Simple syntax of the connect() method:</p>
<p><strong> </strong></p>
<pre><strong>object.connect(Signal_Widget, Signal, Slot_Widget, Slot)
</strong></pre>
<p><strong></strong></p>
<p>The connect() function makes a connection using two sets of parameters:</p>
<ol>
<li><strong>&#8220;signal&#8221; set</strong>
<ul>
<li>Consists of the signalling object and the type of signal you wish to handle (Given by SIGNAL(QString)).</li>
<li>Every widget emits a signal upon an event like a user interaction or timer generated.</li>
<li>These signals are not to be confused with POSIX/UNIX signals, that&#8217;s a wholly different OS-level concept.</li>
</ul>
</li>
<li><strong>&#8220;slot&#8221; set</strong>
<ul>
<li>The receiving object, and the slot it must execute upon the signal (Given by SLOT(QString)).</li>
<li>Every emitted signal can be handled by a function, called in PyQt-lingo as a &#8220;slot&#8221;.</li>
<li>A slot is executed each time the signal connected to it is emitted by the signalling class.</li>
</ul>
</li>
</ol>
<p><strong>QtCore.QObject</strong> is the class that provides us the connect function you used. Since our class is derived from QObject, we can also use it from it&#8217;s instance. This means that the 20th line can be replaced with:</p>
<pre>
<pre class="brush: python;">
QtCore.QObject.connect(button, QtCore.SIGNAL(&quot;clicked()&quot;),\
	app, QtCore.SLOT(&quot;quit()&quot;))
</pre>
</pre>
<p>A PyQt widget has many signals and slots. For example a QAbstractButton has clicked(), pressed(), released() and toggled() signals and click(), setChecked(Bool), toggle() slots. PyQt pre-provides most of the GUI functionality needs one can think of.</p>
<p>References: <a href="http://doc.trolltech.com/latest/qobject.html">QObject</a> | <a title="Signals and Slots in Qt" href="http://doc.trolltech.com/4.5/signalsandslots.html" target="_blank">Signals and Slots</a> | <a title="QPushButton Documentation Page" href="http://doc.trolltech.com/latest/qpushbutton.html" target="_blank">QPushButton</a> | <a title="QApplication Documentation Page" href="http://doc.trolltech.com/latest/qapplication.html" target="_blank">QApplication</a></p>
<h1>Layouts</h1>
<p>If you tried stretching the previous example&#8217;s window a bit, you would feel that the button is more pasted onto the window than placed. It does not move from its position, the window contents don&#8217;t mutate based on the user&#8217;s screen. Layouts help in this aspect and more.</p>
<p>As the word means, Layouts help <em>lay out</em> your widgets on the form/window in a proper manner. QLayout forms the most basic Layout class and has four major layout sub-classes. The types of those are Box, Grid, Form and Stacked layouts. The following depicts the hierarchy of these layouts, and how some of these look.</p>
<p><div class="wp-caption aligncenter" style="width: 352px"><img title="PyQt Layouts Hierarchy" src="http://pyqt.wordpress.com/files/2009/05/layouthierarchy.png" alt="PyQt Layouts Hierarchy" width="342" height="182" /><p class="wp-caption-text">PyQt Layouts Hierarchy</p></div>
<p>Using a Layout is simple in PyQt. One only has to attach the preferred layout to a window/widget and then adding the components to it (the layout) will automatically lay them out. The following topic&#8217;s example makes use of the QHBoxLayout.</p>
<div class="wp-caption aligncenter" style="width: 198px"><img title="Various PyQt Layouts" src="http://pyqt.files.wordpress.com/2009/05/layout1.png" alt="Various PyQt Layouts" width="188" height="105" /><p class="wp-caption-text">Various PyQt Layouts - Each square can contain an item.</p></div>
<p>References: <a title="QLayout Documentation Page" href="http://doc.trolltech.com/latest/qlayout.html" target="_blank">QLayout</a> | <a title="Layout Classes in Qt" href="http://doc.trolltech.com/latest/layout.html" target="_blank">Layout Classes<br />
</a></p>
<h1>Passing Arguments to Slots</h1>
<p>Signals and Slots <strong>can also carry parameters</strong>. This is useful when there&#8217;s an input involved, or when there needs to be some data sent automatically each time an event occurs.</p>
<p>Let me demonstrate another example, one with parameters. In this example I shall connect a line editor to a label, and as one enters text into the line editor events are generated that make a slot of the label execute and change its display text to the one you&#8217;ve typed. For this we need to use a QLabel for the label and a QLineEdit for the line editor.</p>
<p>List of steps to write the code below:</p>
<ol>
<li>Import necessary classes and functions from PyQt4 (QtGui and QtCore).</li>
<li>Create the QApplication instance.</li>
<li>Create a Window (QWidget).</li>
<li>Attach a QHBoxLayout to it (By setting Window as its parent).</li>
<li>Create a Line input widget and add it to the layout.</li>
<li>Create a Label widget and add it to the layout.</li>
<li>Connect the <strong>textChanged(QString)</strong> signal of the QLineEdit to the <strong>setText(QString)</strong> slot of QLabel.</li>
<li>Show the Window.</li>
<li>Begin the Application loop.</li>
</ol>
<div class="wp-caption aligncenter" style="width: 233px"><img title="Signals and Slots with Arguments" src="http://pyqt.wordpress.com/files/2009/05/screenshot-arguments-1.png" alt="Signals and Slots with Arguments Example" width="223" height="71" /><p class="wp-caption-text">Signals and Slots with Arguments Example</p></div><br />
<!--adsense--></p>
<pre>
<pre class="brush: python;">
# Program 03 - Signals and Slots with Arguments
from PyQt4.QtCore import SIGNAL, SLOT
from PyQt4.QtGui import QApplication, QWidget,\
	QLineEdit, QLabel, QHBoxLayout
import sys

if __name__=='__main__':
	App = QApplication(sys.argv)
	Window = QWidget()
	Window.setWindowTitle(&quot;Arguments&quot;)
	Layout = QHBoxLayout(Window)
	# Create a Layout Object, attached to the Window.
	Line = QLineEdit()
	# Create a Line-Editor / Text-Box.
	Layout.addWidget(Line)
	# Add it to the HBox Layout.
	Label = QLabel()
	Layout.addWidget(Label)
	Line.connect(Line, SIGNAL(&quot;textChanged(QString)&quot;),\
		Label, SLOT(&quot;setText(QString)&quot;))
	# Connect the required signal and slot.
	Window.show()
	App.exec_()
</pre>
</pre>
<p><!--output--></p>
<p>When the user enters/modifies the text of the QLineEdit widget a textChanged(QString) signal is emitted with the new modified string loaded into it. We intercept this and connect it to the QLabel&#8217;s setText(QString) function/slot. Thus the changed QString travels from the QLineEdit to QLabel and is set for display, all upon a single character modification!</p>
<p>The Layout part (Lines 11, 15, 18) has an interesting function addWidget() that takes a widget and adds it to the layout geometry. The addWidget method also takes a stretch-factor and an alignment factor as its parameters, along with a QWidget/derivative. The layout automatically adjusts the widget sizes based on the text input in this example. If you increase the window size, the layout makes it adapt to the same &#8211; try it out to understand!</p>
<p>If the signal/slot concept still sounds confusing, the following graphic will clear it up a little more.</p>
<p><div class="wp-caption aligncenter" style="width: 234px"><img title="Signals and Slots in the Arguments example" src="http://pyqt.wordpress.com/files/2009/05/signals.png" alt="Signals and Slots in the Arguments example" width="224" height="132" /><p class="wp-caption-text">Signals and Slots in the Arguments example</p></div>
<p><!--add image here, phew--></p>
<p>So that&#8217;s it about Signals, Slots and Layouts!</p>
<p>References: <a title="QLineEdit Documentation Page" href="http://doc.trolltech.com/latest/qlineedit.html" target="_blank">QLineEdit</a> | <a title="QLabel Documentation Page" href="http://doc.trolltech.com/latest/qlabel.html" target="_blank">QLabel</a> | <a title="QHBoxLayout Documentation Page" href="http://doc.trolltech.com/latest/qhboxlayout.html" target="_blank">QHBoxLayout</a></p>
<h1>Exercise</h1>
<p><strong>Use a QPushButton in a QWidget window and toggle its text each time its clicked. Also, add a layout to the window with the button in it.<br />
</strong></p>
<p>Each time the button is clicked, its text must toggle. For example, if the Button&#8217;s text is Hello, after a click it changes to PyQt and another click makes it Hello back again. Ensure that the button gets expanded as the window it is in grows.</p>
<p><strong>Footnotes</strong>:</p>
<ul>
<li>You can pass a function directly to the connect() too, for slot-purposes. It needn&#8217;t be a PyQt-provided slot always.</li>
<li> We can also write custom signals and slots for certain events, how awesome is that? I will cover it when we begin to write our own PyQt Classes.</li>
<li>Not all GUI components have an Abstract class. They exist only for a widget or an item that can be extended in more ways than one.</li>
</ul>
<p><strong>P.s.</strong> While commenting on this article, do nest the code in &lt;pre&gt; and &lt;/pre&gt; tags.</p>

<p><a href="http://feedads.g.doubleclick.net/~a/FhCEjDk14KcXQIvm9iS-oAKdzLQ/0/da"><img src="http://feedads.g.doubleclick.net/~a/FhCEjDk14KcXQIvm9iS-oAKdzLQ/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/FhCEjDk14KcXQIvm9iS-oAKdzLQ/1/da"><img src="http://feedads.g.doubleclick.net/~a/FhCEjDk14KcXQIvm9iS-oAKdzLQ/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/HarshJ?a=mnzqWMHYby0:paxBHXU5oS0:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/HarshJ?i=mnzqWMHYby0:paxBHXU5oS0:D7DqB2pKExk" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/HarshJ/~4/mnzqWMHYby0" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.harshj.com/2009/05/14/pyqt-signals-slots-and-layouts-tutorial/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		<feedburner:origLink>http://www.harshj.com/2009/05/14/pyqt-signals-slots-and-layouts-tutorial/</feedburner:origLink></item>
		<item>
		<title>Ubuntu 9.04 Python 2.6 Site-Packages Directory</title>
		<link>http://feedproxy.google.com/~r/HarshJ/~3/5egIMTvt2Pk/</link>
		<comments>http://www.harshj.com/2009/05/13/ubuntu-904-python-26-site-packages-directory/#comments</comments>
		<pubDate>Tue, 12 May 2009 19:39:05 +0000</pubDate>
		<dc:creator>Harsh</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Jaunty Jackalope]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[Ubuntu]]></category>

		<guid isPermaLink="false">http://www.harshj.com/2009/05/13/ubuntu-904-python-26-site-packages-directory/</guid>
		<description><![CDATA[Strangely the site-packages directory used by Python (2.6) to place/install modules and packages is nowhere to be found in Ubuntu&#8217;s Jaunty Jackalope. The newer directory is called dist-packages, no idea why (Only know that it sounds like its for distribution-installed modules).
So to place a package or a link to one, simply do so in the [...]]]></description>
			<content:encoded><![CDATA[<p>Strangely the site-packages directory used by Python (2.6) to place/install modules and packages is nowhere to be found in Ubuntu&#8217;s Jaunty Jackalope. The newer directory is called dist-packages, no idea why (Only know that it sounds like its for distribution-installed modules).</p>
<p>So to place a package or a link to one, simply do so in the <strong>/usr/local/lib/python2.6/dist-packages/</strong> directory.</p>

<p><a href="http://feedads.g.doubleclick.net/~a/KLHVvvtGyFKcojjwNeQlAqqhP94/0/da"><img src="http://feedads.g.doubleclick.net/~a/KLHVvvtGyFKcojjwNeQlAqqhP94/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/KLHVvvtGyFKcojjwNeQlAqqhP94/1/da"><img src="http://feedads.g.doubleclick.net/~a/KLHVvvtGyFKcojjwNeQlAqqhP94/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/HarshJ?a=5egIMTvt2Pk:DUCV1v2TFfE:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/HarshJ?i=5egIMTvt2Pk:DUCV1v2TFfE:D7DqB2pKExk" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/HarshJ/~4/5egIMTvt2Pk" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.harshj.com/2009/05/13/ubuntu-904-python-26-site-packages-directory/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<feedburner:origLink>http://www.harshj.com/2009/05/13/ubuntu-904-python-26-site-packages-directory/</feedburner:origLink></item>
		<item>
		<title>Basics of PyQt</title>
		<link>http://feedproxy.google.com/~r/HarshJ/~3/zCVNhT0eXLU/</link>
		<comments>http://www.harshj.com/2009/04/29/basics-of-pyqt/#comments</comments>
		<pubDate>Wed, 29 Apr 2009 04:04:19 +0000</pubDate>
		<dc:creator>Harsh</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[Presentations]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[PyQt]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[Qt]]></category>

		<guid isPermaLink="false">http://www.harshj.com/?p=544</guid>
		<description><![CDATA[This is a total beginners-only post. In this post, I will talk about what PyQt is, what it does and what are its major components you should know about before you start thinking about developing with it. I&#8217;ve made a simple Google Docs presentation about these and its viewable below or in full screen at [...]]]></description>
			<content:encoded><![CDATA[<p>This is a total beginners-only post. In this post, I will talk about what PyQt is, what it does and what are its major components you should know about before you start thinking about developing with it. I&#8217;ve made a simple Google Docs presentation about these and its viewable below or in full screen at <a href="http://docs.google.com/Presentation?id=ajhc2mhdjn98_1hm36hvg9">this link</a>.<br />
<!--adsense--></p>
<p style="text-align: center;"><iframe src='http://docs.google.com/EmbedSlideshow?docid=ajhc2mhdjn98_1hm36hvg9&amp;size=m' frameborder='0' width='555' height='451'></iframe></p>
<p><span id="more-544"></span><br />
<!--adsense--><br />
Footnotes:</p>
<ul>
<li> The best way to learn and use Qt is to follow the Qt Documentation (via the Qt Assistant that comes along with the installation). Though it is C++ centric, its not much different when you use it in Python. <strong>Qt is Qt everywhere, across platforms and across languages too</strong>. Ruby, Python, C++ or Java.</li>
<li> Books you can refer to, if you really want to, are Mark Summerfield&#8217;s <a href="http://www.qtrac.eu/pyqtbook.html">Rapid GUI Programming with Python and Qt</a> and Boudewijn Rempt&#8217;s <a href="http://www.commandprompt.com/community/pyqt/">GUI Programming with Python: Qt Edition</a>.</li>
<li>My personal favourite, however, is <a href="http://www.amazon.com/gp/product/0132354160">C++ GUI Programming with Qt</a> by Jasmin Blanchette and Mark Summerfield. Though it&#8217;s in C++, the book has a very good approach.</li>
</ul>

<p><a href="http://feedads.g.doubleclick.net/~a/lQOXe0GCQMUhQTrS70o6Srsibxw/0/da"><img src="http://feedads.g.doubleclick.net/~a/lQOXe0GCQMUhQTrS70o6Srsibxw/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/lQOXe0GCQMUhQTrS70o6Srsibxw/1/da"><img src="http://feedads.g.doubleclick.net/~a/lQOXe0GCQMUhQTrS70o6Srsibxw/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/HarshJ?a=zCVNhT0eXLU:sodNJviFef8:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/HarshJ?i=zCVNhT0eXLU:sodNJviFef8:D7DqB2pKExk" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/HarshJ/~4/zCVNhT0eXLU" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.harshj.com/2009/04/29/basics-of-pyqt/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.harshj.com/2009/04/29/basics-of-pyqt/</feedburner:origLink></item>
		<item>
		<title>The PyQt Intro</title>
		<link>http://feedproxy.google.com/~r/HarshJ/~3/6Quykard_Kw/</link>
		<comments>http://www.harshj.com/2009/04/26/the-pyqt-intro/#comments</comments>
		<pubDate>Sun, 26 Apr 2009 02:31:52 +0000</pubDate>
		<dc:creator>Harsh</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[GUI]]></category>
		<category><![CDATA[Nokia]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[PyQt]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[Qt]]></category>

		<guid isPermaLink="false">http://www.harshj.com/?p=528</guid>
		<description><![CDATA[Ever wondered how to easily write good programs using Python? Programs that would run on any platform &#8211; from Windows Vista to Mac OS X along with the various Linux variants. Programs that look good, look native, and also work good.
Here&#8217;s one solution &#8211; PyQt! With it you can create complete working applications that look [...]]]></description>
			<content:encoded><![CDATA[<p>Ever wondered how to easily write good programs using Python? Programs that would run on any platform &#8211; from Windows Vista to Mac OS X along with the various Linux variants. Programs that look good, look native, and also work good.</p>
<p>Here&#8217;s one solution &#8211; PyQt! With it you can create complete working applications that look like the following:</p>
<p style="text-align:center;"><img src="http://pyqt.wordpress.com/files/2009/04/screenshot-fresco.jpg" alt="Fresco - An application developed with PyQt4" width="570" /></p>
<p>Nokia&#8217;s <strong>Qt</strong> is a free (LGPL) cross-platform C++/Java based application-framework, with GUI being its most prominent feature.</p>
<p><strong>PyQt</strong> is simply a python-binding to the C++ libraries that Qt provides. Using PyQt one can write neat looking GUI applications that do a lot, and do so easily.</p>
<p style="text-align:center;"><img src="http://pyqt.wordpress.com/files/2008/05/qt4-logo.png" alt="Nokia's Qt 4" /></p>
<p>A series of articles, starting with this one will aim to tutor interested programmers into using this wonderful library, and developing applications with it.</p>
<p><strong>Prerequisites:</strong></p>
<ul>
<li>Basic Python knowledge.</li>
<li>A little know-how about GUI and the event-based-programming concepts.</li>
</ul>
<p><!--adsense--></p>
<p>Two primary resources where we start from:</p>
<ol>
<li><a title="Nokia - Qt" href="http://www.qtsoftware.com/" target="_blank">Nokia&#8217;s Qt</a></li>
<li><a title="Riverbank Computing - PyQt" href="http://www.riverbankcomputing.co.uk/software/pyqt/intro" target="_blank">Riverbank Computing&#8217;s PyQt</a></li>
</ol>
<p>Downloading and installing PyQt is fairly easy on Linux thanks to the various package managers. Do check out the download links at each of the above-mentioned links to get them on other platforms as well. Installation help is also provided by Riverbank Computing to help you set-up the PyQt4 library.</p>
<p><strong>Code:</strong></p>
<p>So let&#8217;s start off in the same style as almost everything do in a programmer&#8217;s perspective:</p>
<p style="text-align:center;"><strong>Hello World!</strong></p>
<p>Below is a well documented program for you to start with:</p>
<pre>
<pre class="brush: python;">

import sys

# Importing the necessary Qt classes.

from PyQt4.QtGui import QLabel, QApplication

# We use the from foo import * syntax here because
# all of Qt's objects begin with a Q
# and thus we shouldn't run into namespace problems.

if __name__=='__main__':

	App = QApplication(sys.argv)

	# All Qt programs need an
	# QApplication instance.

	# We pass the sys.argv as its arguments
	# because Qt is adept at handling some
	# of the default command-line options
	# like style, size, etc by itself.

	Label = QLabel( &quot;Hello World!&quot; )

	# QLabel is the class providing a
	# simple label

	Label.show()

	# Like in most GUI toolkits, we have
	# to manually set it to show

	App.exec_()

	# Notice the _ after exec, this is to
	# avoid the confusion with Python's
	# exec() built-in-function

	# exec_() starts the main application
	# loop. Something like main() of other
	# toolkits.
</pre>
</pre>
<p>This is how it looks when run, a simple application that displays some popular text:</p>
<p style="text-align:center;"><img class="size-full wp-image-3" src="http://pyqt.wordpress.com/files/2008/05/screenshot-helloworldpy.png" alt="A simple Hello World application written with Qt" width="64" height="39" /></p>
<p><!--adsense--></p>
<p><strong>Breaking it down:</strong></p>
<p>The first thing we have initialized under our &#8216;__main__&#8217; is the <strong>QApplication</strong> instance, <em>App</em>. Every GUI application needs this instance to be present. It handles the look and feel of the application and is the main thread of the same. Without it Qt will error out and not run any GUI.</p>
<p>Next we create a label. A label is a simple text-displaying widget used in many forms to describe the input fields and other things. In Qt, its called the <strong>QLabel</strong> and resides under the QtGui namespace. We create one with a simple Hello World text under the object name Label.</p>
<p>Now we call the <strong>show()</strong> method of the label so that it appears on the screen. This method is applicable to all <strong>QWidget</strong>-class children, and QLabel is one among them. Calling show() draws the label widget&#8217;s window on the screen.</p>
<p>Finally, we start the application loop, the one responsible for making an application run as an infinite loop waiting for user-interaction. Its done by the <strong>exec_()</strong> method of QApplication (App is the instance name). Note the <strong>_underscore_</strong> in the function name, this is to avoid confusion between Python&#8217;s own exec() built-in-function.</p>
<p>More soon, hope you liked the intro. Do follow the <a title="PyQt Tutorials, Articles and more at Harsh J's web log." href="http://www.harshj.com/tag/PyQt/" target="_self">PyQt</a> tag <img src='http://www.harshj.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><span id="more-528"></span></p>
<p><strong>Footnotes:</strong></p>
<ul>
<li>Am running this Qt application in a GNOME environment and thus you see the GTK style being used. Qt can adapt to your environment and can use the native style of any platform it runs on. Also, you can try out the <strong>-style</strong> option to change it too. More on this as we progress.</li>
<li>This program is just a quick start for the impatient, a dose for the hyperactive. I shall take a slow, but smooth, approach to the finer details of PyQt as the tutorials progress.</li>
</ul>

<p><a href="http://feedads.g.doubleclick.net/~a/oZ0IHDVZQFJqmPjNYoeQcKEKoGk/0/da"><img src="http://feedads.g.doubleclick.net/~a/oZ0IHDVZQFJqmPjNYoeQcKEKoGk/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/oZ0IHDVZQFJqmPjNYoeQcKEKoGk/1/da"><img src="http://feedads.g.doubleclick.net/~a/oZ0IHDVZQFJqmPjNYoeQcKEKoGk/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/HarshJ?a=6Quykard_Kw:TMP-3NkLbSU:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/HarshJ?i=6Quykard_Kw:TMP-3NkLbSU:D7DqB2pKExk" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/HarshJ/~4/6Quykard_Kw" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.harshj.com/2009/04/26/the-pyqt-intro/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		<feedburner:origLink>http://www.harshj.com/2009/04/26/the-pyqt-intro/</feedburner:origLink></item>
		<item>
		<title>To keep this blog away from a Necrologist</title>
		<link>http://feedproxy.google.com/~r/HarshJ/~3/f-6q1AGmkTc/</link>
		<comments>http://www.harshj.com/2009/04/25/to-keep-this-blog-away-from-a-necrologist/#comments</comments>
		<pubDate>Sat, 25 Apr 2009 02:29:08 +0000</pubDate>
		<dc:creator>Harsh</dc:creator>
				<category><![CDATA[Personal]]></category>
		<category><![CDATA[College]]></category>
		<category><![CDATA[Gaming]]></category>
		<category><![CDATA[New Releases]]></category>
		<category><![CDATA[Nokia]]></category>
		<category><![CDATA[PC]]></category>
		<category><![CDATA[PyQt]]></category>
		<category><![CDATA[Qt]]></category>
		<category><![CDATA[Ubuntu]]></category>

		<guid isPermaLink="false">http://www.harshj.com/?p=526</guid>
		<description><![CDATA[With the onslaught of these micro-blogging sites I just can&#8217;t think of writing anything more than 140 characters. I&#8217;ve tried posting a digest of the same in the blog every week just to keep it going here but it does not look so neat. The Lifestream plug-in, now in action at one of my pages, [...]]]></description>
			<content:encoded><![CDATA[<p>With the onslaught of these micro-blogging sites I just can&#8217;t think of writing anything more than 140 characters. I&#8217;ve tried posting a digest of the same in the blog every week just to keep it going here but it does not look so neat. The Lifestream plug-in, now in action at <a href="http://www.harshj.com/lifestream/">one of my pages</a>, keeps track of most of the 2.0 updates while I try to bring myself back to posting proper web logs.</p>
<p>With the model exams over, I have about a month&#8217;s holidays to prepare for the 6th semester exams. Too much time, probably cause I listen in the classes. This semester was pretty good compared to the five before since it had two programming and one cryptography topic accompanied with some mathematics to keep the dullness taking over. I don&#8217;t know what they&#8217;ve chosen as electives for the next semester, but I do know that learning Compilers and related topics at college has nil possibility now. I can learn things myself but I don&#8217;t always have that discipline required, hence the sadness of not being taught.</p>
<p>I&#8217;ve decided to merge here, the <a href="http://pyqt.wordpress.com">PyQt blog</a> I have running over at WordPress.com. I&#8217;ve not posted much there, and think that it will be better off at my own blog. Will be posting the existing posts one at a time. Qt 4.5 brings in quite a lot of performance boosts and their blog is very active these days with new concepts/features being put up almost every week. Thank you Nokia!</p>
<p>I also upgraded my Ubuntu from 8.10 to 9.04 flawlessly. The updater&#8217;s config-file diff warning notices need to have more options since it blocks the update process; an editor should do well. Jaunty Jackalope, as it is called this time, has good updates like OpenOffice.org 3 (Took long enough), Qt 4.5 (Wonder how KDE4 would perform on this one), Python 2.6 (Deprecation warnings, yum). A lot of other updates are present too, I just mentioned the ones I cared about.</p>
<p>One of my cabinet fans started making very loud droning noises and it made my temper flare quite a few times. I literally punched it, hard. The everlasting dust issue also started to seek attention again and I had no choice but to sit down, yet again, and clean the CPU off its dust. The graphic card had quite a lot of dust collected upon it this time, and that was the reason why the computer whined when I played a graphic-intensive game. After cleaning off the cabinet using an air-blower, I detached the side fans and after discovering that they had a secret compartment beneath the sticker I gave it some oiling.</p>
<p>It does not make much noises now, except for a few audible scratches when my Prescott is really hot trying to run the VisualBoy Advance at 400% throttle. Peace in my small room, at last. I&#8217;m losing patience on this 4 year old machine and I have probably mentioned that a hundred times. Yet I can&#8217;t seem to take a decision and buy a newer PC, and I don&#8217;t know why. The only things am sure about right now is on getting a 22-inch monitor and half a terabyte of secondary storage with two or four gigabytes of primary memory thrown in. The processor and the motherboard, however, are still delaying my decision with new ones coming in every other month. I&#8217;m dying to dive into the upgrade pool.</p>
<p>Having, at least, three weeks of free time I decided to get myself the Spider-Man&#8217;s Web of Shadows game. It does lack in performance but has some cool moves, like the last movie game did. I also want to play the Broken Sword series again but I don&#8217;t think I&#8217;ll find time to do that. For now, let&#8217;s just swing with the symbiotic.</p>
<p>Anyway, that&#8217;s all I&#8217;ve done in the past three days. More as they come.</p>

<p><a href="http://feedads.g.doubleclick.net/~a/JGeDyeEVwI_AVgIhBcCYBLPmBhs/0/da"><img src="http://feedads.g.doubleclick.net/~a/JGeDyeEVwI_AVgIhBcCYBLPmBhs/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/JGeDyeEVwI_AVgIhBcCYBLPmBhs/1/da"><img src="http://feedads.g.doubleclick.net/~a/JGeDyeEVwI_AVgIhBcCYBLPmBhs/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/HarshJ?a=f-6q1AGmkTc:qmK9VKqhTag:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/HarshJ?i=f-6q1AGmkTc:qmK9VKqhTag:D7DqB2pKExk" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/HarshJ/~4/f-6q1AGmkTc" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.harshj.com/2009/04/25/to-keep-this-blog-away-from-a-necrologist/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.harshj.com/2009/04/25/to-keep-this-blog-away-from-a-necrologist/</feedburner:origLink></item>
	</channel>
</rss>
