<?xml version="1.0" encoding="iso-8859-1"?>
<rss version="2.0">
<channel>
  <title>Linux Format forums</title>
  <link>http://www.linuxformat.com/forums/index.php</link>
  <description>Help, discussion, magazine feedback and more</description>
  <language>english</language>
  <copyright>(c) Copyright Fri May 24, 2013 7:22 pm by Linux Format forums</copyright>
  <managingEditor>webmaster@linuxformat.com</managingEditor>
  <webMaster>webmaster@linuxformat.com</webMaster>
  <pubDate>Fri May 24, 2013 7:22 pm</pubDate>
  <lastBuildDate>Fri May 24, 2013 7:22 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://www.linuxformat.com/forums/</link>
    <description>Help, discussion, magazine feedback and more</description>
  </image>

                                      <item>
                                        <title>Re: Python modules, anyone?</title>
                                        <link>http://www.linuxformat.com/forums/viewtopic.php?p=569#569</link>
                                        <description>&lt;br /&gt;
                                      Author: &lt;a href='http://www.linuxformat.com/forums/profile.php?mode=viewprofile&amp;u=4'&gt;evilnick&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;
                                      Posted: Thu Apr 14, 2005 10:11 am&lt;br /&gt;&lt;br /&gt;
                                      &lt;br /&gt;&lt;br /&gt;
                                      Are the graphics going to be persistent ? Ar eyou always going to use the same graphics with this module? You could set up some static objects in the module.&lt;br /&gt;
&lt;br /&gt;
But usually, the answer would be to have the main.py initiate the class and pass the relevant item to other functions:&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;
# set up gui and load graphics &amp;#40;all in constructor code&amp;#41;&lt;br /&gt;
import spqr_gui&lt;br /&gt;
my_gui=spqr_gui.game_gui&amp;#40;SCREEN_WIDTH,SCREEN_HEIGHT&amp;#41;&lt;br /&gt;
...&lt;br /&gt;
widget_function&amp;#40;my_gui.images&amp;#91;WINDOW_TOP_LEFT&amp;#93;.image&amp;#41;&lt;br /&gt;
&lt;/td&gt;	&lt;/tr&gt;&lt;/table&gt;&lt;span class=&quot;postbody&quot;&gt;&lt;br /&gt;
&lt;br /&gt;
Alternatively, you can import the gui graphics module into the widget code and just pass the reference to my_gui.&lt;br /&gt;
&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;
# set up gui and load graphics &amp;#40;all in constructor code&amp;#41;&lt;br /&gt;
import spqr_gui&lt;br /&gt;
my_gui=spqr_gui.game_gui&amp;#40;SCREEN_WIDTH,SCREEN_HEIGHT&amp;#41;&lt;br /&gt;
...&lt;br /&gt;
widget_function&amp;#40;my_gui&amp;#41;&lt;br /&gt;
&lt;/td&gt;	&lt;/tr&gt;&lt;/table&gt;&lt;span class=&quot;postbody&quot;&gt;</description>
                                        <comments>http://www.linuxformat.com/forums/viewtopic.php?p=569#569</comments>
                                        <author>evilnick</author>
                                        <pubDate>Thu Apr 14, 2005 10:11 am</pubDate>
                                        <guid isPermaLink="true">http://www.linuxformat.com/forums/viewtopic.php?p=569#569</guid>
                                      </item>
                                      <item>
                                        <title>Re: Python modules, anyone?</title>
                                        <link>http://www.linuxformat.com/forums/viewtopic.php?p=483#483</link>
                                        <description>&lt;br /&gt;
                                      Author: &lt;a href='http://www.linuxformat.com/forums/profile.php?mode=viewprofile&amp;u=303'&gt;maximinus&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;
                                      Posted: Tue Apr 12, 2005 11:49 pm&lt;br /&gt;&lt;br /&gt;
                                      &lt;br /&gt;&lt;br /&gt;
                                      Code example:&lt;br /&gt;
&lt;br /&gt;
In main.py:&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;# set up gui and load graphics &amp;#40;all in constructor code&amp;#41;&lt;br /&gt;
import spqr_gui&lt;br /&gt;
my_gui=spqr_gui.game_gui&amp;#40;SCREEN_WIDTH,SCREEN_HEIGHT&amp;#41;&lt;/td&gt;	&lt;/tr&gt;&lt;/table&gt;&lt;span class=&quot;postbody&quot;&gt;&lt;br /&gt;
&lt;br /&gt;
somewhere in a widgets module&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;# draw the image&lt;br /&gt;
base_image=my_gui.images&amp;#91;WINDOW_TOP_LEFT&amp;#93;.image&lt;/td&gt;	&lt;/tr&gt;&lt;/table&gt;&lt;span class=&quot;postbody&quot;&gt;&lt;br /&gt;
&lt;br /&gt;
This fails because my_gui is not yet known when it looks at the widgets module. I &lt;span style=&quot;font-style: italic&quot;&gt;could&lt;/span&gt; pass my_gui every time I use a function in another module, but this doesn't seem a neat way of doing it at all.&lt;br /&gt;
I need some way of storing the graphics in a way that they can be seen by many other modules that use this data.</description>
                                        <comments>http://www.linuxformat.com/forums/viewtopic.php?p=483#483</comments>
                                        <author>maximinus</author>
                                        <pubDate>Tue Apr 12, 2005 11:49 pm</pubDate>
                                        <guid isPermaLink="true">http://www.linuxformat.com/forums/viewtopic.php?p=483#483</guid>
                                      </item>
                                      <item>
                                        <title>RE: Python modules, anyone?</title>
                                        <link>http://www.linuxformat.com/forums/viewtopic.php?p=474#474</link>
                                        <description>&lt;br /&gt;
                                      Author: &lt;a href='http://www.linuxformat.com/forums/profile.php?mode=viewprofile&amp;u=4'&gt;evilnick&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;
                                      Posted: Tue Apr 12, 2005 11:12 pm&lt;br /&gt;&lt;br /&gt;
                                      &lt;br /&gt;&lt;br /&gt;
                                      Everything in python breaks down into objects. You can use that to pass objects between modules etc., and you may want to import modules from modules. &lt;br /&gt;
It sounds like your widget module wants to import from your graphics module. difficult to say without some example code</description>
                                        <comments>http://www.linuxformat.com/forums/viewtopic.php?p=474#474</comments>
                                        <author>evilnick</author>
                                        <pubDate>Tue Apr 12, 2005 11:12 pm</pubDate>
                                        <guid isPermaLink="true">http://www.linuxformat.com/forums/viewtopic.php?p=474#474</guid>
                                      </item>
                                      <item>
                                        <title>Python modules, anyone?</title>
                                        <link>http://www.linuxformat.com/forums/viewtopic.php?p=469#469</link>
                                        <description>&lt;br /&gt;
                                      Author: &lt;a href='http://www.linuxformat.com/forums/profile.php?mode=viewprofile&amp;u=303'&gt;maximinus&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;
                                      Posted: Tue Apr 12, 2005 10:49 pm&lt;br /&gt;&lt;br /&gt;
                                      &lt;br /&gt;&lt;br /&gt;
                                      Any python coders out there? I am having problems with my own modules. (I'm trying to code a python/pygame gui.)&lt;br /&gt;
&lt;br /&gt;
Basically I have a gfx class which stores all the graphics, which is in it's own seperate module. Next I have the window widget classes, in another module, which need to be able to access those graphics. The trouble is, I create the instance of the gfx class in my main .py file, and then need to use this in the seperate modules - which python doesn't let me do &lt;img src=&quot;images/smiles/icon_sad.gif&quot; alt=&quot;Sad&quot; border=&quot;0&quot; /&gt;&lt;br /&gt;
&lt;br /&gt;
If I write all the modules out in a single text file, the code works. When it gets broken into modules, I get problems. Am I missing something obvious, or is there a neat solution?</description>
                                        <comments>http://www.linuxformat.com/forums/viewtopic.php?p=469#469</comments>
                                        <author>maximinus</author>
                                        <pubDate>Tue Apr 12, 2005 10:49 pm</pubDate>
                                        <guid isPermaLink="true">http://www.linuxformat.com/forums/viewtopic.php?p=469#469</guid>
                                      </item></channel></rss>