-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOpenFiles.py
More file actions
26 lines (23 loc) · 798 Bytes
/
OpenFiles.py
File metadata and controls
26 lines (23 loc) · 798 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import pygame
from tkinter import Tk, filedialog
from pydub import AudioSegment
import os
class OpenFiles:
@staticmethod
def open_image():
root = Tk()
root.withdraw()
file_path = filedialog.askopenfilename(filetypes=[("Image files", "*.png;*.jpg;*.jpeg")])
root.destroy()
if file_path:
image = pygame.image.load(file_path)
return image,os.path.basename(file_path),file_path
@staticmethod
def open_audio():
root = Tk()
root.withdraw()
file_path = filedialog.askopenfilename(filetypes=[("Audio files", "*.mp3;*.wav")])
root.destroy()
if file_path:
audio = AudioSegment.from_file(file_path)
return audio,os.path.basename(file_path),file_path