Python pygame 显示其他用户的图像和音频文件

发布于 2025-01-17 12:35:28 字数 1586 浏览 0 评论 0原文

当我的脚本转换为.exe是由没有必要图像和音频文件的人启动的时,这些图像和音频文件并未在其程序中显示。 我如何让每个人看到它们? 是否可以从Internet或其他内容下载文件?

import pyautogui as pg
from pygame import mixer
import pygame
import pyglet
from tkinter import *
from tkinter import messagebox
from ctypes import cast, POINTER
from comtypes import CLSCTX_ALL
from pycaw.pycaw import AudioUtilities, IAudioEndpointVolume
import requests as rqs



pygame.mixer.init()
pygame.init()
pygame.mixer.music.set_volume(100)


mixer.music.load('D:\Programs\games\Python\Projects\MEDIA\Sm.mp3')
pp = pygame.image.load('D:\Programs\games\Python\Projects\MEDIA\pp.png')

pg.alert("Вы установили смачный вирус!", "ERROR", button = "Продолжить" )
pg.confirm("Точно продолжить?", ("НЕТ!"))
pg.password("Введите пароль для отмены")
pg.alert("Пароль неверный!", "ERROR" )

devices = AudioUtilities.GetSpeakers()
interface = devices.Activate( IAudioEndpointVolume._iid_, CLSCTX_ALL, None)
volume = cast(interface, POINTER(IAudioEndpointVolume))
volume.SetMasterVolumeLevel(-0.0, None)




screen = pygame.display.set_mode((1920, 1080))
screen.blit(pp, (0, 0))
volume.SetMasterVolumeLevel(-0.0, None)
time.sleep(5)
volume.SetMasterVolumeLevel(-0.0, None)
mixer.music.play(-1)




while True:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            screen = pygame.display.set_mode((1920, 1080))
            screen.blit(pp, (0, 0))

            mixer.music.play(-1)
            pg.move(10000, 10000)
            pg.move(10000, 10000)
            volume.SetMasterVolumeLevel(-0.0, None)

    pygame.display.update() ``` 

When my script converted to .exe is launched by a person who does not have the necessary images and audio files, these images and audio files are not displayed in his program.
How can I make everyone see them?
Is it possible to download files from the Internet or something else?

import pyautogui as pg
from pygame import mixer
import pygame
import pyglet
from tkinter import *
from tkinter import messagebox
from ctypes import cast, POINTER
from comtypes import CLSCTX_ALL
from pycaw.pycaw import AudioUtilities, IAudioEndpointVolume
import requests as rqs



pygame.mixer.init()
pygame.init()
pygame.mixer.music.set_volume(100)


mixer.music.load('D:\Programs\games\Python\Projects\MEDIA\Sm.mp3')
pp = pygame.image.load('D:\Programs\games\Python\Projects\MEDIA\pp.png')

pg.alert("Вы установили смачный вирус!", "ERROR", button = "Продолжить" )
pg.confirm("Точно продолжить?", ("НЕТ!"))
pg.password("Введите пароль для отмены")
pg.alert("Пароль неверный!", "ERROR" )

devices = AudioUtilities.GetSpeakers()
interface = devices.Activate( IAudioEndpointVolume._iid_, CLSCTX_ALL, None)
volume = cast(interface, POINTER(IAudioEndpointVolume))
volume.SetMasterVolumeLevel(-0.0, None)




screen = pygame.display.set_mode((1920, 1080))
screen.blit(pp, (0, 0))
volume.SetMasterVolumeLevel(-0.0, None)
time.sleep(5)
volume.SetMasterVolumeLevel(-0.0, None)
mixer.music.play(-1)




while True:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            screen = pygame.display.set_mode((1920, 1080))
            screen.blit(pp, (0, 0))

            mixer.music.play(-1)
            pg.move(10000, 10000)
            pg.move(10000, 10000)
            volume.SetMasterVolumeLevel(-0.0, None)

    pygame.display.update() ``` 

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

陌若浮生 2025-01-24 12:35:28

不可能显示不存在的文件。最简单的解决方案是将程序发送给用户时简单地包含必要的文件(您可能还想尝试使用相对文件路径,而不是假设其他用户将保存在'd:\ program \ program \ gashs \ games \ python \ projects'中的所有内容' 。

​a-file-over-http“>在此问题上如果您不确定如何下载文件。

It isn't possible to display files that aren't there. The easiest solution would be to simply include the necessary files when sending your programme to users (you might also want to try using relative file paths instead of assuming other users will have everything saved in 'D:\Programs\games\Python\Projects'.

If you want to go for the download route, try hosting the necessary files publicly on Google Drive or something similar and taking a looking at this question if you are unsure how to download the files.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文