kevin hayes | 1 Nov 02:19 2007
Picon

Re: Help with the 3rd Lecture, first tutorial

(1) I run python by c:\Python25>Python <Enter>

Once in the interpreter, I can import the pygame modules, initialize Python, make a window, but when I try to set the caption it won't work. I did get it to work in the GUI, however.
 
pygame.display.set_caption('Monkey Fever')

(2) C:\Program Files\examples\data\chimp.bmp   "Is the path to the image"

When trying to load the image with:

monkey_head_file_name = os.path.join("data","chimp.bmp")
>>> print monkey_head_file_name "Creating a relative Path"
data\chimp.bmp

monkey_surface = pygame.image.load(monkey_head_file_name) "From the tutorial...trying to load the image"






On 10/31/07, Ethan Glasser-Camp <glasse-CXiM98XSapA3uPMLIKxrzw@public.gmane.org> wrote:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Michael George wrote:
> Everything after the > is what you type at the dos prompt.  Everything
> after the >>> is what you type at the python prompt.  Everything else is
> what you should expect the system to respond

It's a little more complicated than that, of course:

>>     >>> file = open("file.txt")
>>     >>> Traceback (etc...)

You aren't supposed to type "Traceback (etc...)". Lukasz believes you
may get a traceback here from an error (for example, a file-not-found
error).

>>     >>> [ctrl+d]

This presumably means "press Ctrl-D" rather than "type [ctrl+d]". I'm
not sure if this is correct; I thought on Windows, EOF is Ctrl-Z? But
I wouldn't swear to it.

>>     > cd files
>>     > dir
>>     file.txt
>>     > python
>>     >>> file = open("file.txt")    (and it work!)

And here "(and it work!)" is presumably a comment.

However, if I were you, Kevin Hayes, I would refine what I meant by
"won't load". I believe Lukasz believes that you are getting "Cannot
find file" errors, and he is trying to show you how to find your way
around DOS and how your current directory interacts with Python.

If you are getting file-not-found errors, it may help to explain your
situation further -- what directory are you running Python from? What
directory is chimp.bmp in? And so on.

Ethan
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFHKNS6hRlgoLPrRPwRAoQAAJsENCwdxB2zBNEWH5QYL91lPMva5gCfYatO
NWVybH/zprshjUxUMHAMtOk=
=DS9h
-----END PGP SIGNATURE-----

Ethan Glasser-Camp | 1 Nov 02:44 2007
Picon

Re: Help with the 3rd Lecture, first tutorial


kevin hayes wrote:
> (1) I run python by c:\Python25>Python <Enter>
> 
> Once in the interpreter, I can import the pygame modules, initialize
> Python, make a window, but when I try to set the caption it won't work.
> I did get it to work in the GUI, however.
>  
> pygame.display.set_caption('Monkey Fever')
> 
> (2) C:\Program Files\examples\data\chimp.bmp   "Is the path to the image"
> 
> When trying to load the image with:
> 
> monkey_head_file_name = 
> os.path.join("data","chimp.bmp")
>>>> print monkey_head_file_name                             "Creating a relative Path"
> 
> data\chimp.bmp
> 
> monkey_surface = pygame.image.load(monkey_head_file_name)    "From the tutorial...trying to load the image"

Seems to me that the tutorial expects you to be running python from
inside the c:\Program Files\examples directory. Lukasz has tried to
explain how to change directory to that directory and then run Python,
and RR4CLB has put together some batch scripts for you to run Python
from that directory. You could also use the os.chdir function, as
follows (on a Linux system):

>>> import os
>>> os.getcwd()
'/home/ethan'
>>> os.chdir("/home/ethan/tests/")
>>> os.getcwd()
'/home/ethan/tests'

If you chdir() to 'c:\Program Files\examples', you should be able to
run the examples directly as written.

Hope this helps!

Ethan
Jonah Fishel | 1 Nov 03:04 2007
Picon
Picon

Quick question from newbie

If I had this:

def print_i(i):
	if i == range(1, 9):
		print "It worked!"
	else:
		print "Bummer!"

print_i(6)

Why would I get Bummer! every time? Am I misusing range()?

Thanks,
globalp

Michael George | 1 Nov 03:10 2007
Picon

Re: Quick question from newbie

Yes you are.  "if i == range(1,9)" compares i against the iterator 
returned by the range function.  Assuming i is a number, it will never 
be equal (since a number is not an iterator).  Your function would print 
"It worked!" if you called print_i(range(1,9)).

I think what you probably want is "if 1 <= i < 9" or something similar.  
You could equivalently write "if i in range(1,9)" but the other way is 
preferred because using in like this actually loops over every number 
between 1 and 9 and checks whether that number is equal to i.

Hope this helps,

Mike

Jonah Fishel wrote:
> If I had this:
>
> def print_i(i):
>     if i == range(1, 9):
>         print "It worked!"
>     else:
>         print "Bummer!"
>
> print_i(6)
>
> Why would I get Bummer! every time? Am I misusing range()?
>
> Thanks,
> globalp

Michael George | 1 Nov 03:20 2007
Picon

Re: Quick question from newbie

Michael George wrote:
> Yes you are.  "if i == range(1,9)" compares i against the iterator 
> returned by the range function.  Assuming i is a number, it will never 
> be equal (since a number is not an iterator).  Your function would 
> print "It worked!" if you called print_i(range(1,9)).
Actually to correct myself range returns a list, xrange returns an 
iterator.

Stefan Huchler | 1 Nov 03:23 2007
Picon

pygame hangs with some mp3 files and hangs the hole prozess

Hi,

i wrote it on irc but nobody was there. so i post it again here:

 >>> import pygame
 >>> pygame.mixer.init()
 >>> pygame.mixer.load('test.mp3')
 >>> pygame.mixer.music.play()
 >>> pygame.mixer.music.play()
 so i have some mp3 files
 with them pygame dies
 and when i play the next it hangs
can i do there something? i wanted a preview song-playing function in my game
 the files play with mplayer
 or xmms
can i reset pygame in such case or so
 i have a try catch around it and it does not go in catch
i can send you the mp3 if that helps but i have some that hangs with pygame
 by the way if someone likes to test our game http://lobtoc.org/canta/

k i have the same results under gentoo and pygame with there versions.
I dont hope that you get all this mp3s working soon it could be that
there are buggy, but i hope there is a way that a buggy mp3 dont kill
the hole prozess.

RR4CLB | 1 Nov 04:44 2007
Picon

Re: Help with the 3rd Lecture, first tutorial


Yes!

    For the path function inside the program is only looking at the file in the directory directly below the
python25. Thus it will always fail unless he changes the path to the file directly. Kevin when you load the
Python25 you have placed the path as that location, in the Python25. 

    I set the file path to change in the batch files so when you load Python25 you also have that directory path at
the moment of loading. Now if you want to do this with your way of doing then you will just make the batch file
to do it but leave out the %1.py for that loads your command line data...%1 %2 %3...

Or like this inside your batch file:
 c:\python25\examples\python25 
Making batch file for example directory:
type: copy con: xpy.bat <enter>
c:\python25\examples\python25 <enter>
ctrlz <enter>
     1/file copied!

    The path is c:\python25\examples\data when the program looks for it. Not in the program files directory
when doing the example as is!
Or: you can change the os.path to place the c:\program files\data to find it, but that means do not use os.path.

    So, do what you wish but try and keep all work files inside the directory consistently. In other words while
testing keep then beneath the python directory or everything in the program files. But for safety sake and
viruses it may be better to have something away from the c drive. Only a thought and if you do have a multiple
drive system.

        Bruce

----- Original Message ----- 
From: "Ethan Glasser-Camp" <glasse@...>
Sent: Wednesday, October 31, 2007 8:44 PM
Subject: Re: [pygame] Help with the 3rd Lecture, first tutorial

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

kevin hayes wrote:
> (1) I run python by c:\Python25>Python <Enter>
> 
> Once in the interpreter, I can import the pygame modules, initialize
> Python, make a window, but when I try to set the caption it won't work.
> I did get it to work in the GUI, however.
>  
> pygame.display.set_caption('Monkey Fever')
> 
> (2) C:\Program Files\examples\data\chimp.bmp   "Is the path to the image"
> 
> When trying to load the image with:
> 
> monkey_head_file_name = 
> os.path.join("data","chimp.bmp")
>>>> print monkey_head_file_name                             "Creating a relative Path"
> 
> data\chimp.bmp
> 
> monkey_surface = pygame.image.load(monkey_head_file_name)    "From the tutorial...trying to load the image"

Seems to me that the tutorial expects you to be running python from
inside the c:\Program Files\examples directory. Lukasz has tried to
explain how to change directory to that directory and then run Python,
and RR4CLB has put together some batch scripts for you to run Python
from that directory. You could also use the os.chdir function, as
follows (on a Linux system):

>>> import os
>>> os.getcwd()
'/home/ethan'
>>> os.chdir("/home/ethan/tests/")
>>> os.getcwd()
'/home/ethan/tests'

If you chdir() to 'c:\Program Files\examples', you should be able to
run the examples directly as written.

Hope this helps!

Ethan
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFHKS91hRlgoLPrRPwRAsTUAJ9da7op3jDVOom0vHNJxlDsQS0EVQCgjLAo
bGHnlPOsO+VV6WuuSqX4L4I=
=MPsQ
-----END PGP SIGNATURE-----

--

-- 
No virus found in this incoming message.
Checked by AVG Free Edition. 
Version: 7.5.503 / Virus Database: 269.15.15/1101 - Release Date: 10/31/2007 10:06 AM

RR4CLB | 1 Nov 05:03 2007
Picon

Re: Quick question from newbie


Yes and also remember that when doing the range remember that having sequential numbers or letters they do
not always follow logic such as different character code lists do not. So when using range use the in to look
at the list and not a sequence of numbers. Unless you want a sequence to look at. The best example is the
EBCDIC code list. There a, b, c does not mean 1, 2, 3...in terms being in a direct sequence

        Bruce

----- Original Message ----- 
From: "Michael George" <mdgeorge@...>
To: <pygame-users@...>
Sent: Wednesday, October 31, 2007 9:20 PM
Subject: Re: [pygame] Quick question from newbie

Michael George wrote:
> Yes you are.  "if i == range(1,9)" compares i against the iterator 
> returned by the range function.  Assuming i is a number, it will never 
> be equal (since a number is not an iterator).  Your function would 
> print "It worked!" if you called print_i(range(1,9)).
Actually to correct myself range returns a list, xrange returns an 
iterator.

John Popplewell | 1 Nov 04:04 2007
Picon
Picon

Re: Help with the 3rd Lecture, first tutorial

On Wed, Oct 31, 2007 at 06:19:37PM -0700, kevin hayes wrote:
> (1) I run python by c:\Python25>Python <Enter>
> 
> Once in the interpreter, I can import the pygame modules, initialize Python,
> make a window, but when I try to set the caption it won't work. I did get it
> to work in the GUI, however.
> 
> pygame.display.set_caption('Monkey Fever')
> 
> (2) C:\Program Files\examples\data\chimp.bmp   "Is the path to the image"
> 
> When trying to load the image with:
> 
> monkey_head_file_name = os.path.join("data","chimp.bmp")
> >>> print monkey_head_file_name                             "Creating
> a relative Path"
> data\chimp.bmp
> 
> monkey_surface = pygame.image.load(monkey_head_file_name)    "From the
> tutorial...trying to load the image"
Hi,

I'd do it the other way round. Add C:\Python25 to your system path like
this:

Right-click on My Computer (on the desktop), select 'Properties' at the
bottom and then click on the 'Advanced' tab. At the bottom, click on the
'Environment Variables' button, and look at the 'System variables' list
in the bottom half. Scroll-down until you can see 'Path' in the
left-hand column and double-click on it. The 'Variable value:' field
should be high-lighted. Hit the 'End' key or use the mouse and cursor
keys and then *add* ';C:\Python25' (without the quotes). The end of mine
now looks like this:

...blah...blah;e:\programs\kdiff3;C:\Python25

If you have any 'accidents' make sure you click on the Cancel button and
try again.

When you are happy with it click the OK button and OK your way out of
the dialogs.

Note: it's a shame this isn't a Python installer option, but I can think
of at least one good reason why it isn't :-)

Close any currently running Windows Command Prompts (the environment is
setup when the shell is started) and then download the 'Open Command
Window Here' PowerToy from Microsoft on this page:

http://www.microsoft.com/windowsxp/downloads/powertoys/xppowertoys.mspx

and install it. It adds a context-menu (right-click) item 'Open Command
Window Here' to the Windows Explorer (not IE).

Now, using the Windows Explorer, navigate to the 
'C:\Program Files\examples\' directory, right-click on it and select
'Open Command Window Here'. This should open a Windows Command Prompt with
the current directory set to the examples directory.

I find this invaluable, but that might just be me.

Type Python in the shell (if it doesn't work the path is not set
correctly) and Python will start.

Your problem (2) with the relative path will be fixed now, because the
files are loaded relative to the current working directory.

I don't know about problem (1).

Hope that helps,
John.

Ian Mallett | 1 Nov 04:50 2007
Picon

Re: Re: [pygtk] Relative mouse controlled game in gtk

On 10/31/07, Greg Ewing <greg.ewing-F+z8Qja7x9Xokq/tPzqvJg@public.gmane.org> wrote:

Thomas Dybdahl Ahle wrote:
> You want to know when the mose moves?

What I want is:

* No mouse cursor is visible.

* All mouse movements reported as relative movements,
   with no restrictions from hitting the edges of the
   screen.

* No danger of accidentally clicking on something
   outside of the application with the invisible
   mouse.

If it's necessary to make the window fill the whole
screen to achieve all of these, that's okay, but
it would be a bonus if this were not needed.

--
Greg
You can already do most of that with Pygame, and the pygame.mouse module works with OpenGL.

Gmane