<?xml version="1.0" encoding="iso-8859-1"?>
<rss version="2.0">
<channel>
  <title>Linux Format forums</title>
  <link>http://linuxformat.com/forums/index.php</link>
  <description>Help, discussion, magazine feedback and more</description>
  <language>english</language>
  <copyright>(c) Copyright Tue May 21, 2013 8:47 pm by Linux Format forums</copyright>
  <managingEditor>webmaster@linuxformat.com</managingEditor>
  <webMaster>webmaster@linuxformat.com</webMaster>
  <pubDate>Tue May 21, 2013 8:47 pm</pubDate>
  <lastBuildDate>Tue May 21, 2013 8:47 pm</lastBuildDate>
  <docs>http://backend.userland.com/rss</docs>
  <generator>phpBB2 RSS Syndication Mod by Lucas</generator>
  <ttl>1</ttl>

  <image>
    <title>Linux Format forums</title>
    <url></url>
    <link>http://linuxformat.com/forums/</link>
    <description>Help, discussion, magazine feedback and more</description>
  </image>

                                      <item>
                                        <title>Re: Printing anywhere inside a Text Mode Python Window.</title>
                                        <link>http://linuxformat.com/forums/viewtopic.php?p=107525#107525</link>
                                        <description>&lt;br /&gt;
                                      Author: &lt;a href='http://linuxformat.com/forums/profile.php?mode=viewprofile&amp;u=58561'&gt;Bazza&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;
                                      Posted: Wed Aug 22, 2012 4:19 pm&lt;br /&gt;&lt;br /&gt;
                                      &lt;br /&gt;&lt;br /&gt;
                                      Thanks... ;o)&lt;br /&gt;
&lt;br /&gt;
Just got an Apple MacBook Pro OSX 10.7.3 and Python 2.7.1 and the above code works on that too.&lt;br /&gt;
&lt;br /&gt;
Just run Python from a Terminal to test...</description>
                                        <comments>http://linuxformat.com/forums/viewtopic.php?p=107525#107525</comments>
                                        <author>Bazza</author>
                                        <pubDate>Wed Aug 22, 2012 4:19 pm</pubDate>
                                        <guid isPermaLink="true">http://linuxformat.com/forums/viewtopic.php?p=107525#107525</guid>
                                      </item>
                                      <item>
                                        <title>Re: Printing anywhere inside a Text Mode Python Window.</title>
                                        <link>http://linuxformat.com/forums/viewtopic.php?p=107360#107360</link>
                                        <description>&lt;br /&gt;
                                      Author: &lt;a href='http://linuxformat.com/forums/profile.php?mode=viewprofile&amp;u=68214'&gt;scarydeath&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;
                                      Posted: Sun Aug 12, 2012 6:26 pm&lt;br /&gt;&lt;br /&gt;
                                      &lt;br /&gt;&lt;br /&gt;
                                      Love the comments, if only more programmers had the same style  &lt;img src=&quot;images/smiles/icon_cool.gif&quot; alt=&quot;Cool&quot; border=&quot;0&quot; /&gt;</description>
                                        <comments>http://linuxformat.com/forums/viewtopic.php?p=107360#107360</comments>
                                        <author>scarydeath</author>
                                        <pubDate>Sun Aug 12, 2012 6:26 pm</pubDate>
                                        <guid isPermaLink="true">http://linuxformat.com/forums/viewtopic.php?p=107360#107360</guid>
                                      </item>
                                      <item>
                                        <title>Printing anywhere inside a Text Mode Python Window.</title>
                                        <link>http://linuxformat.com/forums/viewtopic.php?p=107358#107358</link>
                                        <description>&lt;br /&gt;
                                      Author: &lt;a href='http://linuxformat.com/forums/profile.php?mode=viewprofile&amp;u=58561'&gt;Bazza&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;
                                      Posted: Sun Aug 12, 2012 3:56 pm&lt;br /&gt;&lt;br /&gt;
                                      &lt;br /&gt;&lt;br /&gt;
                                      Read the code for more information.&lt;br /&gt;
&lt;br /&gt;
It was originally designed for a stock AMIGA A1200(HD) and Python Version 1.4.0, but has since been updated to suit Linux and Python Versions 3.x.x...&lt;br /&gt;
&lt;br /&gt;
&lt;/span&gt;&lt;table width=&quot;90%&quot; cellspacing=&quot;1&quot; cellpadding=&quot;3&quot; border=&quot;0&quot; align=&quot;center&quot;&gt;&lt;tr&gt; 	  &lt;td&gt;&lt;span class=&quot;genmed&quot;&gt;&lt;b&gt;Code:&lt;/b&gt;&lt;/span&gt;&lt;/td&gt;	&lt;/tr&gt;	&lt;tr&gt;	  &lt;td class=&quot;code&quot;&gt;# Locate_Demo.py&lt;br /&gt;
#&lt;br /&gt;
# A DEMO showing the power of the ANSI &amp;#40;ASCII&amp;#41; _Esc_ codes in standard text mode Python.&lt;br /&gt;
# This test code was originally written in 2007 for Python 1.4.0 on a standard AMIGA A1200&amp;#40;HD&amp;#41;.&lt;br /&gt;
# It is now brought up to date and ALSO works on Linux up to Python 3.2.2...&lt;br /&gt;
# This code works on Classic AMIGAs, WinUAE and E-UAE using AmigaOS 3.1x and Python&lt;br /&gt;
# Version&amp;#40;s&amp;#41; 1.4.0 to 2.0.1, PcLinuxOS 2009 using Python 2.5.2, 2.6.1 and 3.2.2 and&lt;br /&gt;
# Debian Linux using Python 2.6.6, 2.7.2 and 3.1.3.&lt;br /&gt;
#&lt;br /&gt;
# ANSI _Esc_ codes here&amp;#58;-&amp;nbsp; &amp;nbsp; http&amp;#58;//www.termsys.demon.co.uk/vtansi.htm&lt;br /&gt;
#&lt;br /&gt;
# It draws a text mode triangle inside a Python Terminal, writes a string inside that triangle,&lt;br /&gt;
# writes a string BELOW the triangle and then resets the cursor to the top of the screen awaiting&lt;br /&gt;
# user input. After pressing the &amp;lt;CR&amp;gt; key the screen is cleared and a new text mode _sine_wave_&lt;br /&gt;
# graph is plotted, again awaiting user input to clear the screen, finally placing the cursor at&lt;br /&gt;
# the top of the Terminal window along with the default string being printed...&lt;br /&gt;
# It uses a simple function to draw an ASCII character or string on screen starting at a given,&lt;br /&gt;
# &amp;#91;column, line&amp;#93;, location.&lt;br /&gt;
#&lt;br /&gt;
# This function is as thus&amp;#58;-&lt;br /&gt;
#&lt;br /&gt;
# &amp;gt;&amp;gt;&amp;gt; locate&amp;#40;user_string, horizontal_position, vertical_position&amp;#41;&amp;lt;CR&amp;gt;&lt;br /&gt;
#&lt;br /&gt;
# &amp;lt;user_string&amp;gt; is a string type, and, &amp;lt;horizontal_position&amp;gt; and &amp;lt;vertical_position&amp;gt; are inetger&lt;br /&gt;
# types from 0, &amp;#40;zero&amp;#41; to 255...&lt;br /&gt;
#&lt;br /&gt;
# The easiest way to run this code, &amp;#40;depending upon the platform&amp;#41;, is to type......&lt;br /&gt;
#&lt;br /&gt;
# &amp;gt;&amp;gt;&amp;gt; exec&amp;#40;open&amp;#40;&amp;quot;/full/path/to/Locate_Demo.py&amp;quot;&amp;#41;.read&amp;#40;&amp;#41;&amp;#41;&amp;lt;CR&amp;gt;&lt;br /&gt;
#&lt;br /&gt;
# ......and away you go.&lt;br /&gt;
#&lt;br /&gt;
# $VER&amp;#58; Locate_Demo.py_Version_0.00.10_&amp;#40;C&amp;#41;2007-2012_B.Walker_G0LCU.&lt;br /&gt;
&lt;br /&gt;
# The only imports required for this demo...&lt;br /&gt;
import math&lt;br /&gt;
import sys&lt;br /&gt;
&lt;br /&gt;
# Make the whole code 3.x.x compatible too...&lt;br /&gt;
if sys.version&amp;#91;0&amp;#93;==&amp;quot;3&amp;quot;&amp;#58; raw_input=input&lt;br /&gt;
&lt;br /&gt;
# The only _varaibles_ required for this DEMO...&lt;br /&gt;
char=&amp;quot;*&amp;quot;&lt;br /&gt;
x=20&lt;br /&gt;
y=19&lt;br /&gt;
&lt;br /&gt;
# A Simple clear screen command for this DEMO...&lt;br /&gt;
for n in range&amp;#40;0, 64, 1&amp;#41;&amp;#58; print&amp;#40;&amp;quot;\r\n&amp;quot;&amp;#41;&lt;br /&gt;
&lt;br /&gt;
# This function is just basic for this DEMO but shows the power of the ANSI _Esc_ codes...&lt;br /&gt;
def locate&amp;#40;user_string=&amp;quot;$VER&amp;#58; Locate_Demo.py_Version_0.00.10_&amp;#40;C&amp;#41;2007-2012_B.Walker_G0LCU.&amp;quot;, x=0, y=0&amp;#41;&amp;#58;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;# Don't allow any user errors. Python's own error detection will check for&lt;br /&gt;
&amp;nbsp; &amp;nbsp;# syntax and concatination, etc, etc, errors.&lt;br /&gt;
&amp;nbsp; &amp;nbsp;x=int&amp;#40;x&amp;#41;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;y=int&amp;#40;y&amp;#41;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;if x&amp;gt;=255&amp;#58; x=255&lt;br /&gt;
&amp;nbsp; &amp;nbsp;if y&amp;gt;=255&amp;#58; y=255&lt;br /&gt;
&amp;nbsp; &amp;nbsp;if x&amp;lt;=0&amp;#58; x=0&lt;br /&gt;
&amp;nbsp; &amp;nbsp;if y&amp;lt;=0&amp;#58; y=0&lt;br /&gt;
&amp;nbsp; &amp;nbsp;HORIZ=str&amp;#40;x&amp;#41;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;VERT=str&amp;#40;y&amp;#41;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;# Plot the user_string at the starting position HORIZ, VERT...&lt;br /&gt;
&amp;nbsp; &amp;nbsp;print&amp;#40;&amp;quot;\033&amp;#91;&amp;quot;+VERT+&amp;quot;;&amp;quot;+HORIZ+&amp;quot;f&amp;quot;+user_string&amp;#41;&lt;br /&gt;
&lt;br /&gt;
# Plot the upwards slope of the triangle...&lt;br /&gt;
while x&amp;lt;=35&amp;#58;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;locate&amp;#40;char, x, y&amp;#41;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;x=x+1&lt;br /&gt;
&amp;nbsp; &amp;nbsp;y=y-1&lt;br /&gt;
&lt;br /&gt;
# Plot the downwards slope of the triangle...&lt;br /&gt;
while x&amp;lt;=52&amp;#58;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;locate&amp;#40;char, x, y&amp;#41;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;x=x+1&lt;br /&gt;
&amp;nbsp; &amp;nbsp;y=y+1&lt;br /&gt;
&lt;br /&gt;
# Plot the base of the triangle...&lt;br /&gt;
char=&amp;quot;***********************************&amp;quot;&lt;br /&gt;
locate&amp;#40;char, 19, 20&amp;#41;&lt;br /&gt;
&lt;br /&gt;
# Write a string inside the triangle...&lt;br /&gt;
char=&amp;quot;Drawing in text mode Python.&amp;quot;&lt;br /&gt;
locate&amp;#40;char, 23, 18&amp;#41;&lt;br /&gt;
&lt;br /&gt;
# Print this line BELOW the triangle...&lt;br /&gt;
print&amp;#40;&amp;quot;\n\n\nCursor now set to the top.&amp;quot;&amp;#41;&lt;br /&gt;
# NOW reset the cursor back to the top of the window using the default x and y values.&lt;br /&gt;
locate&amp;#40;&amp;quot;&amp;quot;&amp;#41;&lt;br /&gt;
&lt;br /&gt;
# Hold drawing until user input for sine wave plot...&lt;br /&gt;
char=raw_input&amp;#40;&amp;quot;Press &amp;lt;CR&amp;gt; to continue with a _sine_ wave&amp;#58;- &amp;quot;&amp;#41;&lt;br /&gt;
&lt;br /&gt;
# A Simple clear screen command for this DEMO...&lt;br /&gt;
for n in range&amp;#40;0, 64, 1&amp;#41;&amp;#58; print&amp;#40;&amp;quot;\r\n&amp;quot;&amp;#41;&lt;br /&gt;
&lt;br /&gt;
char=&amp;quot;*&amp;quot;&lt;br /&gt;
x=3&lt;br /&gt;
y=12&lt;br /&gt;
&lt;br /&gt;
# Now plot a sinewave curve inside the Terminal.&lt;br /&gt;
for angle in range&amp;#40;0, 360, 5&amp;#41;&amp;#58;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;# Generate a FLOATING point sine&amp;#40;angle&amp;#41; value...&lt;br /&gt;
&amp;nbsp; &amp;nbsp;angle=float&amp;#40;angle&amp;#41;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;y=math.sin&amp;#40;&amp;#40;angle*&amp;#40;math.pi&amp;#41;&amp;#41;/180.0&amp;#41;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;# INVERT, AND, keep the y scan inside the standard Terminal window size.&lt;br /&gt;
&amp;nbsp; &amp;nbsp;y=12-&amp;#40;int&amp;#40;y*10&amp;#41;&amp;#41;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;locate&amp;#40;char, x, y&amp;#41;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;# Move along one, &amp;#40;1&amp;#41;, x position.&lt;br /&gt;
&amp;nbsp; &amp;nbsp;x=x+1&lt;br /&gt;
&lt;br /&gt;
# Hold drawing until user input for a final clear screen...&lt;br /&gt;
char=raw_input&amp;#40;&amp;quot;\n\n\n\n\n\n\n\n\n\nPress &amp;lt;CR&amp;gt; to clear the screen, display the default string, and stop&amp;#58;- &amp;quot;&amp;#41;&lt;br /&gt;
&lt;br /&gt;
# A Simple clear screen command for this DEMO...&lt;br /&gt;
for n in range&amp;#40;0, 64, 1&amp;#41;&amp;#58; print&amp;#40;&amp;quot;\r\n&amp;quot;&amp;#41;&lt;br /&gt;
&lt;br /&gt;
# NOW reset the cursor back to the top of the window using the default x and y values&lt;br /&gt;
# and display the locate&amp;#40;&amp;#41; function's default string...&lt;br /&gt;
locate&amp;#40;&amp;#41;&lt;br /&gt;
&lt;br /&gt;
# End of Locate_Demo.py Python code...&lt;br /&gt;
# Enjoy finding simple solutions to often very difficult problems...&lt;br /&gt;
&lt;/td&gt;	&lt;/tr&gt;&lt;/table&gt;&lt;span class=&quot;postbody&quot;&gt;</description>
                                        <comments>http://linuxformat.com/forums/viewtopic.php?p=107358#107358</comments>
                                        <author>Bazza</author>
                                        <pubDate>Sun Aug 12, 2012 3:56 pm</pubDate>
                                        <guid isPermaLink="true">http://linuxformat.com/forums/viewtopic.php?p=107358#107358</guid>
                                      </item></channel></rss>