#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    4
    Rep Power
    0

    Python (pyGame Graphics) HELP! PLEASE :)


    Hey guys. I know that this may a be a really dumb question and all. I was however, wondering how (using pygame), one could create a program to display this picture:

    lorenzod8n.files.wordpress(dot)com/2007/05/fishnet.png

    Please help. It would be greatly appreciated. Truly.
  2. #2
  3. Contributing User
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Aug 2011
    Posts
    4,850
    Rep Power
    481
    Do you need an introduction to calculus or an introduction to pygame? I'm willing to work with the mathematics and tkinter for graphics.
    [code]Code tags[/code] are essential for python code and Makefiles!
  4. #3
  5. Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2005
    Posts
    610
    Rep Power
    65
    Here is an example:
    Code:
    '''PG_image_url.py
    experiments with module pygame
    free from: http://www.pygame.org/
    load and display a web image using pygame
    Python 2.7.3
    '''
    
    import pygame as pg
    from urllib2 import urlopen
    import StringIO
    
    # initialize pygame
    pg.init()
    
    image_url = "http://www.lorenzod8n.files.wordpress.com/2007/05/fishnet.png"
    
    image_str = urlopen(image_url).read()
    image_file = StringIO.StringIO(image_str)
    
    # RGB color tuple used by pygame
    white = (255, 255, 255)
    
    # create a 300x300 white screen
    screen = pg.display.set_mode((300,300),  pg.RESIZABLE )
    screen.fill(white)
    
    # load the image from a file
    image = pg.image.load(image_file)
    
    # draw image, position the image ulc at x=20, y=20
    screen.blit(image, (20, 20))
    
    # nothing gets displayed until one updates the screen
    pg.display.flip()
    
    # start event loop and wait until
    # the user clicks on the window corner x
    while True:
        for event in pg.event.get():
            if event.type == pg.QUIT:
                raise SystemExit
    Real Programmers always confuse Christmas and Halloween because Oct31 == Dec25

IMN logo majestic logo threadwatch logo seochat tools logo