-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpublic_functions.py
More file actions
89 lines (74 loc) · 2.58 KB
/
public_functions.py
File metadata and controls
89 lines (74 loc) · 2.58 KB
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
import os
from PyQt5.QtWidgets import QFileDialog, QLabel, QDialog, QWidget,QSpinBox
from PyQt5.QtCore import Qt
from PyQt5.QtGui import QFont
from PyQt5.uic import loadUi
from spleeter.separator import Separator
import pickle
class OkOrCancelDialog(QDialog):
def __init__(self):
super().__init__()
self.ui = loadUi(".\\UI\\uiFiles\\ResetConfirm.ui", self)
self.ui.buttonBox.accepted.connect(self.on_accepted)
self.ui.buttonBox.rejected.connect(self.reject)
self.show()
def on_accepted(self):
# Code to be executed after the "accepted" button is clicked
reset()
self.accept()
def reset():
with open('.\\profile.dat', 'rb') as f:
prf = pickle.load(f)
prf.can_max =0
prf.well_max=0
prf.verified_health=0
prf.offset =0
with open('.\\profile.dat', 'wb') as f:
pickle.dump(prf, f)
return
def open_file_dialog():
file_dialog = QFileDialog()
file_dialog.setFileMode(QFileDialog.ExistingFiles)
file_dialog.setNameFilter("MP3 Files (*.mp3)")
if file_dialog.exec_():
selected_files = file_dialog.selectedFiles()
# Filter selected files to keep only .mp3 files
selected_files = [file for file in selected_files if file.endswith('.mp3')]
return selected_files
else:
return None
def profile_exist():
with open('.\\profile.dat', 'rb') as f:
prf = pickle.load(f)
if prf.well_max == 0 and prf.can_max == 0 and prf.verified_health == 0:
return False
else: return True
def centering(widgets):
for widget in widgets.findChildren(QLabel):
widget.setAlignment(Qt.AlignCenter)
def ratio(widgets,font_str, ratio):
for widget in widgets.findChildren(QWidget):
widget_geometry = widget.geometry()
font_size = widget_geometry.height() * ratio
font = QFont(font_str, font_size)
widget.setFont(font)
for widget in widgets.findChildren(QSpinBox):
widget_geometry = widget.geometry()
font_size = widget_geometry.height() * ratio
font = QFont(font_str, font_size)
widget.setFont(font)
def open_ok_or_cancel_dialog(mainui):
# Show the new window and wait for user response
new_window = OkOrCancelDialog()
result = new_window.exec_()
if result == QDialog.Accepted:
pass
mainui.enable_window()
# implement reset code
def search(L, name):
M = [x for x in L if name in x.root_file.name]
return M
def separate(directory):
separator = Separator('spleeter:2stems')
separator.separate_to_file(directory, './temp')
return