<?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 Sat May 25, 2013 4:37 pm by Linux Format forums</copyright>
  <managingEditor>webmaster@linuxformat.com</managingEditor>
  <webMaster>webmaster@linuxformat.com</webMaster>
  <pubDate>Sat May 25, 2013 4:37 pm</pubDate>
  <lastBuildDate>Sat May 25, 2013 4:37 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: Python</title>
                                        <link>http://linuxformat.com/forums/viewtopic.php?p=108446#108446</link>
                                        <description>&lt;br /&gt;
                                      Author: &lt;a href='http://linuxformat.com/forums/profile.php?mode=viewprofile&amp;u=1257'&gt;lok1950&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;
                                      Posted: Mon Oct 22, 2012 11:44 pm&lt;br /&gt;&lt;br /&gt;
                                      &lt;br /&gt;&lt;br /&gt;
                                      If you are using gedit or kwrite you can set syntax checking for a variety of languages.&lt;br /&gt;
&lt;br /&gt;
Enjoy the Choice &lt;img src=&quot;images/smiles/icon_smile.gif&quot; alt=&quot;Smile&quot; border=&quot;0&quot; /&gt;</description>
                                        <comments>http://linuxformat.com/forums/viewtopic.php?p=108446#108446</comments>
                                        <author>lok1950</author>
                                        <pubDate>Mon Oct 22, 2012 11:44 pm</pubDate>
                                        <guid isPermaLink="true">http://linuxformat.com/forums/viewtopic.php?p=108446#108446</guid>
                                      </item>
                                      <item>
                                        <title>Re: Python</title>
                                        <link>http://linuxformat.com/forums/viewtopic.php?p=108445#108445</link>
                                        <description>&lt;br /&gt;
                                      Author: &lt;a href='http://linuxformat.com/forums/profile.php?mode=viewprofile&amp;u=67853'&gt;RyanF109&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;
                                      Posted: Mon Oct 22, 2012 10:54 pm&lt;br /&gt;&lt;br /&gt;
                                      &lt;br /&gt;&lt;br /&gt;
                                      I fixed it. It was an indentation error. I'm not used to indentation being so important!</description>
                                        <comments>http://linuxformat.com/forums/viewtopic.php?p=108445#108445</comments>
                                        <author>RyanF109</author>
                                        <pubDate>Mon Oct 22, 2012 10:54 pm</pubDate>
                                        <guid isPermaLink="true">http://linuxformat.com/forums/viewtopic.php?p=108445#108445</guid>
                                      </item>
                                      <item>
                                        <title>Python</title>
                                        <link>http://linuxformat.com/forums/viewtopic.php?p=108437#108437</link>
                                        <description>&lt;br /&gt;
                                      Author: &lt;a href='http://linuxformat.com/forums/profile.php?mode=viewprofile&amp;u=67853'&gt;RyanF109&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;
                                      Posted: Mon Oct 22, 2012 3:55 pm&lt;br /&gt;&lt;br /&gt;
                                      &lt;br /&gt;&lt;br /&gt;
                                      I have kept all of my coding academy tutorials and today I started the process of working my way through them.&lt;br /&gt;
&lt;br /&gt;
I decided to play around with python and I am trying to create code that generates a random colour for the screen fill every time you click the mouse. But after spending a while fixing indentation errors now when I run it, it just quits with no error, as if one of the returns are being executed. Can anybody see any obvious errors in my code?&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;&lt;br /&gt;
#/usr/bin/python&lt;br /&gt;
&lt;br /&gt;
#import modules&lt;br /&gt;
import pygame&lt;br /&gt;
import os,random&lt;br /&gt;
&lt;br /&gt;
#define colour settings class&lt;br /&gt;
class colourset&amp;#40;&amp;#41;&amp;#58;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp;def __init__&amp;#40;self&amp;#41;&amp;#58;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;quot;&amp;quot;&amp;quot; colour settings &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp;def gencolour&amp;#40;self&amp;#41;&amp;#58;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;self.r = random.randint&amp;#40;0,255&amp;#41;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;self.g = random.randint&amp;#40;0,255&amp;#41;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;self.b = random.randint&amp;#40;0,255&amp;#41;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;return self&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp;def colourscreen&amp;#40;self,colour&amp;#41;&amp;#58;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;self.screensize = &amp;#40;800,600&amp;#41;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;self.screen = pygame.display.set_mode&amp;#40;self.screensize&amp;#41;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;pygame.display.set_caption&amp;#40;'Random Colour'&amp;#41;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;self.backdrop = pygame.Surface&amp;#40;self.screensize&amp;#41;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;self.backdrop.fill&amp;#40;&amp;#40;colour.r,colour.g,colour.b&amp;#41;&amp;#41;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;#refresh the screen by drawing everything again&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;#redrawthe background&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;self.screen.blit&amp;#40;self.backdrop, &amp;#40;0, 0&amp;#41;&amp;#41;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;#flip the buffer&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;pygame.display.flip&amp;#40;&amp;#41;&lt;br /&gt;
&lt;br /&gt;
def main&amp;#40;&amp;#41;&amp;#58;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;quot;&amp;quot;&amp;quot;the main game logic&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp;#Initialize Everything&lt;br /&gt;
&amp;nbsp; &amp;nbsp;pygame.init&amp;#40;&amp;#41;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp;colourinst = colourset&amp;#40;&amp;#41;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;colour = colourinst.gencolour&amp;#40;&amp;#41;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;colourinst.colourscreen&amp;#40;colour&amp;#41;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;clock = pygame.time.Clock&amp;#40;&amp;#41;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp;# control loop&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp;while 1&amp;#58;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;#adjust this timer to make the game harder or easier&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;clock.tick&amp;#40;130&amp;#41;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;#check what events Pygame has caught&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;for event in pygame.event.get&amp;#40;&amp;#41;&amp;#58;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; if event.type == pygame.QUIT&amp;#58;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;return&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; elif event.type == pygame.KEYDOWN and event.key == pygame.K_ESCAPE&amp;#58;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;return&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; elif event.type == pygame.MOUSEBUTTONDOWN&amp;#58;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;#button means mouse click&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;colourinst = colourset&amp;#40;&amp;#41;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;colour = colourinst.gencolour&amp;#40;&amp;#41;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;colourinst.colourscreen&amp;#40;colour&amp;#41;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;clock = pygame.time.Clock&amp;#40;&amp;#41;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp;if __name__ == '__main__'&amp;#58; &lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; main&amp;#40;&amp;#41;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; pygame.quit&amp;#40;&amp;#41;&lt;br /&gt;
&lt;/td&gt;	&lt;/tr&gt;&lt;/table&gt;&lt;span class=&quot;postbody&quot;&gt;[/code]</description>
                                        <comments>http://linuxformat.com/forums/viewtopic.php?p=108437#108437</comments>
                                        <author>RyanF109</author>
                                        <pubDate>Mon Oct 22, 2012 3:55 pm</pubDate>
                                        <guid isPermaLink="true">http://linuxformat.com/forums/viewtopic.php?p=108437#108437</guid>
                                      </item></channel></rss>