pygame-community / pygame-ce

🐍🎮 pygame - Community Edition is a FOSS Python library for multimedia applications (like games). Built on top of the excellent SDL library.
https://pyga.me
929 stars 154 forks source link

pygame.image.show(filename | Surface | filelike) (3422) #1689

Open GalacticEmperor1 opened 1 year ago

GalacticEmperor1 commented 1 year ago

Issue №3422 opened by illume at 2022-08-21 15:10:00

To make it easy to see the images.


Comments

*illume commented at 2022-08-21 15:33:51*

Some editors/repls have a html like editor and support things like __html__() which returns an img base url encoded. So they can be seen in the repl.


*robertpfeiffer commented at 2022-08-26 14:03:04*

Should this execute something like feh/display/eog/xdg-open/windows image viewer, or should it use SDL?


*ankith26 commented at 2022-09-05 04:21:21*

I'm not clear about what this issue is proposing Should it just be a short hand for loading and blitting images? Is it indented for use for quick debugging? Will calling this function execute a small application of its own (and will this function call block), or should the user use this along with their game loop?

MyreMylar commented 5 months ago
import pygame

pygame.init()

def image_show(file_path):
    image_surf = pygame.image.load(file_path)
    size = image_surf.get_size()
    display = pygame.display.set_mode(size, flags=pygame.NOFRAME)
    image_surf = image_surf.convert_alpha()
    display.blit(image_surf, (0, 0))
    should_close = False
    while not should_close:
        for event in pygame.event.get():
            if event.type == pygame.MOUSEBUTTONDOWN or event.type == pygame.KEYDOWN:
                should_close = True

        pygame.display.flip()

image_show("images/walt.png")