<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	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/"
	>

<channel>
	<title>Bin-Blog &#187; tcl</title>
	<atom:link href="http://www.bin-co.com/blog/tag/tcl/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.bin-co.com/blog</link>
	<description>Learn about the latest in Web Development - as soon as I do.</description>
	<lastBuildDate>Tue, 13 Oct 2009 18:55:47 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Hello Script for Tcl</title>
		<link>http://www.bin-co.com/blog/2008/04/hello-script-for-tcl/</link>
		<comments>http://www.bin-co.com/blog/2008/04/hello-script-for-tcl/#comments</comments>
		<pubDate>Thu, 24 Apr 2008 17:14:29 +0000</pubDate>
		<dc:creator>Binny V A</dc:creator>
				<category><![CDATA[Scripts]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[hello]]></category>
		<category><![CDATA[language]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[tcl]]></category>
		<category><![CDATA[tk]]></category>

		<guid isPermaLink="false">http://www.bin-co.com/blog/?p=103</guid>
		<description><![CDATA[
 Tcl, or Tool Command Language, will not be found in the &#8216;most popular languages&#8217; hall of fame. That is partly because of its &#8216;wierd&#8217; syntax. But those who know Tcl will tell you that Tcl is a pleasure to work with. I have a special interest in Tcl &#8211; its the language that introduced [...]]]></description>
			<content:encoded><![CDATA[<p><img src='http://www.bin-co.com/images/tcl.gif' alt='Tcl Logo' align="right" /></p>
<p class="intro"> <a href="http://www.tcl.tk/">Tcl, or Tool Command Language</a>, will not be found in the &#8216;most popular languages&#8217; hall of fame. That is partly because of its &#8216;wierd&#8217; syntax. But those who know Tcl will tell you that Tcl is a pleasure to work with. I have a special interest in Tcl &#8211; its the language that introduced me to GUI programming(<a href="http://www.bin-co.com/tcl/">Tcl/Tk</a>). Now, when ever I see a GUI toolkit, I <a href="http://www.bin-co.com/blog/2007/10/tk-verses-gtkand-python-verses-tcl/">compare it to Tcl</a>.</p>
<p>I have a few years experience in Tcl &#8211; I have written a very popular <a href="http://www.bin-co.com/tcl/tutorial/">Tcl/Tk Tutorial</a> and also a <a href="http://www.bin-co.com/tcl/scripts/indexer/">few</a> <a href="http://www.bin-co.com/tcl/scripts/ri/">small</a> <a href="http://www.bin-co.com/tcl/scripts/tagview/">applications</a> in Tcl. I am not using it a lot now a days because Tk apps look really bad in Linux. This problem is not present in Windows.</p>
<h3>Hello Code</h3>
<pre><code class="tcl">
#!/usr/bin/tclsh

# Printing(IO)
puts "Hello World!\n" 

# Variables, concatenation
set name 'Binny'
set year 2008
puts [concat "Hello, "  $name  " - welcome to "  $year]

#If,else conditions
if { $year &gt; 2008 } {
	 puts "Welcome to the future - yes, we have flying cars!" 

} elseif { $year &lt; 2008 }  {
	 puts "The past - please don't change anything. Don't step on any butterflies. And for the sake of all that's good and holy, stay away from your parents!" 

} else {
	 puts "Anything wrong with your time machine? You have not gone anywhere, kiddo."
}

# For loop
for { set i 0 } { $i&lt;3 } { incr i  }  {
	 puts "$i) Hi there!"
}

#Numerical Array, foreach
set rules [list "Do no harm" "Obey" "Continue Living"]

set i 0
while { $i &lt; [llength $rules] } {
	puts [concat "Rule " [expr $i+1] " : "  [lindex $rules $i]]
	incr i
}

# Associated array, while
array set associated {
	hello	"world"
	foo		"bar"
	lorem	"ipsum"
}

foreach key [array names associated] {
	 puts [concat $key " : " $associated($key)]
}

# Using Join and Split
set csv_values [split "hello,world,how,are,you\n" ","]
puts [join $csv_values ":"]

# Function, argument, return, call
proc hello { person_name } {
	return [concat "Hello, " $person_name]
}
puts [hello "Binny"]

# File IO
# File reading, easy method...
set IN [open "Hello.tcl" r]
set contents [read $IN]
close $IN
puts [concat "Hello has " [string length $contents] " chars"]

# Writing to a file
set OUT [open "/tmp/hello.txt" w]
puts $OUT "Hello World"
close $OUT

# Regular Expressions
set str "Hello World"
if { [regexp {^Hell} $str] } {
	puts "Yup, its evil"
}

puts [regsub -all {l([^l])} $str {\1}]

# Special Tcl Syntax
# Math ops
set answer [expr {3 + 2}]

# Comments
puts $answer ;# Comments in the same line as code must use ;# instead of just #

</code></pre>
<h3>Tcl/Tk Links</h3>
<ul>
<li><a href="http://www.tcl.tk/">Tcl Developer Xchange</a></li>
<li><a href="http://wiki.tcl.tk/">Tcler&#8217;s Wiki</a></li>
<li><a href="http://en.wikipedia.org/wiki/Tcl">Tcl in Wikipedia</a></li>
<li><a href="http://www.yosefk.com/blog/i-cant-believe-im-praising-tcl.html">I can’t believe I’m praising Tcl</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.bin-co.com/blog/2008/04/hello-script-for-tcl/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tk Verses Gtk(And Python verses Tcl)</title>
		<link>http://www.bin-co.com/blog/2007/10/tk-verses-gtkand-python-verses-tcl/</link>
		<comments>http://www.bin-co.com/blog/2007/10/tk-verses-gtkand-python-verses-tcl/#comments</comments>
		<pubDate>Wed, 31 Oct 2007 18:29:10 +0000</pubDate>
		<dc:creator>Binny V A</dc:creator>
				<category><![CDATA[Design]]></category>
		<category><![CDATA[Opinion]]></category>
		<category><![CDATA[Review]]></category>
		<category><![CDATA[Scripts]]></category>
		<category><![CDATA[gtk]]></category>
		<category><![CDATA[gui]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[pygtk]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[tcl]]></category>
		<category><![CDATA[tk]]></category>

		<guid isPermaLink="false">http://www.bin-co.com/blog/2007/10/tk-verses-gtkand-python-verses-tcl/</guid>
		<description><![CDATA[Back when I was using Windows, I searched for some language that would let me create GUI application. I knew C++ &#8211; but creating a GUI using C++ was very, very hard. After some searching I found Tcl/Tk &#8211; it was perfect. I liked Tk so much that I used it to create GUI in [...]]]></description>
			<content:encoded><![CDATA[<p class="">Back when I was using Windows, I searched for some language that would let me create GUI application. I knew C++ &#8211; but creating a GUI using C++ was very, very hard. After some searching I found Tcl/Tk &#8211; it was perfect. I liked Tk so much that I used it to create <a href="http://www.bin-co.com/perl/tk/sedgui/">GUI in perl programs</a>. And <a href="http://www.bin-co.com/ruby/tk/locater/">in Ruby</a>. And in Python. I even wrote <a href="http://www.bin-co.com/tcl/tutorial/">tutorials for Tcl/Tk</a> and <a href="http://www.bin-co.com/perl/perl_tk_tutorial/">Perl/Tk</a>. Then I discovered Linux. initially I was glad that I did not choose VB &#8211; that would mean that I have to throw away all my custom programs. But since I used open languages like Tcl, Perl, Ruby etc, they will run on Linux as well.</p>
<p>But when I actually ran the programs in Linux, I got the shock of a lifetime. The applications I created looked bad &#8211; really bad&#8230;</p>
<p><img src='http://www.bin-co.com/blog/wp-content/uploads/2007/10/tk_screenshot.png' alt='TK Screenshot - Ugly' /></p>
<p>I still use many Tk programs &#8211; but because of the looks issue, I decided to stop using Tk for my new programs. So I decided to try GTK. I even created a small application using PyGTK(my first) to view the harddisk space usage in Linux &#8211; <a href="http://www.bin-co.com/python/programs/frees/">Frees</a>.</p>
<p><img src='http://www.bin-co.com/blog/wp-content/uploads/2007/10/frees_main.png' alt='Frees Screenshot' /></p>
<p>It was a very simple application &#8211; all I had to do is run the &#8216;df&#8217; command, parse its output, and display a small table using that data. I was expecting around 100, 150 lines of code at the most. But after I created the app, I have 500+ lines of code.</p>
<p>At first, I thought that it was a mistake on my part &#8211; I thought that I was not using the best method. But then I came across an <a  href="http://programming.reddit.com/info/5zagm/comments/">article in Reddit</a> &#8211; <a href="http://wiki.tcl.tk/20238">gnocl or PyGtk?</a>.</p>
<p>PyGtk is still the most recommended binding for Gtk. A lot of programs in Linux is written using PyGtk. So naturally there are a few advantages for using it&#8230;</p>
<ul>
<li>It will be the more &#8216;road-tested&#8217; binding.</li>
<li>Many system will have it installed by default.</li>
<li>Bigger community &#8211; so&#8230;
<ul>
<li>more support</li>
<li>more examples</li>
<li>more tutorials</li>
<li>etc.</li>
</ul>
</li>
</ul>
<p>One the other hand, I have to write more code.</p>
<h2>Conclusion</h2>
<p>If it is a private script &#8211; only useful for myself, then I will use Tcl/Tk or Gnometcl. If the script could be distributed, like Frees, then I will use Python GTK.</p>
<p>What about the other options&#8230;</p>
<ul>
<li>wxWidgets</li>
<li>PyQT</li>
<li>Ruby/GTK</li>
<li>Perl/GTK</li>
</ul>
<p>Any recommendations for me on which library to use? Please leave it in the comments.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bin-co.com/blog/2007/10/tk-verses-gtkand-python-verses-tcl/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
	</channel>
</rss>
