@@ -154,11 +154,10 @@ def on_closing():
154
154
self .quit ()
155
155
self .player .stop ()
156
156
current_pid = psutil .Process ().pid
157
- parent_pid = psutil .Process (current_pid ).ppid ()
158
157
159
158
# Terminate child processes
160
- parent = psutil .Process (parent_pid )
161
- children = parent .children (recursive = True )
159
+ process = psutil .Process (current_pid )
160
+ children = process .children (recursive = True )
162
161
self .logger .info (f"Terminating { len (children )} child processes." )
163
162
for child in children :
164
163
child .terminate ()
@@ -311,49 +310,64 @@ def createWidgets(self) -> None:
311
310
importsBoxUpdates .daemon = True
312
311
importsBoxUpdates .start ()
313
312
# Export Tab
314
- self .search_entry_export = customtkinter .CTkEntry (
315
- master = self .east_frame .tab ("Export" ),
316
- width = 150 ,
317
- height = 25 ,
318
- placeholder_text = "Search for audio" ,
319
- )
320
- self .search_entry_export .place (relx = 0.5 , rely = 0.05 , anchor = tkinter .CENTER )
321
-
322
- self .listframe_export = customtkinter .CTkFrame (
323
- master = self .east_frame .tab ("Export" ), width = 150 , height = 175 , corner_radius = 8
324
- )
325
- self .listframe_export .place (relx = 0.5 , rely = 0.45 , anchor = tkinter .CENTER )
326
-
327
- self .songs_box_export = customtkinter .CTkTextbox (
328
- master = self .listframe_export ,
329
- width = 140 ,
330
- height = 175 ,
331
- bg_color = 'transparent' ,
332
- fg_color = 'transparent' ,
333
- corner_radius = 8 ,
334
- )
335
- self .songs_box_export .place (relx = 0.5 , rely = 0.5 , anchor = tkinter .CENTER )
336
-
337
- self .index_entry_export = customtkinter .CTkEntry (
338
- master = self .east_frame .tab ("Export" ),
339
- width = 150 ,
340
- height = 25 ,
341
- placeholder_text = "Enter index of audio" ,
342
- )
343
- self .index_entry_export .place (relx = 0.5 , rely = 0.85 , anchor = tkinter .CENTER )
313
+ def activate (button , slider ):
314
+ if button .cget ("border_color" ) == "#3E454A" :
315
+ button .configure (border_color = self .settings .getSetting ("chosenLightColor" ) if customtkinter .get_appearance_mode () == "Light" else self .settings .getSetting ("chosenDarkColor" ))
316
+ slider .set (0.5 )
317
+ else :
318
+ button .configure (border_color = "#3E454A" )
319
+ slider .set (0 )
344
320
345
- self .playbutton_export = customtkinter .CTkButton (
321
+ def slider_event (slider , button ):
322
+ if slider == 0 :
323
+ button .configure (border_color = "#3E454A" )
324
+ else :
325
+ button .configure (border_color = self .settings .getSetting ("chosenLightColor" ) if customtkinter .get_appearance_mode () == "Light" else self .settings .getSetting ("chosenDarkColor" ))
326
+
327
+ widgets = ["Bass" , "Other" , "Drums" , "Vocals" ]
328
+ sliders = []
329
+ i = 0
330
+ for widget in widgets :
331
+ activate_button = customtkinter .CTkButton (
332
+ master = self .east_frame .tab ("Export" ),
333
+ text = widget ,
334
+ width = 70 ,
335
+ height = 70 ,
336
+ border_width = 2 ,
337
+ border_color = self .settings .getSetting ("chosenLightColor" ) if customtkinter .get_appearance_mode () == "Light" else self .settings .getSetting ("chosenDarkColor" ),
338
+ bg_color = 'transparent' ,
339
+ fg_color = 'transparent' ,
340
+ hover_color = self .east_frame .cget ("bg_color" ),
341
+ )
342
+ factor = 0.25 if i < 2 else 0.75
343
+ activate_button .place (
344
+ relx = factor , rely = 0.25 if i % 2 == 0 else 0.6 , anchor = tkinter .CENTER
345
+ )
346
+ volume_slider = customtkinter .CTkSlider (
347
+ master = self .east_frame .tab ("Export" ),
348
+ width = 70 ,
349
+ height = 10 ,
350
+ number_of_steps = 10
351
+ )
352
+ sliders .append (volume_slider )
353
+ volume_slider .place (
354
+ relx = factor , rely = 0.42 if i % 2 == 0 else 0.77 , anchor = tkinter .CENTER
355
+ )
356
+ activate_button .configure (
357
+ command = lambda button = activate_button , slider = volume_slider : activate (button , slider )
358
+ )
359
+ volume_slider .configure (
360
+ command = lambda slider = volume_slider , button = activate_button : slider_event (slider , button )
361
+ )
362
+ i += 1
363
+ self .export_button = customtkinter .CTkButton (
346
364
master = self .east_frame .tab ("Export" ),
347
365
text = "Export" ,
348
366
width = 150 ,
349
367
height = 25 ,
350
- command = lambda : self .export (self .index_entry_export . get ( ), MISSThelpers . MISSTlistdir ( self , self . importsDest )),
368
+ command = lambda : threading . Thread ( target = self .export , args = (self .songlabel . cget ( "text" ), sliders ), daemon = True ). start ()
351
369
)
352
- self .playbutton_export .place (relx = 0.5 , rely = 0.95 , anchor = tkinter .CENTER )
353
-
354
- importsBoxUpdates = threading .Thread (target = self .imports_check , args = (self .search_entry_export , self .songs_box_export ))
355
- importsBoxUpdates .daemon = True
356
- importsBoxUpdates .start ()
370
+ self .export_button .place (relx = 0.5 , rely = 0.95 , anchor = tkinter .CENTER )
357
371
## WEST FRAME ----------------------------------------------------------------------------------------------------
358
372
359
373
self .logolabel = customtkinter .CTkLabel (
@@ -396,7 +410,7 @@ def createWidgets(self) -> None:
396
410
width = 5 ,
397
411
height = 5 ,
398
412
corner_radius = 16 ,
399
- command = lambda : self .draw_eq_frame (),
413
+ command = lambda : self .draw_effects_frame (),
400
414
)
401
415
self .equalizer .place (relx = 0.7 , rely = 0.9 , anchor = tkinter .CENTER )
402
416
@@ -1372,9 +1386,9 @@ def eqOnOff(self) -> None:
1372
1386
child .configure (state = 'normal' )
1373
1387
return
1374
1388
1375
- def draw_eq_frame (self ) -> None :
1389
+ def draw_effects_frame (self ) -> None :
1376
1390
"""
1377
- Draws the eq frame.
1391
+ Draws the effects frame.
1378
1392
"""
1379
1393
self .eq_window = customtkinter .CTkFrame (
1380
1394
master = self , width = self .WIDTH * (755 / self .WIDTH ), height = self .HEIGHT * (430 / self .HEIGHT )
@@ -1498,6 +1512,15 @@ def add_highlight(text, start, end):
1498
1512
songs .append (f"{ num } . { _ } " )
1499
1513
while True :
1500
1514
time .sleep (0.25 )
1515
+ if self .songlabel .cget ("text" ) == "Play Something!" :
1516
+ self .export_button .configure (text = "Nothing Playing" )
1517
+ self .export_button .configure (state = tkinter .DISABLED )
1518
+ else :
1519
+ if (self .export_button .cget ("text" ).startswith ("Export" )):
1520
+ pass
1521
+ else :
1522
+ self .export_button .configure (state = tkinter .NORMAL )
1523
+ self .export_button .configure (text = "Export" )
1501
1524
if len (MISSThelpers .MISSTlistdir (self , self .importsDest )) != num :
1502
1525
num = 0
1503
1526
songs = []
@@ -1578,73 +1601,32 @@ def play_search(self, index_label:str, songs:list) -> None:
1578
1601
pass
1579
1602
self .playbutton .configure (state = tkinter .NORMAL )
1580
1603
1581
- def export (self , index_label :str , songs :list ) -> None :
1604
+ def export (self , songname :str , sliders :list ) -> None :
1582
1605
"""
1583
1606
Exports a song
1584
1607
1585
1608
Args:
1586
- index_label (str): The index of the song
1587
- songs (list): The list of songs
1609
+ songname (str): The name of the song
1588
1610
"""
1589
- try :
1590
- self .export_frame .destroy ()
1591
- except :
1592
- pass
1593
- try :
1594
- index = int (index_label )
1595
- song = songs [index - 1 ]
1596
-
1597
- self .export_frame = customtkinter .CTkFrame (
1598
- self ,
1599
- width = 360 ,
1600
- height = 250 ,
1601
- border_width = 3
1602
- )
1603
- self .export_frame .place (relx = 0.485 , rely = 0.5 , anchor = tkinter .CENTER )
1604
-
1605
- goback_button = customtkinter .CTkButton (
1606
- self .export_frame ,
1607
- text = "Adjust some more" ,
1608
- command = lambda : self .export_frame .destroy ()
1609
- )
1610
- goback_button .place (relx = 0.3 , rely = 0.9 , anchor = tkinter .CENTER )
1611
-
1612
- def save ():
1613
- export_label .configure (text = "Exporting..." )
1614
- file = tkinter .filedialog .asksaveasfilename (initialfile = f"{ song } .mp3" , filetypes = (('mp3 files' , '*.mp3' ),('All files' , '*.*' )))
1615
- if file == "" :
1616
- export_label .configure (text = "Cancelled!" )
1617
- self .export_frame .destroy ()
1618
- return
1619
- self .player .save ([
1620
- f"{ self .importsDest } /{ song } /bass.flac" ,
1621
- f"{ self .importsDest } /{ song } /drums.flac" ,
1622
- f"{ self .importsDest } /{ song } /other.flac" ,
1623
- f"{ self .importsDest } /{ song } /vocals.flac"
1624
- ], [
1625
- self .slider1 .get (),
1626
- self .slider2 .get (),
1627
- self .slider3 .get (),
1628
- self .slider4 .get ()
1629
- ], file )
1630
- export_label .configure (text = "Exported!" )
1631
- self .export_frame .destroy ()
1632
-
1633
- export_button = customtkinter .CTkButton (
1634
- self .export_frame ,
1635
- text = "Export" ,
1636
- command = save
1637
- )
1638
- export_button .place (relx = 0.7 , rely = 0.9 , anchor = tkinter .CENTER )
1639
-
1640
- export_label = customtkinter .CTkLabel (
1641
- self .export_frame ,
1642
- text = "Are you sure you want to export this \n song with your current volume settings?" ,
1643
- font = (self .FONT , 16 )
1644
- )
1645
- export_label .place (relx = 0.5 , rely = 0.5 , anchor = tkinter .CENTER )
1646
- except :
1647
- pass
1611
+ file = tkinter .filedialog .asksaveasfilename (initialfile = f"{ songname } .mp3" , filetypes = (('mp3 files' , '*.mp3' ),('All files' , '*.*' )))
1612
+ if file == "" :
1613
+ self .export_button .configure (text = "Export Cancelled." )
1614
+ threading .Timer (1.5 , lambda : self .export_button .configure (text = "Export" )).start ()
1615
+ return
1616
+ self .export_button .configure (text = "Exporting..." )
1617
+ self .player .save ([
1618
+ f"{ self .importsDest } /{ songname } /bass.flac" ,
1619
+ f"{ self .importsDest } /{ songname } /drums.flac" ,
1620
+ f"{ self .importsDest } /{ songname } /other.flac" ,
1621
+ f"{ self .importsDest } /{ songname } /vocals.flac"
1622
+ ], [
1623
+ sliders [0 ].get (),
1624
+ sliders [2 ].get (),
1625
+ sliders [1 ].get (),
1626
+ sliders [3 ].get ()
1627
+ ], file )
1628
+ self .export_button .configure (text = "Exported!" )
1629
+ threading .Timer (1.5 , lambda : self .export_button .configure (text = "Export" )).start ()
1648
1630
1649
1631
def shuffle (self ) -> None :
1650
1632
"""
0 commit comments