forked from kelvinlawson/pykaraoke
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pykaraoke.py
executable file
·3904 lines (3288 loc) · 167 KB
/
pykaraoke.py
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/env python
# pykaraoke - Karaoke Player Frontend
#
#******************************************************************************
#**** ****
#**** Copyright (C) 2010 Kelvin Lawson ([email protected]) ****
#**** Copyright (C) 2010 PyKaraoke Development Team ****
#**** ****
#**** This library is free software; you can redistribute it and/or ****
#**** modify it under the terms of the GNU Lesser General Public ****
#**** License as published by the Free Software Foundation; either ****
#**** version 2.1 of the License, or (at your option) any later version. ****
#**** ****
#**** This library is distributed in the hope that it will be useful, ****
#**** but WITHOUT ANY WARRANTY; without even the implied warranty of ****
#**** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ****
#**** Lesser General Public License for more details. ****
#**** ****
#**** You should have received a copy of the GNU Lesser General Public ****
#**** License along with this library; if not, write to the ****
#**** Free Software Foundation, Inc. ****
#**** 59 Temple Place, Suite 330 ****
#**** Boston, MA 02111-1307 USA ****
#******************************************************************************
# OVERVIEW
#
# pykaraoke is a frontend for the pycdg and pympg karaoke players. It provides
# a search engine to find your songs, a file/folder browser to pick songs from
# disk, as well as a playlist.
#
# The default view is the search engine - you add your folders that contain
# karaoke songs, and hit the Scan button to build the database. The search
# engine can also look inside ZIP files for karaoke tracks.
#
# This frontend uses the WxPython library (www.wxpython.org) to provide the
# GUI. The CDG and MPG player functionality is handled by the external
# pycdg and pympg libraries (which use the pygame library (www.pygame.org)
# for audio/video).
#
# The frontend and player libraries run on any operating system that run pygame
# and WxPython (currently Linux, Windows and OSX).
# REQUIREMENTS
#
# pykaraoke requires the following to be installed on your system:
# . WxPython (www.wxpython.org)
# . Python (www.python.org)
# . Pygame (www.pygame.org)
# USAGE INSTRUCTIONS
#
# To start the player, run the following from the command line:
# python pykaraoke.py
#
# The player starts in Search View. From here you can search for songs in
# your song database. You need to first set up the database, however, by
# clicking "Add Songs".
#
# To set up the database, add the folders that contain your karaoke songs.
# Select which type of files you are interested in adding to the search
# database (CDG, MPG etc). Click "Look Inside Zips" if you also want to
# search inside any ZIP files found in the folders for more karaoke songs.
#
# When you have finished adding folders, and setting your preferences,
# click "Scan Now" to start building the database. This can take some time
# but only needs to be done once. The search engine then searches your
# database, rather than searching the hard disk every time you search for
# a song.
#
# Once you have set up your database, clicking "Save" will save the database
# and settings for the next time you run the program. (The information is
# saved in a .pykaraoke folder in your home directory).
#
# If you get more karaoke files, don't forget to rescan the hard disk and
# build the database again. Otherwise the new files won't be visible in
# the search engine.
#
# With your database set up, you are ready to start searching for and
# playing your karaoke songs. From the main window, enter the name of the
# song you would like to find and click "Search". This will populate the
# Search Results panel below with the matching song files. From here
# double-clicking a song plays it directly. You can also add the song to
# your playlist by right-clicking on the song and using the popup menu.
#
# There is also a simple explorer-like interface that can be selected using
# a drop-down box on the main window ("Folder View"). Using this you can
# also play songs directly or add them to the playlist, by right-clicking
# on the song and using the popup menu.
#
# In the right-hand side of the window you will find your playlist. Songs
# can be added from the search results or folder browser, until you have
# built up your playlist. Once ready, click on the song you would like to
# start with. When the song is finished playing, the next song down the
# playlist will automatically start playing. You can also delete single
# songs, or clear the entire playlist by right-clicking on an item in
# the playlist.
#
# This is an early release of pykaraoke. Please let us know if there are
# any features you would like to see added, or you have any other
# suggestions or bug reports. Contact the project at
# IMPLEMENTATION DETAILS
#
# pykaraoke is a python module that implements a frontend for
# the external pycdg and pympg player modules. The frontend
# is implemented using WxPython.
#
# Everything is kicked off by the PyKaraokeMgr class, which
# instantiates the main window (PyKaraokeWindow class). It
# also handles calling the player modules and managing the
# playlist.
#
# All panels, windows and controls tend to be sub-classed from the
# base WxPython classes.
#
# The players are started by instantiating the class exported by
# their modules (e.g. pycdg.cdgPlayer()). They can then be
# controlled by calling their methods (Play(), Close() etc). The
# player modules do not take over the main loop, so the GUI is still
# usable while the songs are playing, allowing the user to
# continue adding to the playlist etc.
import sys
# Ensure that we have at least wx version 2.6, but also protect
# wxversion against py2exe (wxversion requires actual wx directories
# on-disk, so it doesn't work in the py2exe-compiled version used for
# Windows distribution).
if not hasattr(sys, 'frozen'):
import wxversion
wxversion.ensureMinimal('2.6')
import os, string, wx, time, copy, types
from pykconstants import *
from pykenv import env
import pycdg, pympg, pykar, pykversion, pykdb
import codecs
import cPickle
from pykmanager import manager
import random
import performer_prompt as PerformerPrompt
# Constants
PLAY_COL_TITLE = "Title"
PLAY_COL_ARTIST = "Artist"
PLAY_COL_FILENAME = "Filename"
PLAY_COL_PERFORMER = "Performer"
class wxAppYielder(pykdb.AppYielder):
def Yield(self):
wx.GetApp().Yield()
# Popup busy window with cancel button
class wxBusyCancelDialog(wx.ProgressDialog, pykdb.BusyCancelDialog):
def __init__(self, parent, title):
pykdb.BusyCancelDialog.__init__(self)
wx.ProgressDialog.__init__(
self, title, title, style = wx.PD_APP_MODAL | wx.PD_CAN_ABORT | wx.PD_AUTO_HIDE)
def SetProgress(self, label, progress):
""" Called from time to time to update the progress display. """
cont = self.Update(int(progress * 100), label)
if isinstance(cont, types.TupleType):
# Later versions of wxPython return a tuple from the above.
cont, skip = cont
if not cont:
# Cancel clicked
self.Clicked = True
# Popup settings window for adding song folders, requesting a
# new folder scan to fill the database etc.
class DatabaseSetupWindow (wx.Frame):
def __init__(self,parent,id,title,KaraokeMgr):
wx.Frame.__init__(self,parent,wx.ID_ANY, title,
style=wx.DEFAULT_FRAME_STYLE|wx.FRAME_FLOAT_ON_PARENT)
self.KaraokeMgr = KaraokeMgr
self.panel = wx.Panel(self)
# Help text
self._HelpText = wx.StaticText (self.panel, wx.ID_ANY,
"Add folders to build a searchable database of your karaoke songs\n",
style = wx.ALIGN_CENTER)
# Add the folder list
self.FolderList = wx.ListBox(self.panel, -1, style=wx.LB_SINGLE)
for item in self.KaraokeMgr.SongDB.GetFolderList():
self.FolderList.Append(item)
# Add the buttons
self.AddFolderButtonID = wx.NewId()
self.DelFolderButtonID = wx.NewId()
self.AddFolderButton = wx.Button(self.panel, self.AddFolderButtonID, "Add Folder")
self.DelFolderButton = wx.Button(self.panel, self.DelFolderButtonID, "Delete Folder")
self.FolderButtonsSizer = wx.BoxSizer(wx.VERTICAL)
self.FolderButtonsSizer.Add(self.AddFolderButton, 0, wx.ALIGN_LEFT, 3)
self.FolderButtonsSizer.Add(self.DelFolderButton, 0, wx.ALIGN_LEFT, 3)
wx.EVT_BUTTON(self, self.AddFolderButtonID, self.OnAddFolderClicked)
wx.EVT_BUTTON(self, self.DelFolderButtonID, self.OnDelFolderClicked)
# Create a sizer for the folder list and folder buttons
self.FolderSizer = wx.BoxSizer (wx.HORIZONTAL)
self.FolderSizer.Add (self.FolderList, 1, wx.EXPAND, 3)
self.FolderSizer.Add (self.FolderButtonsSizer, 0, wx.ALL, 3)
# Create the settings controls
self.FileExtensionID = wx.NewId()
self.FiletypesText = wx.StaticText (self.panel, wx.ID_ANY, "Include File Types: ")
self.FiletypesSizer = wx.BoxSizer (wx.HORIZONTAL)
settings = self.KaraokeMgr.SongDB.Settings
self.extCheckBoxes = {}
for ext in settings.KarExtensions + settings.CdgExtensions + settings.MpgExtensions:
cb = wx.CheckBox(self.panel, self.FileExtensionID, ext[1:])
cb.SetValue(self.KaraokeMgr.SongDB.IsExtensionValid(ext))
self.FiletypesSizer.Add(cb, 0, wx.ALL | wx.RIGHT, border = 2)
self.extCheckBoxes[ext] = cb
wx.EVT_CHECKBOX (self, self.FileExtensionID, self.OnFileExtChanged)
# Create the ZIP file setting checkbox
self.zipID = wx.NewId()
self.zipText = wx.StaticText (self.panel, wx.ID_ANY, "Look Inside ZIPs: ")
self.zipCheckBox = wx.CheckBox(self.panel, self.zipID, "Enabled")
self.zipCheckBox.SetValue(settings.LookInsideZips)
self.ZipSizer = wx.BoxSizer (wx.HORIZONTAL)
self.ZipSizer.Add (self.zipCheckBox, 0, wx.ALL)
wx.EVT_CHECKBOX (self, self.zipID, self.OnZipChanged)
# Create the titles.txt file setting checkbox
self.titlesID = wx.NewId()
self.titlesText = wx.StaticText (self.panel, wx.ID_ANY, "Read titles.txt files: ")
self.titlesCheckBox = wx.CheckBox(self.panel, self.titlesID, "Enabled")
self.titlesCheckBox.SetValue(self.KaraokeMgr.SongDB.Settings.ReadTitlesTxt)
self.TitlesSizer = wx.BoxSizer (wx.HORIZONTAL)
self.TitlesSizer.Add (self.titlesCheckBox, 0, wx.ALL)
wx.EVT_CHECKBOX (self, self.titlesID, self.OnTitlesChanged)
# Create the filesystem and zip file coding boxes.
fsCodingText = wx.StaticText(self.panel, -1, "System filename encoding:")
self.fsCoding = wx.ComboBox(
self.panel, -1, value = settings.FilesystemCoding,
choices = settings.Encodings)
zipCodingText = wx.StaticText(self.panel, -1, "Filename encoding within zips:")
self.zipCoding = wx.ComboBox(
self.panel, -1, value = settings.ZipfileCoding,
choices = settings.Encodings)
# Create the hash-check options
self.hashCheckBox = wx.CheckBox(self.panel, -1, "Check for identical files (by comparing MD5 hash)")
self.hashCheckBox.SetValue(self.KaraokeMgr.SongDB.Settings.CheckHashes)
self.Bind(wx.EVT_CHECKBOX, self.OnHashChanged, self.hashCheckBox)
self.deleteIdenticalCheckBox = wx.CheckBox(self.panel, -1, "Delete duplicate identical files from disk")
self.deleteIdenticalCheckBox.SetValue(self.KaraokeMgr.SongDB.Settings.DeleteIdentical)
self.deleteIdenticalCheckBox.Enable(self.KaraokeMgr.SongDB.Settings.CheckHashes)
self.Bind(wx.EVT_CHECKBOX, self.OnDeleteIdenticalChanged, self.deleteIdenticalCheckBox)
# Create the scan folders button
self.ScanText = wx.StaticText (self.panel, wx.ID_ANY, "Rescan all folders: ")
self.ScanFoldersButtonID = wx.NewId()
self.ScanFoldersButton = wx.Button(self.panel, self.ScanFoldersButtonID, "Scan Now")
wx.EVT_BUTTON(self, self.ScanFoldersButtonID, self.OnScanFoldersClicked)
# Create the save settings button
self.SaveText = wx.StaticText (self.panel, wx.ID_ANY, "Save settings and song database: ")
self.SaveSettingsButtonID = wx.NewId()
self.SaveSettingsButton = wx.Button(self.panel, self.SaveSettingsButtonID, "Save and Close")
wx.EVT_BUTTON(self, self.SaveSettingsButtonID, self.OnSaveSettingsClicked)
# Create the settings and buttons grid
self.LowerSizer = wx.FlexGridSizer(cols = 2, vgap = 3, hgap = 3)
self.LowerSizer.Add(self.FiletypesText, 0, wx.ALL, 3)
self.LowerSizer.Add(self.FiletypesSizer, 1, wx.ALL, 3)
self.LowerSizer.Add(self.zipText, 0, wx.ALL, 3)
self.LowerSizer.Add(self.ZipSizer, 1, wx.ALL, 3)
self.LowerSizer.Add(self.titlesText, 0, wx.ALL, 3)
self.LowerSizer.Add(self.TitlesSizer, 1, wx.ALL, 3)
self.LowerSizer.Add(fsCodingText, 0, wx.ALL, 3)
self.LowerSizer.Add(self.fsCoding, 1, wx.ALL, 3)
self.LowerSizer.Add(zipCodingText, 0, wx.ALL, 3)
self.LowerSizer.Add(self.zipCoding, 1, wx.ALL, 3)
self.LowerSizer.Add((0, 0))
self.LowerSizer.Add(self.hashCheckBox, 1, wx.LEFT | wx.RIGHT | wx.TOP, 3)
self.LowerSizer.Add((0, 0))
self.LowerSizer.Add(self.deleteIdenticalCheckBox, 1, wx.LEFT | wx.RIGHT | wx.BOTTOM, 3)
self.LowerSizer.Add(self.ScanText, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 3)
self.LowerSizer.Add(self.ScanFoldersButton, 1, wx.ALL, 3)
self.LowerSizer.Add(self.SaveText, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 3)
self.LowerSizer.Add(self.SaveSettingsButton, 1, wx.ALL, 3)
# Create the main sizer
self.MainSizer = wx.BoxSizer(wx.VERTICAL)
self.MainSizer.Add(self._HelpText, 0, wx.EXPAND | wx.TOP, 3)
self.MainSizer.Add(self.FolderSizer, 1, wx.EXPAND, 3)
self.MainSizer.Add(self.LowerSizer, 0, wx.ALL, 3)
# Add a close handler to ask the user if they want to rescan folders
self.ScanNeeded = False
self.SaveNeeded = False
wx.EVT_CLOSE(self, self.ExitHandler)
self.panel.SetSizer(self.MainSizer)
psizer = wx.BoxSizer(wx.VERTICAL)
psizer.Add(self.panel, flag = wx.EXPAND, proportion = 1)
self.SetSizerAndFit(psizer)
pos = parent.GetPosition()
parentSize = parent.GetSize()
thisSize = self.GetSize()
pos[0] += (parentSize[0] / 2) - (thisSize[0] / 2)
pos[1] += (parentSize[1] / 2) - (thisSize[1] / 2)
self.SetPosition(pos)
self.Show()
# User wants to add a folder
def OnAddFolderClicked(self, event):
dirDlg = wx.DirDialog(self)
retval = dirDlg.ShowModal()
FolderPath = dirDlg.GetPath()
dirDlg.Destroy()
if retval == wx.ID_OK:
# User made a valid selection
folder_list = self.KaraokeMgr.SongDB.GetFolderList()
# Add it to the list control and song DB if not already in
if FolderPath not in folder_list:
self.KaraokeMgr.SongDB.FolderAdd(FolderPath)
self.FolderList.Append(FolderPath)
self.ScanNeeded = True
self.SaveNeeded = True
# User wants to delete a folder, get the selection in the folder list
def OnDelFolderClicked(self, event):
index = self.FolderList.GetSelection()
Folder = self.FolderList.GetString(index)
self.KaraokeMgr.SongDB.FolderDel(Folder)
self.FolderList.Delete(index)
self.ScanNeeded = True
self.SaveNeeded = True
def __getCodings(self):
# Extract the filesystem and zip file encodings. These aren't
# captured as they are changed, unlike the other parameters
# here, because that's just a nuisance.
settings = self.KaraokeMgr.SongDB.Settings
FilesystemCoding = self.fsCoding.GetValue()
if FilesystemCoding != settings.FilesystemCoding:
settings.FilesystemCoding = FilesystemCoding
self.ScanNeeded = True
self.SaveNeeded = True
ZipfileCoding = self.zipCoding.GetValue()
if ZipfileCoding != settings.ZipfileCoding:
settings.ZipfileCoding = ZipfileCoding
self.ScanNeeded = True
self.SaveNeeded = True
# User wants to rescan all folders
def OnScanFoldersClicked(self, event):
self.__getCodings()
# Create a temporary SongDatabase we can use to initiate the
# scanning. This way, if the user cancels out halfway
# through, we can abandon it instead of being stuck with a
# halfway-scanned database.
songDb = pykdb.SongDB()
songDb.Settings = self.KaraokeMgr.SongDB.Settings
cancelled = songDb.BuildSearchDatabase(
wxAppYielder(), wxBusyCancelDialog(self.KaraokeMgr.Frame, "Searching"))
if not cancelled:
# The user didn't cancel, so make the new database the
# effective one.
self.KaraokeMgr.SongDB = songDb
pykdb.globalSongDB = songDb
self.ScanNeeded = False
self.SaveNeeded = True
# User wants to save all settings
def OnSaveSettingsClicked(self, event):
self.__getCodings()
self.Show(False)
self.KaraokeMgr.SongDB.SaveSettings()
self.KaraokeMgr.SongDB.SaveDatabase()
self.SaveNeeded = False
self.Destroy()
# User changed a checkbox, just do them all again
def OnFileExtChanged(self, event):
ignored_ext_list = []
for ext, cb in self.extCheckBoxes.items():
if not cb.IsChecked():
ignored_ext_list.append(ext)
self.KaraokeMgr.SongDB.Settings.IgnoredExtensions = ignored_ext_list
self.ScanNeeded = True
self.SaveNeeded = True
# User changed the zip checkbox, enable it
def OnZipChanged(self, event):
self.KaraokeMgr.SongDB.Settings.LookInsideZips = self.zipCheckBox.IsChecked()
self.ScanNeeded = True
self.SaveNeeded = True
# User changed the titles.txt checkbox, enable it
def OnTitlesChanged(self, event):
self.KaraokeMgr.SongDB.Settings.ReadTitlesTxt = self.titlesCheckBox.IsChecked()
self.ScanNeeded = True
self.SaveNeeded = True
# User changed the hash checkbox, enable it
def OnHashChanged(self, event):
self.KaraokeMgr.SongDB.Settings.CheckHashes = self.hashCheckBox.IsChecked()
self.deleteIdenticalCheckBox.Enable(self.KaraokeMgr.SongDB.Settings.CheckHashes)
self.ScanNeeded = True
self.SaveNeeded = True
# User changed the delete identical checkbox, enable it
def OnDeleteIdenticalChanged(self, event):
self.KaraokeMgr.SongDB.Settings.DeleteIdentical = self.deleteIdenticalCheckBox.IsChecked()
self.ScanNeeded = True
self.SaveNeeded = True
# Popup asking if want to rescan the database after changing settings
def ExitHandler(self, event):
self.__getCodings()
if self.ScanNeeded:
changedString = "You have changed settings, would you like to rescan your folders now?"
answer = wx.MessageBox(changedString, "Rescan folders now?", wx.YES_NO | wx.ICON_QUESTION)
if answer == wx.YES:
cancelled = self.KaraokeMgr.SongDB.BuildSearchDatabase(
wxAppYielder(), wxBusyCancelDialog(self.KaraokeMgr.Frame, "Searching"))
if not cancelled:
self.SaveNeeded = True
if self.SaveNeeded:
saveString = "You have made changes, would you like to save your settings and database now?"
answer = wx.MessageBox(saveString, "Save changes?", wx.YES_NO | wx.ICON_QUESTION)
if answer == wx.YES:
self.Show(False)
self.KaraokeMgr.SongDB.SaveSettings()
self.KaraokeMgr.SongDB.SaveDatabase()
self.Destroy()
# Popup config window for setting full-screen mode etc
class ConfigWindow (wx.Frame):
def __init__(self,parent,id,title,KaraokeMgr):
wx.Frame.__init__(self, parent, -1, title,
style = wx.DEFAULT_FRAME_STYLE|wx.FRAME_FLOAT_ON_PARENT)
self.parent = parent
self.panel = wx.Panel(self)
self.KaraokeMgr = KaraokeMgr
vsizer = wx.BoxSizer(wx.VERTICAL)
self.notebook = wx.Notebook(self.panel)
self.__layoutDisplayPage()
self.__layoutAudioPage()
self.__layoutKarPage()
self.__layoutCdgPage()
self.__layoutMpgPage()
vsizer.Add(self.notebook, flag = wx.EXPAND | wx.ALL,
proportion = 1, border = 5)
# Make the OK and Cancel buttons.
hsizer = wx.BoxSizer(wx.HORIZONTAL)
b = wx.Button(self.panel, wx.ID_OK, 'OK')
self.Bind(wx.EVT_BUTTON, self.clickedOK, b)
hsizer.Add(b, flag = wx.EXPAND | wx.RIGHT | wx.LEFT, border = 10)
b = wx.Button(self.panel, wx.ID_CANCEL, 'Cancel')
self.Bind(wx.EVT_BUTTON, self.clickedCancel, b)
hsizer.Add(b, flag = wx.EXPAND | wx.RIGHT, border = 10)
vsizer.Add(hsizer, flag = wx.ALIGN_CENTER | wx.TOP | wx.BOTTOM,
border = 10)
self.panel.SetSizer(vsizer)
psizer = wx.BoxSizer(wx.VERTICAL)
psizer.Add(self.panel, flag = wx.EXPAND, proportion = 1)
self.SetSizerAndFit(psizer)
pos = parent.GetPosition()
parentSize = parent.GetSize()
thisSize = self.GetSize()
pos[0] += (parentSize[0] / 2) - (thisSize[0] / 2)
pos[1] += max((parentSize[1] / 2) - (thisSize[1] / 2), 0)
self.SetPosition(pos)
self.Show()
def __layoutDisplayPage(self):
""" Creates the page for the display config options """
settings = self.KaraokeMgr.SongDB.Settings
panel = wx.Panel(self.notebook)
dispsizer = wx.BoxSizer(wx.VERTICAL)
self.FSCheckBox = wx.CheckBox(panel, -1, "Enable Player Full-Screen Mode")
self.FSCheckBox.SetValue(settings.FullScreen)
dispsizer.Add(self.FSCheckBox, flag = wx.LEFT | wx.RIGHT | wx.TOP, border = 10)
self.NoFrameCheckBox = wx.CheckBox(panel, -1, "Enable Player With No Frame")
self.NoFrameCheckBox.SetValue(settings.NoFrame)
dispsizer.Add(self.NoFrameCheckBox, flag = wx.LEFT | wx.RIGHT | wx.TOP, border = 10)
self.DoubleBufCheckBox = wx.CheckBox(panel, -1, "Use double-buffered rendering (recommended)")
self.DoubleBufCheckBox.SetValue(settings.DoubleBuf)
dispsizer.Add(self.DoubleBufCheckBox, flag = wx.LEFT | wx.RIGHT | wx.TOP, border = 10)
self.HardwareSurfaceCheckBox = wx.CheckBox(panel, -1, "Request a hardware surface (recommended)")
self.HardwareSurfaceCheckBox.SetValue(settings.HardwareSurface)
dispsizer.Add(self.HardwareSurfaceCheckBox, flag = wx.LEFT | wx.RIGHT | wx.TOP, border = 10)
gsizer = wx.FlexGridSizer(0, 4, 2, 0)
text = wx.StaticText(panel, -1, "Player Window Size:")
gsizer.Add(text, flag = wx.RIGHT | wx.ALIGN_CENTER_VERTICAL, border = 5)
self.PlayerSizeX = wx.TextCtrl(panel, -1, value = str(settings.PlayerSize[0]))
gsizer.Add(self.PlayerSizeX, flag = wx.EXPAND | wx.RIGHT, border = 5)
self.PlayerSizeY = wx.TextCtrl(panel, -1, value = str(settings.PlayerSize[1]))
gsizer.Add(self.PlayerSizeY, flag = wx.EXPAND | wx.RIGHT, border = 10)
gsizer.Add((0, 0))
# Window placement only seems to work reliably on Linux. Only
# offer it there.
self.DefaultPosCheckBox = None
if env == ENV_POSIX:
text = wx.StaticText(panel, -1, "Player Placement:")
gsizer.Add(text, flag = wx.RIGHT | wx.ALIGN_CENTER_VERTICAL, border = 5)
pos_x = pos_y = ''
if settings.PlayerPosition:
pos_x, pos_y = settings.PlayerPosition
self.PlayerPositionX = wx.TextCtrl(panel, -1, value = str(pos_x))
gsizer.Add(self.PlayerPositionX, flag = wx.EXPAND | wx.RIGHT, border = 5)
self.PlayerPositionY = wx.TextCtrl(panel, -1, value = str(pos_y))
gsizer.Add(self.PlayerPositionY, flag = wx.EXPAND | wx.RIGHT, border = 10)
self.DefaultPosCheckBox = wx.CheckBox(panel, -1, "Default placement")
self.Bind(wx.EVT_CHECKBOX, self.clickedDefaultPos, self.DefaultPosCheckBox)
self.DefaultPosCheckBox.SetValue(settings.PlayerPosition is None)
self.clickedDefaultPos(None)
gsizer.Add(self.DefaultPosCheckBox, flag = wx.EXPAND)
dispsizer.Add(gsizer, flag = wx.EXPAND | wx.ALL, border = 10)
self.SplitVerticallyCheckBox = wx.CheckBox(panel, -1, "Split play-list window vertically")
self.SplitVerticallyCheckBox.SetValue(settings.SplitVertically)
dispsizer.Add(self.SplitVerticallyCheckBox, flag = wx.LEFT | wx.RIGHT | wx.TOP, border = 10)
# Enables or disables the auto play-list functionality
self.AutoPlayCheckBox = wx.CheckBox(panel, -1, "Enable play-list continuous play")
self.AutoPlayCheckBox.SetValue(settings.AutoPlayList)
dispsizer.Add(self.AutoPlayCheckBox, flag = wx.LEFT | wx.RIGHT | wx.TOP, border = 10)
# Enables or disables the double-click playing from the play-list
self.DoubleClickPlayCheckBox = wx.CheckBox(panel, -1, "Enable playing from play-list")
self.DoubleClickPlayCheckBox.SetValue(settings.DoubleClickPlayList)
dispsizer.Add(self.DoubleClickPlayCheckBox, flag = wx.LEFT | wx.RIGHT | wx.TOP, border = 10)
# Enables or disables the clearing of the play-list from teh list
self.ClearFromPlayListCheckBox = wx.CheckBox(panel, -1, "Enable playlist clearing from play-list")
self.ClearFromPlayListCheckBox.SetValue(settings.ClearFromPlayList)
dispsizer.Add(self.ClearFromPlayListCheckBox, flag = wx.LEFT | wx.RIGHT | wx.TOP, border = 10)
# Enables or disables playing from a search list functionality
self.PlayFromSearchListCheckBox = wx.CheckBox(panel, -1, "Enable playing from search-list")
self.PlayFromSearchListCheckBox.SetValue(settings.PlayFromSearchList)
dispsizer.Add(self.PlayFromSearchListCheckBox, flag = wx.LEFT | wx.RIGHT | wx.TOP, border = 10)
# Enables or disables the kamikaze funtionality
self.KamikazeCheckBox = wx.CheckBox(panel, -1, "Enable kamikaze play")
self.KamikazeCheckBox.SetValue(settings.Kamikaze)
dispsizer.Add(self.KamikazeCheckBox, flag = wx.LEFT | wx.RIGHT | wx.TOP, border = 10)
# Enables or disables the performer functionality
self.PerformerCheckBox = wx.CheckBox(panel, -1, "Enable performer enquiry")
self.PerformerCheckBox.SetValue(settings.UsePerformerName)
dispsizer.Add(self.PerformerCheckBox, flag = wx.LEFT | wx.RIGHT | wx.TOP, border = 10)
# Enables or disables the performer functionality
self.ArtistTitleCheckBox = wx.CheckBox(panel, -1, "Display derived Artist/Title columns")
self.ArtistTitleCheckBox.SetValue(settings.DisplayArtistTitleCols)
dispsizer.Add(self.ArtistTitleCheckBox, flag = wx.LEFT | wx.RIGHT | wx.TOP, border = 10)
panel.SetSizer(dispsizer)
self.notebook.AddPage(panel, "Display")
def __layoutAudioPage(self):
""" Creates the page for the audio config options """
settings = self.KaraokeMgr.SongDB.Settings
panel = wx.Panel(self.notebook)
audsizer = wx.BoxSizer(wx.VERTICAL)
self.StereoCheckBox = wx.CheckBox(panel, -1, "Stereo")
self.StereoCheckBox.SetValue(settings.NumChannels > 1)
audsizer.Add(self.StereoCheckBox, flag = wx.ALL, border = 10)
self.UseMp3SettingsCheckBox = wx.CheckBox(panel, -1, "Use source sample rate if possible")
self.UseMp3SettingsCheckBox.SetValue(settings.UseMp3Settings)
audsizer.Add(self.UseMp3SettingsCheckBox, flag = wx.EXPAND | wx.LEFT, border = 10)
gsizer = wx.FlexGridSizer(0, 2, 2, 0)
text = wx.StaticText(panel, -1, "Sample rate:")
gsizer.Add(text, flag = wx.RIGHT | wx.ALIGN_CENTER_VERTICAL, border = 5)
self.SampleRate = wx.ComboBox(
panel, -1, value = str(settings.SampleRate),
choices = map(str, settings.SampleRates))
gsizer.Add(self.SampleRate, flag = wx.EXPAND)
text = wx.StaticText(panel, -1, "Buffer size (ms):")
gsizer.Add(text, flag = wx.RIGHT | wx.ALIGN_CENTER_VERTICAL, border = 5)
self.BufferSize = wx.TextCtrl(panel, -1,
value = str(settings.BufferMs))
gsizer.Add(self.BufferSize, flag = wx.EXPAND)
text = wx.StaticText(panel, -1, "Sync delay (ms):")
gsizer.Add(text, flag = wx.RIGHT | wx.ALIGN_CENTER_VERTICAL, border = 5)
self.SyncDelay = wx.TextCtrl(panel, -1,
value = str(settings.SyncDelayMs))
gsizer.Add(self.SyncDelay, flag = wx.EXPAND)
audsizer.Add(gsizer, flag = wx.EXPAND | wx.ALL, border = 10)
panel.SetSizer(audsizer)
self.notebook.AddPage(panel, "Audio")
def __layoutKarPage(self):
""" Creates the page for the kar-file config options """
settings = self.KaraokeMgr.SongDB.Settings
panel = wx.Panel(self.notebook)
karsizer = wx.BoxSizer(wx.VERTICAL)
hsizer = wx.BoxSizer(wx.HORIZONTAL)
text = wx.StaticText(panel, -1, "Encoding:")
hsizer.Add(text, flag = wx.RIGHT | wx.ALIGN_CENTER_VERTICAL, border = 5)
self.KarEncoding = wx.ComboBox(
panel, -1, value = settings.KarEncoding,
choices = settings.Encodings)
hsizer.Add(self.KarEncoding, flag = wx.EXPAND, proportion = 1)
karsizer.Add(hsizer, flag = wx.EXPAND | wx.LEFT | wx.RIGHT | wx.TOP, border = 10)
hsizer = wx.BoxSizer(wx.HORIZONTAL)
text = wx.StaticText(panel, -1, "Font:")
hsizer.Add(text, flag = wx.RIGHT | wx.ALIGN_CENTER_VERTICAL, border = 5)
self.KarFont = copy.copy(settings.KarFont)
self.KarFontLabel = wx.StaticText(panel, -1, self.KarFont.getDescription())
# Make sure the label has enough space to include big font names.
w, h = self.KarFontLabel.GetSize()
self.KarFontLabel.SetMinSize((max(w, 100), h))
hsizer.Add(self.KarFontLabel, flag = wx.ALIGN_CENTER_VERTICAL, proportion = 1)
b = wx.Button(panel, -1, 'Select')
self.Bind(wx.EVT_BUTTON, self.clickedFontSelect, b)
hsizer.Add(b, flag = wx.EXPAND | wx.LEFT, border = 10)
b = wx.Button(panel, -1, 'Browse')
self.Bind(wx.EVT_BUTTON, self.clickedFontBrowse, b)
hsizer.Add(b, flag = wx.EXPAND | wx.LEFT, border = 10)
karsizer.Add(hsizer, flag = wx.EXPAND | wx.ALL, border = 10)
gsizer = wx.FlexGridSizer(0, 2, 2, 0)
gsizer.AddGrowableCol(1, 1)
text = wx.StaticText(panel, -1, "MIDI Sample rate:")
gsizer.Add(text, flag = wx.RIGHT | wx.ALIGN_CENTER_VERTICAL, border = 5)
self.MIDISampleRate = wx.ComboBox(
panel, -1, value = str(settings.MIDISampleRate),
choices = map(str, settings.SampleRates))
gsizer.Add(self.MIDISampleRate, flag = wx.EXPAND)
karsizer.Add(gsizer, flag = wx.EXPAND | wx.LEFT | wx.RIGHT, border = 10)
self.Colours = {}
self.ColourSamples = {}
gsizer = wx.FlexGridSizer(0, 3, 2, 0)
gsizer.AddGrowableCol(1, 1)
for attribName in ['Ready', 'Sweep', 'Info', 'Title', 'Background']:
text = wx.StaticText(panel, -1, "%s colour:" % (attribName))
gsizer.Add(text, flag = wx.RIGHT | wx.ALIGN_CENTER_VERTICAL, border = 5)
colour = getattr(settings, 'Kar%sColour' % (attribName))
sample = wx.Panel(panel)
sample.SetSize((50, 10))
sample.SetBackgroundColour(colour)
gsizer.Add(sample, flag = wx.EXPAND, proportion = 1)
b = wx.Button(panel, -1, 'Select')
self.Bind(wx.EVT_BUTTON, lambda evt, attribName = attribName: self.clickedColourSelect(attribName), b)
gsizer.Add(b, flag = wx.EXPAND | wx.LEFT, border = 10)
self.Colours[attribName] = colour
self.ColourSamples[attribName] = sample
karsizer.Add(gsizer, flag = wx.EXPAND | wx.ALL, border = 10)
panel.SetSizer(karsizer)
self.notebook.AddPage(panel, 'Kar (MIDI)')
def __layoutCdgPage(self):
""" Creates the page for the cdg-file config options """
settings = self.KaraokeMgr.SongDB.Settings
panel = wx.Panel(self.notebook)
cdgsizer = wx.BoxSizer(wx.VERTICAL)
hsizer = wx.BoxSizer(wx.HORIZONTAL)
text = wx.StaticText(panel, -1, "Zoom:")
hsizer.Add(text, flag = wx.RIGHT | wx.ALIGN_CENTER_VERTICAL, border = 5)
selection = settings.Zoom.index(settings.CdgZoom)
choices = map(lambda z: '%s: %s' % (z, settings.ZoomDesc[z]), settings.Zoom)
self.CdgZoom = wx.Choice(panel, -1, choices = choices)
self.CdgZoom.SetSelection(selection)
hsizer.Add(self.CdgZoom, flag = wx.EXPAND, proportion = 1)
cdgsizer.Add(hsizer, flag = wx.EXPAND | wx.ALL, border = 10)
# Enable/disable optimised C implementation of CDG decoder
self.CdgUseCCheckBox = wx.CheckBox(panel, -1, "Use optimised (C-based) implementation")
self.CdgUseCCheckBox.SetValue(settings.CdgUseC)
# Check that the C implementation is available.
if not pycdg.aux_c:
self.CdgUseCCheckBox.SetValue(False)
self.CdgUseCCheckBox.Enable(False)
cdgsizer.Add(self.CdgUseCCheckBox, flag = wx.LEFT | wx.RIGHT | wx.TOP, border = 10)
# Scan song information from the file names.
infoSizer = wx.BoxSizer(wx.VERTICAL)
# Add checkbox for song-derivation enable/disable
self.SongInfoCheckBoxID = wx.NewId()
self.SongInfoCheckBox = wx.CheckBox(panel, self.SongInfoCheckBoxID, "Derive song information from file names?")
wx.EVT_CHECKBOX(self, self.SongInfoCheckBoxID, self.setSongInfoCheckBox)
infoSizer.Add(self.SongInfoCheckBox, flag = wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL, border = 7)
# Add sub-options for song-derivation
infoOptionsSizer = wx.BoxSizer(wx.VERTICAL)
# Add combo-box for choosing filename scheme
infoFormatSizer = wx.BoxSizer(wx.HORIZONTAL)
self.FileNameStylesText = wx.StaticText(panel, -1, "File naming scheme: ")
infoFormatSizer.Add(self.FileNameStylesText, flag = wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_LEFT, border = 7)
self.FileNameStyles = wx.ComboBox(panel, -1, choices = settings.FileNameCombinations, style = wx.CB_READONLY)
infoFormatSizer.Add(self.FileNameStyles, flag = wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT, proportion = 1, border = 7)
infoOptionsSizer.Add(infoFormatSizer, flag = wx.ALIGN_CENTER_VERTICAL | wx.EXPAND, proportion = 1, border = 7)
# Add checkbox for exclusion of songs from database of files not matching the above scheme
self.ExcludeNonMatchingCheckBox = wx.CheckBox(panel, -1, "Exclude from search results files not matching naming scheme")
self.ExcludeNonMatchingCheckBox.SetValue(settings.ExcludeNonMatchingFilenames)
infoOptionsSizer.Add(self.ExcludeNonMatchingCheckBox, border = 7)
infoSizer.Add(infoOptionsSizer, flag = wx.ALIGN_RIGHT, border = 7)
# Add the sizer with all info-related options to the main page sizer
cdgsizer.Add(infoSizer, flag = wx.EXPAND | wx.ALL, border = 10)
# Update the display to match whether derivation enabled (grey out options if not)
if settings.CdgDeriveSongInformation:
self.SongInfoCheckBox.SetValue(True)
self.FileNameStyles.Enable(True)
self.FileNameStylesText.Enable(True)
self.FileNameStyles.SetSelection(settings.CdgFileNameType)
self.ExcludeNonMatchingCheckBox.Enable (True)
else:
self.FileNameStyles.Enable(False)
self.FileNameStylesText.Enable(False)
self.ExcludeNonMatchingCheckBox.Enable (False)
# Now add final sizer to panel
panel.SetSizer(cdgsizer)
self.notebook.AddPage(panel, 'CDG+MP3/OGG')
def __layoutMpgPage(self):
""" Creates the page for the mpg-file config options """
settings = self.KaraokeMgr.SongDB.Settings
panel = wx.Panel(self.notebook)
mpgsizer = wx.BoxSizer(wx.VERTICAL)
self.MpgNativeCheckBox = wx.CheckBox(
panel, -1, "Use native viewer for mpg files")
self.MpgNativeCheckBox.SetValue(settings.MpgNative)
if not pympg.movie:
self.MpgNativeCheckBox.SetValue(False)
self.MpgNativeCheckBox.Enable(False)
mpgsizer.Add(self.MpgNativeCheckBox, flag = wx.LEFT | wx.RIGHT | wx.TOP, border = 10)
hsizer = wx.BoxSizer(wx.HORIZONTAL)
text = wx.StaticText(panel, -1, "External viewer:")
hsizer.Add(text, flag = wx.RIGHT | wx.ALIGN_CENTER_VERTICAL, border = 5)
self.MpgExternal = wx.TextCtrl(panel, -1, value = settings.MpgExternal)
hsizer.Add(self.MpgExternal, flag = wx.EXPAND, proportion = 1)
b = wx.Button(panel, -1, 'Browse')
self.Bind(wx.EVT_BUTTON, self.clickedExternalBrowse, b)
hsizer.Add(b, flag = wx.EXPAND | wx.LEFT, border = 10)
mpgsizer.Add(hsizer, flag = wx.EXPAND | wx.LEFT | wx.RIGHT | wx.TOP, border = 10)
self.MpgExternalThreadedCheckBox = wx.CheckBox(
panel, -1, "Use a sub-thread to wait for external viewer")
self.MpgExternalThreadedCheckBox.SetValue(settings.MpgExternalThreaded)
mpgsizer.Add(self.MpgExternalThreadedCheckBox, flag = wx.LEFT | wx.RIGHT | wx.TOP, border = 10)
panel.SetSizer(mpgsizer)
self.notebook.AddPage(panel, 'MPG/AVI')
def clickedFontSelect(self, event):
fontData = wx.FontData()
if self.KarFont.size:
font = self.findWxFont(self.KarFont)
if font:
fontData.SetInitialFont(font)
dlg = wx.FontDialog(self, fontData)
result = dlg.ShowModal()
if result != wx.ID_OK:
dlg.Destroy()
return
font = dlg.GetFontData().GetChosenFont()
self.KarFont = pykdb.FontData(font.GetFaceName(),
font.GetPointSize(),
(font.GetWeight() == wx.FONTWEIGHT_BOLD),
(font.GetStyle() == wx.FONTSTYLE_ITALIC))
dlg.Destroy()
self.KarFontLabel.SetLabel(self.KarFont.getDescription())
def clickedFontBrowse(self, event):
defaultDir = manager.FontPath
defaultFile = ''
if not self.KarFont.size:
defaultDir, defaultFile = os.path.split(self.KarFont.name)
if defaultDir == '':
defaultDir = manager.FontPath
dlg = wx.FileDialog(self, 'Font file',
defaultDir = defaultDir, defaultFile = defaultFile,
wildcard = 'True Type Fonts (*.ttf)|*.ttf|All files|*')
result = dlg.ShowModal()
if result != wx.ID_OK:
dlg.Destroy()
return
filename = dlg.GetPath()
dlg.Destroy()
# Is it a file within the font directory?
pathname, basename = os.path.split(filename)
if os.path.normcase(os.path.realpath(pathname)) == os.path.normcase(os.path.realpath(manager.FontPath)):
# Yes, it is a file within the font directory. In this
# case, just store the basename.
filename = basename
self.KarFont = pykdb.FontData(filename)
self.KarFontLabel.SetLabel(self.KarFont.getDescription())
def clickedColourSelect(self, attribName):
colour = self.Colours[attribName]
colourData = wx.ColourData()
colourData.SetColour(colour)
dlg = wx.ColourDialog(self, colourData)
if dlg.ShowModal() != wx.ID_OK:
dlg.Destroy()
return
data = dlg.GetColourData()
r, g, b = data.GetColour()
dlg.Destroy()
colour = (r, g, b)
self.Colours[attribName] = colour
sample = self.ColourSamples[attribName]
sample.SetBackgroundColour(colour)
sample.ClearBackground()
def setSongInfoCheckBox(self, event):
""" This enables and disables the ability to derive song information from file names"""
if self.SongInfoCheckBox.IsChecked():
self.FileNameStyles.Enable(True)
self.FileNameStylesText.Enable(True)
self.FileNameStyles.SetSelection(0)
self.ExcludeNonMatchingCheckBox.Enable (True)
else:
self.FileNameStyles.Enable(False)
self.FileNameStylesText.Enable(False)
self.ExcludeNonMatchingCheckBox.Enable (False)
def clickedCancel(self, event):
self.Show(False)
self.Destroy()
def clickedDefaultPos(self, event):
# Changing this checkbox changes the enabled state of the
# window position fields.
checked = self.DefaultPosCheckBox.IsChecked()
self.PlayerPositionX.Enable(not checked)
self.PlayerPositionY.Enable(not checked)
def clickedExternalBrowse(self, event):
# Pop up a file browser to find the appropriate external program.
if env == ENV_WINDOWS:
wildcard = 'Executable Programs (*.exe)|*.exe'
else:
wildcast = 'All files|*'
dlg = wx.FileDialog(self, 'External Movie Player',
wildcard = wildcard)
result = dlg.ShowModal()
if result != wx.ID_OK:
dlg.Destroy()
return
self.MpgExternal.SetValue(dlg.GetPath())
dlg.Destroy()
def clickedOK(self, event):
self.Show(False)
settings = self.KaraokeMgr.SongDB.Settings
settings.FullScreen = self.FSCheckBox.IsChecked()
settings.NoFrame = self.NoFrameCheckBox.IsChecked()
settings.DoubleBuf = self.DoubleBufCheckBox.IsChecked()
settings.HardwareSurface = self.HardwareSurfaceCheckBox.IsChecked()
settings.PlayerPosition = None
splitVertically = self.SplitVerticallyCheckBox.IsChecked()
if splitVertically != settings.SplitVertically:
settings.SplitVertically = splitVertically
# Re-split the main window.
parent = self.parent
parent.splitter.Unsplit()
if splitVertically:
parent.splitter.SplitVertically(parent.leftPanel, parent.rightPanel, 0.5)
else:
parent.splitter.SplitHorizontally(parent.leftPanel, parent.rightPanel, 0.5)
# Save the auto play option
if self.AutoPlayCheckBox.IsChecked():
settings.AutoPlayList = True
self.parent.playlistButton.SetLabel('Start')
else:
settings.AutoPlayList = False
self.parent.playlistButton.SetLabel('Play')
# Save the double-click play option
if self.DoubleClickPlayCheckBox.IsChecked():
settings.DoubleClickPlayList = True
else:
settings.DoubleClickPlayList = False
# Save the playlist clear option
if self.ClearFromPlayListCheckBox.IsChecked():
settings.ClearFromPlayList = True
else:
settings.ClearFromPlayList = False
# Save the kamikaze option
if self.KamikazeCheckBox.IsChecked():
settings.Kamikaze = True
self.parent.playButton.SetLabel('Kamikaze')
self.parent.Unbind(wx.EVT_BUTTON, self.parent.playButton)
self.parent.Bind(wx.EVT_BUTTON, self.parent.OnKamikazeClicked, self.parent.playButton)
else:
settings.Kamikaze = False
self.parent.playButton.SetLabel('Play')
self.parent.Unbind(wx.EVT_BUTTON, self.parent.playButton)
self.parent.Bind(wx.EVT_BUTTON, self.parent.OnPlayClicked, self.parent.playButton)
# Save the performer option
if self.PerformerCheckBox.IsChecked() != settings.UsePerformerName:
if self.PerformerCheckBox.IsChecked():
settings.UsePerformerName = True
else:
settings.UsePerformerName = False
# Delete and reinitialise the display columns
self.parent.PlaylistPanel.DeleteColumns()
self.parent.PlaylistPanel.CreateColumns()
self.parent.PlaylistPanel.ReloadData()
# Save the Artist/Title display option
if self.ArtistTitleCheckBox.IsChecked() != settings.DisplayArtistTitleCols:
# Store the new setting
if self.ArtistTitleCheckBox.IsChecked():
settings.DisplayArtistTitleCols = True
else: