Python pygame 显示其他用户的图像和音频文件
当我的脚本转换为.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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不可能显示不存在的文件。最简单的解决方案是将程序发送给用户时简单地包含必要的文件(您可能还想尝试使用相对文件路径,而不是假设其他用户将保存在'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.