help<newbe>please!!

Alex Martelli aleaxit at yahoo.com
Wed Oct 11 08:50:22 EDT 2000


"grass hopper" <hopper_grass at hotmail.com> wrote in message
news:39e45032.5929225 at news.atl.bellsouth.net...
    [snip]
> this is going to sound stupid but i just don't no what it means whats
> this  e.g.  mean. Is it like ect. so-on?

"e.g." (for "exempli gratia", or "example given") is a common use
in English to abbreviate the idiom "for example".

> with .html. it works fine.But how ever i can't even get python to open
> a image.

One possibility is to use PIL, the Python Imaging Library module.
However, while this can _open_ images (and let you work on them
with various image-processing thingies) it's not necessarily best
if what you want is to DISPLAY the file on the screen (and let
the user interact, for example by clicking with the mouse...).

> do i have to call on the browser to open a image? if so how do i do
> this?

You can do that, yes.  For example, this very short Python
program:
    import os
    os.system("start c:/foo.jpg")
when run in a typical Windows installation, assuming you have
a picture called c:/foo.jpg, will ask whatever application you
have told Windows to associate to the extension .jpg (normally,
for example, Internet Explorer) to open and display the image.

But this is not necessarily a great help to you...!  For
example, if you do this twice for two image-files:
    import os
    os.system("start c:/foo.jpg")
    os.system("start c:/bar.jpg")
the second image will be displayed in the same Internet Explorer
window that was displaying the first one; so they will not both
be showing onscreen at the same time -- only the second one will
be left in view, and only using the browser's "Back" button will
the end-user be able to view the first one (again, I am referring
to a "typical" Windows installation).

If you do want to use your browser, then, to display both
images on-screen at once, you need to prepare (and feed to
your browser) a little HTML sourcefile -- for example...:

import os

images = ["c:/foo.jpg", "c:/bar.jpg"]

auxhtm = open("c:/foo.htm", "w")
for image in images:
    auxhtm.write("<IMG SRC=%s> " % image)
auxhtm.close()

os.system("start c:/foo.htm")


This will show both images at once, one below the other (if they're
too large to be shown together in this way, the browser will show a
scrollbar...).

This minimalist approach could perhaps suffice if you're content
of showing the images on screen in this fashion (perhaps with a
little text label on each -- you need to generate a little bit
more HTML for that, but not much), then let the user give his
desired response...:

> this is a short of the game
> you are asked :which is the pic of a cow
> there are 3 pic's to pick from like  01(pig.jpg) or 02(dog.jpg) or
> 03(cow.jpg).

...by entering the number in response to a Python "input" call,
i.e., from the keyboard (rather than clicking with the mouse on
the desired image).

> I really won't to learn python but this is really getting to me.

I'll assume you mean "want" ("desire") rather than "won't" ("will
not")...

> would someone show me the code to do this or point me
> in the right direction.
> I won't it to run in windows as a stand alone game
> I'm not asking for a handout just a hand
> I won't to wright the game in python .

My suggestion is perhaps the simplest way to go, but surely not
the most powerful.  You may use any of several Python graphical
user interface frameworks to display the images on the screen,
and detect mouse-clicks on one of them by the user...


Alex






More information about the Python-list mailing list