{"id":7144,"date":"2014-04-07T05:07:24","date_gmt":"2014-04-06T19:07:24","guid":{"rendered":"http:\/\/www.rjmprogramming.com.au\/wordpress\/?p=7144"},"modified":"2020-03-30T19:44:10","modified_gmt":"2020-03-30T09:44:10","slug":"tcltk-bats-and-ball-tutorial","status":"publish","type":"post","link":"https:\/\/www.rjmprogramming.com.au\/ITblog\/tcltk-bats-and-ball-tutorial\/","title":{"rendered":"Tcl\/Tk Bats and Ball Tutorial"},"content":{"rendered":"<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/TCL\/Mavericks\/BatsAndBall_TclTk.m4v\"><img decoding=\"async\" id='pimqgmovh' onmouseover=\"var xqw=this.src;  if (xqw.indexOf('25') != -1) { this.src = 'http:\/\/www.rjmprogramming.com.au\/TCL\/Mavericks\/TclTk_BatsAndBall-31of.jpg'; } else if (xqw.indexOf('31') != -1) { this.src = 'http:\/\/www.rjmprogramming.com.au\/TCL\/Mavericks\/TclTk_BatsAndBall-32of.jpg'; }  else if (xqw.indexOf('32') != -1) { this.src = 'http:\/\/www.rjmprogramming.com.au\/TCL\/Mavericks\/TclTk_BatsAndBall-33of.jpg'; } else if (xqw.indexOf('33') != -1) { this.src = 'http:\/\/www.rjmprogramming.com.au\/TCL\/Mavericks\/TclTk_BatsAndBall-11of.jpg'; } else if (xqw.indexOf('11') != -1) { this.src = 'http:\/\/www.rjmprogramming.com.au\/TCL\/Mavericks\/TclTk_BatsAndBall-21of.jpg'; } else if (xqw.indexOf('21') != -1) { this.src = 'http:\/\/www.rjmprogramming.com.au\/TCL\/Mavericks\/TclTk_BatsAndBall-25of.jpg'; }  \"  style=\"float:left;border: 15px solid pink;\" alt=\"Python Webserver Primer Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/TCL\/Mavericks\/TclTk_BatsAndBall.jpg\" title=\"Tcl\/Tk Bats and Ball Tutorial (try twirling round bottom of image for a synopsis ... 'do the twirl now')\"  \/><\/a><p class=\"wp-caption-text\">Tcl\/Tk Bats and Ball Tutorial (try twirling round bottom of image for a synopsis ... 'do the twirl now')<\/p><\/div>\n<p>Good news today is a breakthrough on a put-off project, getting Tcl\/Tk to work with Mac OS X <a target=_blank title='Mac OS X 10.9 ... Mavericks' href='http:\/\/www.apple.com\/au\/osx\/?cid=wwa-au-kwg-mac-com'>Mavericks<\/a> and <a target=_blank title='Xcode' href='https:\/\/developer.apple.com\/xcode\/'>Xcode 5.1<\/a> on a MacBook Pro laptop &#8230; answering, partially, the previous <a target=_blank title='Tcl\/Tk So Brilliant (but where do you start?) Primer Tutorial' href='#ttsbpt'>Tcl\/Tk So Brilliant (but where do you start?) Primer Tutorial<\/a> lament &#8230; yayyyyyyyyyyyyyy!<\/p>\n<p>Was a bit of a battle combining environmental issues and coding issues, and there is an ongoing unresolved (ease of) deployment issue (with Mavericks (ie. Mac OS X 10.9) &#8230; lead is <a target=_blank title='Homebrew as alternative to Package Manager' href='http:\/\/brew.sh\/'>Homebrew<\/a> (what happened to the excellent Package Manager?!)).<\/p>\n<p>Think Tcl\/Tk is definitely worth the time to try GUI applications, which we do here with Xcode C++ code, which utitizes Tcl scripting and Tk GUI.<\/p>\n<p>The <a target=_blank title='Setup issues' href='http:\/\/www.rjmprogramming.com.au\/TCL\/Mavericks\/TclTk_BatsAndBall-11of.jpg'>environmental requirements<\/a> to get it up and running (again &#8230; had it working quite a long time ago (with Mac OS X Darwin or one up from this &#8230; see below it was Mac OS X 10.5.8\/Xcode 3.0)) revolved around updating (personally, <a target=_blank title='Got to this excellent resource via one of those excellent helper links below' href='https:\/\/distfiles.macports.org\/MacPorts\/'>had to start again with a full reinstall<\/a>) <a target=_blank title='The Macports Project' href='http:\/\/www.macports.org'>Macports<\/a>.<\/p>\n<p>The coding issues revolved around a Mac OS X alternative to gettimeofday() function and the 64-bit architecture of a modern Macbook Pro laptop.<\/p>\n<p>Today&#8217;s Mac OS X Mavericks application built with <a target=_blank title='Mac OS X Mavericks application' href='http:\/\/www.rjmprogramming.com.au\/TCL\/Mavericks\/TclTk_BatsAndBall-21of.jpg'>Xcode 5,1<\/a> is a Bats and Ball <a target=_blank title='Mac OS X Mavericks application' href='http:\/\/www.rjmprogramming.com.au\/TCL\/Mavericks\/TclTk_BatsAndBall-25of.jpg'>game<\/a> with up to four players (4 players\/1 keyboard = twister?) reminiscent of those twee tennis games you used to play in the foyer before playing a squash game, back in the &#8217;70s &#8230; please don&#8217;t do the maths!<\/p>\n<p>If you would like this application for a Mavericks Mac maybe an ad-hoc style of install could be arranged if you drop me an <a href='mailto:rmetcalfe@rjmprogramming.com.au?subject=BatsAndBall&#038;cc=rmetcalfe15@gmail.com' title='Email RJM Programming RE BatsAndBall'>email<\/a>.<\/p>\n<p>Please enjoy today&#8217;s Tcl\/Tk tutorial made up of two visual parts &#8230; &#8220;twirling&#8221; around bottom of picture above, and clicking for a <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/TCL\/Mavericks\/BatsAndBall_TclTk.m4v\" title=\"Click picture\">video<\/a>.<\/p>\n<p>These links were useful (so, thanks):<\/p>\n<ul>\n<li><a target=_blank title='Mac OS X install error: No available formula for gtest - ROS Answers: Open Source Q&#038;A Forum' href='http:\/\/answers.ros.org\/question\/42335\/mac-os-x-install-error-no-available-formula-for-gtest\/'>Mac OS X install error: No available formula for gtest &#8211; ROS Answers: Open Source Q&#038;A Forum<\/a><\/li>\n<li><a target=_blank title='OS X- How can I create an OS 10.9 Mavericks .dmg?: [ Apple ]' href='http:\/\/www.usoftlap.com\/t36806.html'>OS X- How can I create an OS 10.9 Mavericks .dmg?: [ Apple ]<\/a><\/li>\n<li><a target=_blank title='X112.7.5 \u2013 XQuartz' href='http:\/\/xquartz.macosforge.org\/trac\/wiki\/X112.7.5'>X112.7.5 \u2013 XQuartz<\/a><\/li>\n<li><a target=_blank title='Installing Homebrew on OS X Mavericks 10.9, Package Manager for Unix Apps' href='http:\/\/coolestguidesontheplanet.com\/setting-up-os-x-mavericks-and-homebrew\/'>Installing Homebrew on OS X Mavericks 10.9, Package Manager for Unix Apps<\/a><\/li>\n<li><a target=_blank title='MacOS Mavericks Fix, Package Manager, etc.' href='http:\/\/arelle.org\/2013\/10\/27\/macos-mavericks-inoperable\/'>MacOS Mavericks Fix, Package Manager, etc.<\/a><\/li>\n<li><a target=_blank title='The state of package management on Mac OS X | On the lambda' href='http:\/\/www.onthelambda.com\/2013\/10\/14\/the-state-of-package-management-on-mac-os-x\/'>The state of package management on Mac OS X | On the lambda<\/a><\/li>\n<li><a target=_blank title='Retrieving system time: gettimeofday()' href='http:\/\/www.chocolatesparalucia.com\/2010\/10\/retrieving-system-time-gettimeofday\/'>Retrieving system time: gettimeofday()<\/a><\/li>\n<li><a target=_blank title=\"osx - Can't update Macports (with Mac OS X Mavericks) - Stack Overflow\" href='http:\/\/stackoverflow.com\/questions\/19622337\/cant-update-macports-with-mac-os-x-mavericks'>osx &#8211; Can&#8217;t update Macports (with Mac OS X Mavericks) &#8211; Stack Overflow<\/a><\/li>\n<li><a target=_blank title='How to Install Command Line Tools in 10.9 Mavericks Fresh Install' href='http:\/\/www.computersnyou.com\/2025\/2013\/06\/install-command-line-tools-in-osx-10-9-mavericks-how-to\/'>How to Install Command Line Tools in 10.9 Mavericks Fresh Install<\/a><\/li>\n<li><a target=_blank title='Macports Download page' href='https:\/\/distfiles.macports.org\/MacPorts\/'>Macports Download page<\/a><\/li>\n<li><a target=_blank title=\"Can't run a TCL script on CentOS 5.8\" href='https:\/\/www.centos.org\/forums\/viewtopic.php?t=18208'> Can&#8217;t run a TCL script on CentOS 5.8<\/a><\/li>\n<\/ul>\n<p>Tcl scripts can run on many web servers, and the web server this domain runs on accepts Tcl scripts run from the command line.  Take a look at this simple Tcl programming script inspired by that last link above, which can be called  <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/TCL\/Mavericks\/HelloWorld.tcl_GETME\" title=\"HelloWorld.tcl\">HelloWorld.tcl<\/a> and runs at the web server&#8217;s command line via <i>tclsh .\/HelloWorld.tcl<\/i> &#8230; this can be a web application via PHP exec command which you can see with <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/TCL\/Mavericks\/HelloWorld.php_GETME\" title=\"HelloWorld.php\">HelloWorld.php<\/a> and with this <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/TCL\/Mavericks\/HelloWorld.php\" title=\"HelloWorld.php\">live run<\/a>.   Tcl scripts are <a target=_blank title='Interpreted language information from Wikipedia' href='http:\/\/en.wikipedia.org\/wiki\/Interpreted_language'>interpreted<\/a>, unlike our Bats And Ball <a target=_blank title='Compiled language information from Wikipedia' href='http:\/\/en.wikipedia.org\/wiki\/Compiled_language'>compiled<\/a> code, so you would have to compile the code at the web server with a similar environment to successfully deploy Bats And Ball to a Linux web server, this way.<\/p>\n<p>Link to Tcl\/Tk website &#8230; <a target=_blank href='http:\/\/www.tcl.tk\/software\/tcltk\/' title='Home of Tcl\/Tk'>Home of Tcl\/Tk<\/a><br \/>\nLink to Tcl\/Tk jobs done &#8230; <a target=_blank href='http:\/\/www.rjmprogramming.com.au\/TCL\/' title='Examples of use of Tcl\/Tk'>Tcl\/Tk jobs done<\/a> &#8230; personal experience<\/p>\n<hr \/>\n<p id='ttsbpt'>Previous relevant <a target=_blank title='Tcl\/Tk So Brilliant (but where do you start?) Primer Tutorial' href='http:\/\/www.rjmprogramming.com.au\/wordpress\/?p=664'>Tcl\/Tk So Brilliant (but where do you start?) Primer Tutorial<\/a> is shown below.<\/p>\n<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/TCL\/MacExample\/\"><img decoding=\"async\" style=\"border: 15px solid pink;\" alt=\"Tcl\/Tk So Brilliant (but where do you start?) Primer Tutorial ... http:\/\/www.tcl.tk\/software\/tcltk\/\" src=\"http:\/\/www.rjmprogramming.com.au\/TCL\/MacExample\/TCL_Example_1of.png\" title=\"Tcl\/Tk So Brilliant (but where do you start?) Primer Tutorial ... http:\/\/www.tcl.tk\/software\/tcltk\/\"  style=\"float:left;\" \/><img decoding=\"async\" style=\"float:left;border: 15px solid pink;\" alt=\"Tcl\/Tk So Brilliant (but where do you start?) Primer Tutorial ... http:\/\/www.tcl.tk\/software\/tcltk\/\" src=\"http:\/\/www.rjmprogramming.com.au\/TCL\/MacExample\/TCL_Example_4of.png\" title=\"Tcl\/Tk So Brilliant (but where do you start?) Primer Tutorial ... http:\/\/www.tcl.tk\/software\/tcltk\/\"  \/><\/a><p class=\"wp-caption-text\">Tcl\/Tk So Brilliant (but where do you start?) Primer Tutorial ... http:\/\/www.tcl.tk\/software\/tcltk\/<\/p><\/div>\n<p>Have you heard of Tcl\/Tk?<\/p>\n<blockquote><p>Tcl\/Tk is open source (based on a BSD-style license), so you can use it and modify it virtually any way you want, including for commercial uses.<\/p><\/blockquote>\n<p>With Tcl\/Tk have used in conjunction with C++ and Python (look out for Tkinter).<\/p>\n<p>Use it for Games Programming (it makes pretty cute GUIs &#8230; you may disagree?!) and it used to work back at Mac OS X 10.5.8\/XCode 3.0 (am going to try Mac OS X 10.7.5 &#8230; any advice anywhere?) and had it going on Windows XP with Visual Studio Express as well.   It has a lot of cross-platform strengths.<\/p>\n<p>Think Tcl\/Tk is really really good.<\/p>\n<p>In this primer  <a target=_blank title='click picture' href='http:\/\/www.rjmprogramming.com.au\/TCL\/MacExample\/'>tutorial<\/a> you can see a Draw Poker game as an XCode project, see it Build and in action, then see how to arrange for *.dmg Package Distribution via Package Manager.<\/p>\n<p>Link to Tcl\/Tk website &#8230; <a target=_blank href='http:\/\/www.tcl.tk\/software\/tcltk\/' title='Home of Tcl\/Tk'>Home of Tcl\/Tk &#8230; where quote up the top resides<\/a><br \/>\nLink to Tcl\/Tk jobs done &#8230; <a target=_blank href='http:\/\/www.rjmprogramming.com.au\/TCL\/' title='Examples of use of Tcl\/Tk'>Tcl\/Tk jobs done<\/a> &#8230; personal experience\n<\/p>\n<p>If this was interesting you may be interested in <a title='Click here to see topics in which you might be interested' href='#d664' onclick='var dv=document.getElementById(\"d664\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"http:\/\/www.rjmprogramming.com.au\/wordpress\/?cat=51\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d664' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n<hr \/>\n<p>If this was interesting you may be interested in <a title='Click here to see topics in which you might be interested' href='#d7144' onclick='var dv=document.getElementById(\"d7144\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"http:\/\/www.rjmprogramming.com.au\/wordpress\/?cat=51\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d7144' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Good news today is a breakthrough on a put-off project, getting Tcl\/Tk to work with Mac OS X Mavericks and Xcode 5.1 on a MacBook Pro laptop &#8230; answering, partially, the previous Tcl\/Tk So Brilliant (but where do you start?) &hellip; <a href=\"https:\/\/www.rjmprogramming.com.au\/ITblog\/tcltk-bats-and-ball-tutorial\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12,15,17,37,40],"tags":[176,571,707,725,735,758,997,1245,1246,1975,1319,1411,1473,1474],"class_list":["post-7144","post","type-post","status-publish","format-standard","hentry","category-elearning","category-games","category-gui","category-tutorials","category-xcode","tag-c","tag-homebrew","tag-linux","tag-mac-os-x","tag-macports","tag-mavericks","tag-programming","tag-tcl","tag-tcltk","tag-tk","tag-tutorial","tag-web-server","tag-xcode","tag-xcode-command-line-tools"],"_links":{"self":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/7144"}],"collection":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/comments?post=7144"}],"version-history":[{"count":2,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/7144\/revisions"}],"predecessor-version":[{"id":48444,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/7144\/revisions\/48444"}],"wp:attachment":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/media?parent=7144"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/categories?post=7144"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/tags?post=7144"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}