annotate mainGDI.py @ 2:46fb79167a61 tip

Main Code
author Victor Padilla <victor.padilla.mc@gmail.com>
date Mon, 04 May 2015 22:56:18 +0200
parents
children
rev   line source
victor@2 1 '''
victor@2 2 @organization: Lancaster University & University of Leeds
victor@2 3 @version: 1.0
victor@2 4 Created on 11/12/2014
victor@2 5
victor@2 6 @author: Victor Padilla
victor@2 7 @contact: v.padilla@lancaster.ac.uk
victor@2 8
victor@2 9 GDI interface application with wxpython
victor@2 10 The application can be run through command line (without windows interface) using
victor@2 11 MainMultiOMR library
victor@2 12 '''
victor@2 13 import wx
victor@2 14 import webbrowser
victor@2 15 from Functions import AddingXMLSingleMeasures
victor@2 16 from Automatism import BatchOMR
victor@2 17 from MainMultiOMR import MainMultiOMR
victor@2 18
victor@2 19 import modulefinder
victor@2 20
victor@2 21 class MainWindow(wx.Frame):
victor@2 22 '''
victor@2 23 Configuration of the main interface.
victor@2 24 The application could be used without this interface, just with the classes of MainMultiOMR
victor@2 25 '''
victor@2 26
victor@2 27 def __init__(self, parent, title):
victor@2 28 '''
victor@2 29 init function
victor@2 30
victor@2 31 '''
victor@2 32 self.runMainMenu(parent,title)
victor@2 33 mf=MainMultiOMR()
victor@2 34 mf._loadNWunsch()
victor@2 35
victor@2 36
victor@2 37 def runMainMenu(self,parent,title):
victor@2 38 '''
victor@2 39 Configure the main menu for the application
victor@2 40
victor@2 41 '''
victor@2 42 wx.Frame.__init__(self, parent, title=title, size=(400,400))
victor@2 43 self.control = wx.TextCtrl(self, style=wx.TE_MULTILINE)
victor@2 44 self.CreateStatusBar()
victor@2 45
victor@2 46 preprocessmenu=wx.Menu()
victor@2 47 automatmenu=wx.Menu()
victor@2 48 processmenu= wx.Menu()
victor@2 49 resultmenu=wx.Menu()
victor@2 50 utilsmenu=wx.Menu()
victor@2 51 menu=wx.Menu()
victor@2 52
victor@2 53 menuPDF2TIFF=preprocessmenu.Append(wx.ID_ANY, "& PDF to TIFF"," PDF to TIFF")
victor@2 54 menuOssias=preprocessmenu.Append(wx.ID_ANY, "& Remove Ossias"," Remove Ossias")
victor@2 55
victor@2 56 menuPSAuto=automatmenu.Append(wx.ID_ANY, "&PS"," PS")
victor@2 57 menuSSAuto=automatmenu.Append(wx.ID_ANY, "&SS"," SS")
victor@2 58 menuCPAuto=automatmenu.Append(wx.ID_ANY, "&CP"," CP")
victor@2 59 menuSEAuto=automatmenu.Append(wx.ID_ANY, "&SE"," SE")
victor@2 60 automatmenu.AppendSeparator()
victor@2 61 menuAllAuto=automatmenu.Append(wx.ID_ANY, "&All"," All")
victor@2 62 automatmenu.AppendSeparator()
victor@2 63 menuCleanXML=automatmenu.Append(wx.ID_ANY, "&Clean XML"," Clean XML")
victor@2 64 automatmenu.AppendSeparator()
victor@2 65 menuSetupApp=automatmenu.Append(wx.ID_ANY, "&Setup Application"," Setup Application")
victor@2 66
victor@2 67 menuOpenOneMovement = processmenu.Append(wx.ID_OPEN, "&Process one Movement"," Process one Movement")
victor@2 68 menuOpenLoopBigData = processmenu.Append(wx.ID_ANY, "&Process Big Data"," Process big Data")
victor@2 69 menuOpenLoopBigDataAdapt = processmenu.Append(wx.ID_ANY, "&Process Big Data Adapting OMRs"," Process big Data Adapting OMRs")
victor@2 70 processmenu.AppendSeparator()
victor@2 71 menuOpenCompleteProcess = processmenu.Append(wx.ID_ANY, "&Complete process"," Complete Process")
victor@2 72
victor@2 73 menuOpenOneMovementGround=resultmenu.Append(wx.ID_ANY, "&Result one Movement"," Result one Movement")
victor@2 74 menuOpenLoopBigDataGround = resultmenu.Append(wx.ID_ANY, "&Result Big Data"," Result Big Data")
victor@2 75 processmenu.AppendSeparator()
victor@2 76 menuFinalXLS = resultmenu.Append(wx.ID_ANY, "&Write final xls"," Write final xls")
victor@2 77
victor@2 78
victor@2 79 menuWrongMeasures = utilsmenu.Append(wx.ID_ANY, "&View Wrong Measures"," Wrong measures")
victor@2 80 utilsmenu.AppendSeparator()
victor@2 81 menuJoinXMLs = utilsmenu.Append(wx.ID_ANY, "&Join XML"," Join XML")
victor@2 82 utilsmenu.AppendSeparator()
victor@2 83 menuViewM21 = utilsmenu.Append(wx.ID_ANY, "&View Through Music21"," View Music21")
victor@2 84 utilsmenu.AppendSeparator()
victor@2 85 menuConvertKrnToMusicXML = utilsmenu.Append(wx.ID_ANY, "&Krn to MusicXML"," Krn to MusicXML")
victor@2 86 menuConvertMidiToMusicXML = utilsmenu.Append(wx.ID_ANY, "&Midi to MusicXML"," Midi to MusicXML")
victor@2 87 menuConvertVoicesToChord = utilsmenu.Append(wx.ID_ANY, "&Voices to Chord"," Voices to Chord")
victor@2 88 menuConvertBeamsToTriplets = utilsmenu.Append(wx.ID_ANY, "&Beams to Triplets"," Beams to Triplets")
victor@2 89 menuRemovesEmptyVoices = utilsmenu.Append(wx.ID_ANY, "&Removes empty voices"," Removes empty voices")
victor@2 90 menuRemovesGaps = utilsmenu.Append(wx.ID_ANY, "&Removes Gaps"," Removes Gaps")
victor@2 91 utilsmenu.AppendSeparator()
victor@2 92 menuAdaptOMRs = utilsmenu.Append(wx.ID_ANY, "&Adapt OMRs"," Adapt OMRs")
victor@2 93
victor@2 94 menuAbout = menu.Append(wx.ID_ABOUT, "&About"," Information about this program")
victor@2 95 menu.AppendSeparator()
victor@2 96 menuDocumentation = menu.Append(wx.ID_ANY, "& Technical Documentation"," Technical Documentation")
victor@2 97 menuUserManual = menu.Append(wx.ID_ANY, "& User Manual"," User Manual")
victor@2 98 menu.AppendSeparator()
victor@2 99 menuExit = menu.Append(wx.ID_EXIT,"E&xit"," Terminate the program")
victor@2 100
victor@2 101 menuBar = wx.MenuBar()
victor@2 102 menuBar.Append(preprocessmenu,"&Preprocessing")
victor@2 103 menuBar.Append(automatmenu,"&Automatism")
victor@2 104 menuBar.Append(processmenu,"&Process")
victor@2 105 menuBar.Append(resultmenu,"&Results")
victor@2 106 menuBar.Append(utilsmenu,"&Utils")
victor@2 107 menuBar.Append(menu,"&Help")
victor@2 108
victor@2 109 self.SetMenuBar(menuBar)
victor@2 110
victor@2 111 self.Bind(wx.EVT_MENU, self.OnPDF2TIFF, menuPDF2TIFF)
victor@2 112 self.Bind(wx.EVT_MENU, self.OnRemoveOssias, menuOssias)
victor@2 113
victor@2 114 self.Bind(wx.EVT_MENU, self.OnViewPSAuto, menuPSAuto)
victor@2 115 self.Bind(wx.EVT_MENU, self.OnViewSSAuto, menuSSAuto)
victor@2 116 self.Bind(wx.EVT_MENU, self.OnViewCPAuto, menuCPAuto)
victor@2 117 self.Bind(wx.EVT_MENU, self.OnViewSEAuto, menuSEAuto)
victor@2 118 self.Bind(wx.EVT_MENU, self.OnViewAllAuto, menuAllAuto)
victor@2 119 self.Bind(wx.EVT_MENU, self.OnViewCleanXML, menuCleanXML)
victor@2 120 self.Bind(wx.EVT_MENU, self.OnViewSetupApp, menuSetupApp)
victor@2 121
victor@2 122 self.Bind(wx.EVT_MENU, self.OnAbout, menuAbout)
victor@2 123 self.Bind(wx.EVT_MENU, self.OnDocumentation, menuDocumentation)
victor@2 124 self.Bind(wx.EVT_MENU, self.OnUserManual, menuUserManual)
victor@2 125 self.Bind(wx.EVT_MENU, self.OnOpenOneMovement, menuOpenOneMovement)
victor@2 126 self.Bind(wx.EVT_MENU, self.OnOpenLoopBigData, menuOpenLoopBigData)
victor@2 127 self.Bind(wx.EVT_MENU, self.OnOpenLoopBigDataAdapt, menuOpenLoopBigDataAdapt)
victor@2 128 self.Bind(wx.EVT_MENU, self.OnOpenCompleteProcess, menuOpenCompleteProcess)
victor@2 129 self.Bind(wx.EVT_MENU, self.OnExit, menuExit)
victor@2 130
victor@2 131 self.Bind(wx.EVT_MENU, self.OnViewWrongMeasures, menuWrongMeasures)
victor@2 132 self.Bind(wx.EVT_MENU, self.OnViewJoinXMLs, menuJoinXMLs)
victor@2 133 self.Bind(wx.EVT_MENU, self.OnViewM21, menuViewM21)
victor@2 134 self.Bind(wx.EVT_MENU, self.OnViewConvertKrnToMusicXML, menuConvertKrnToMusicXML)
victor@2 135 self.Bind(wx.EVT_MENU, self.OnViewConvertMidiToMusicXML, menuConvertMidiToMusicXML)
victor@2 136 self.Bind(wx.EVT_MENU, self.OnViewConvertVoicesToChord, menuConvertVoicesToChord)
victor@2 137 self.Bind(wx.EVT_MENU, self.OnViewConvertBeamsToTriplets, menuConvertBeamsToTriplets)
victor@2 138 self.Bind(wx.EVT_MENU, self.OnViewRemovesEmptyVoices, menuRemovesEmptyVoices)
victor@2 139 self.Bind(wx.EVT_MENU, self.OnViewRemovesGaps, menuRemovesGaps)
victor@2 140 self.Bind(wx.EVT_MENU, self.OnViewAdaptOMRs, menuAdaptOMRs)
victor@2 141
victor@2 142
victor@2 143
victor@2 144 self.Bind(wx.EVT_MENU, self.OnOpenOneMovementGround, menuOpenOneMovementGround)
victor@2 145 self.Bind(wx.EVT_MENU, self.OnOpenLoopBigDataGround, menuOpenLoopBigDataGround)
victor@2 146 self.Bind(wx.EVT_MENU, self.OnOpenFinalXLS, menuFinalXLS)
victor@2 147
victor@2 148 self.Show(True)
victor@2 149
victor@2 150
victor@2 151 def OnPDF2TIFF(self,e):
victor@2 152 dlg = wx.FileDialog(self, "Open .PDF file", "", "",
victor@2 153 "PDF files (*.pdf)|*.pdf", wx.FD_OPEN | wx.FD_FILE_MUST_EXIST)
victor@2 154 mmo=MainMultiOMR()
victor@2 155 if dlg.ShowModal() == wx.ID_OK:
victor@2 156 filename = dlg.GetPath()
victor@2 157 mmo.processPDF2TIFF(filename)
victor@2 158 print "END"
victor@2 159 dlg.Destroy()
victor@2 160
victor@2 161
victor@2 162 def OnRemoveOssias(self,e):
victor@2 163 dlg = wx.DirDialog(None, "Choose a directory","",wx.DD_DEFAULT_STYLE)
victor@2 164 mmo=MainMultiOMR()
victor@2 165 if dlg.ShowModal() == wx.ID_OK:
victor@2 166 dirGeneral = dlg.GetPath()
victor@2 167 mmo.processOssia(dirGeneral)
victor@2 168 dlg.Destroy()
victor@2 169
victor@2 170
victor@2 171
victor@2 172 def OnViewPSAuto(self,e):
victor@2 173 '''
victor@2 174 ################ AUTOMATISM MENU ##################
victor@2 175 Search all the images folder and convert .tif images to .XML
victor@2 176 using PhotoScore (SIKULI)
victor@2 177 '''
victor@2 178 batchOMR=BatchOMR()
victor@2 179 dlg = wx.DirDialog(None, "Choose a directory","",wx.DD_DEFAULT_STYLE)
victor@2 180 if dlg.ShowModal() == wx.ID_OK:
victor@2 181 dirname = dlg.GetPath()
victor@2 182 batchOMR.processAllTiffFiles(dirname,"PS")
victor@2 183 print "END"
victor@2 184 dlg.Destroy()
victor@2 185
victor@2 186 def OnViewSSAuto(self,e):
victor@2 187 '''
victor@2 188 ################ AUTOMATISM MENU ##################
victor@2 189 Search all the images folder and convert .tif images to .XML
victor@2 190 using SmartScore (SIKULI)
victor@2 191 '''
victor@2 192 batchOMR=BatchOMR()
victor@2 193 dlg = wx.DirDialog(None, "Choose a directory","",wx.DD_DEFAULT_STYLE)
victor@2 194 if dlg.ShowModal() == wx.ID_OK:
victor@2 195 dirname = dlg.GetPath()
victor@2 196 batchOMR.processAllTiffFiles(dirname,"SS")
victor@2 197 print "END"
victor@2 198 dlg.Destroy()
victor@2 199
victor@2 200 def OnViewCPAuto(self,e):
victor@2 201 '''
victor@2 202 ################ AUTOMATISM MENU ##################
victor@2 203 Search all the images folder and convert .tif images to .XML
victor@2 204 using Capella (SIKULI)
victor@2 205 '''
victor@2 206 batchOMR=BatchOMR()
victor@2 207 dlg = wx.DirDialog(None, "Choose a directory","",wx.DD_DEFAULT_STYLE)
victor@2 208 if dlg.ShowModal() == wx.ID_OK:
victor@2 209 dirname = dlg.GetPath()
victor@2 210 batchOMR.processAllTiffFiles(dirname,"CP")
victor@2 211 print "END"
victor@2 212 dlg.Destroy()
victor@2 213
victor@2 214 def OnViewSEAuto(self,e):
victor@2 215 '''
victor@2 216 ################ AUTOMATISM MENU ##################
victor@2 217 Search all the images folder and convert .tif images to .XML
victor@2 218 using SharpEye (SIKULI)
victor@2 219 '''
victor@2 220 batchOMR=BatchOMR()
victor@2 221 dlg = wx.DirDialog(None, "Choose a directory","",wx.DD_DEFAULT_STYLE)
victor@2 222 if dlg.ShowModal() == wx.ID_OK:
victor@2 223 dirname = dlg.GetPath()
victor@2 224 batchOMR.processAllTiffFiles(dirname,"SE")
victor@2 225 print "END"
victor@2 226 dlg.Destroy()
victor@2 227
victor@2 228 def OnViewAllAuto(self,e):
victor@2 229 '''
victor@2 230 ################ AUTOMATISM MENU ##################
victor@2 231 Search all the images folder and convert .tif images to .XML
victor@2 232 using ALL the predefined OMR (SIKULI)
victor@2 233 '''
victor@2 234 batchOMR=BatchOMR()
victor@2 235 dlg = wx.DirDialog(None, "Choose a directory","",wx.DD_DEFAULT_STYLE)
victor@2 236 if dlg.ShowModal() == wx.ID_OK:
victor@2 237 dirname = dlg.GetPath()
victor@2 238 batchOMR.processAllTiffFiles(dirname,"ALL")
victor@2 239 print "END"
victor@2 240 dlg.Destroy()
victor@2 241
victor@2 242 def OnViewCleanXML(self,e):
victor@2 243 '''
victor@2 244 ################ AUTOMATISM MENU ##################
victor@2 245 Utility for deleting all the files produced by the different OMR
victor@2 246 (.XML files and .mro in case of SharpEye)
victor@2 247 '''
victor@2 248 batchOMR=BatchOMR()
victor@2 249 if wx.MessageBox("All XML Files will be deleted. Do you wish to continue?", "Please confirm",
victor@2 250 wx.ICON_QUESTION | wx.YES_NO, self) == wx.NO:
victor@2 251 return
victor@2 252 dlg = wx.DirDialog(None, "Choose a directory","",wx.DD_DEFAULT_STYLE)
victor@2 253 if dlg.ShowModal() == wx.ID_OK:
victor@2 254 dirname = dlg.GetPath()
victor@2 255 batchOMR.cleanXMLFiles(dirname)
victor@2 256 print "END"
victor@2 257 dlg.Destroy()
victor@2 258
victor@2 259 def OnViewSetupApp(self,e):
victor@2 260 '''
victor@2 261 ################ AUTOMATISM MENU ##################
victor@2 262 Utility for setup the 'Process' folder once the OMR files are finished
victor@2 263 Two steps:
victor@2 264 1.- Copy the XML files
victor@2 265 2.- Take the .krn file and convert to ground.xml in the appropriate folder
victor@2 266 '''
victor@2 267 batchOMR=BatchOMR()
victor@2 268 dlg = wx.DirDialog(None, "Choose a directory","",wx.DD_DEFAULT_STYLE)
victor@2 269 if dlg.ShowModal() == wx.ID_OK:
victor@2 270 dirname = dlg.GetPath()
victor@2 271 print "-------COPY XML FILES----------"
victor@2 272 batchOMR.setupApp(dirname)
victor@2 273 print "-------CONVERT GROUND----------"
victor@2 274 batchOMR.setGround(dirname)
victor@2 275 ######## preparing files
victor@2 276
victor@2 277 print "END"
victor@2 278 dlg.Destroy()
victor@2 279
victor@2 280
victor@2 281
victor@2 282 def OnOpenOneMovement(self,e):
victor@2 283 '''
victor@2 284 ######################### PROCESS MENU ###########################
victor@2 285 Processing just one movement
victor@2 286 '''
victor@2 287
victor@2 288 dlg = wx.DirDialog(None, "Choose a directory","",wx.DD_DEFAULT_STYLE)
victor@2 289 mf=MainMultiOMR()
victor@2 290 if dlg.ShowModal() == wx.ID_OK:
victor@2 291 dirGeneral = dlg.GetPath()
victor@2 292 print "----START----:",dirGeneral
victor@2 293 mf.processMovement(dirGeneral)
victor@2 294
victor@2 295 dlg.Destroy()
victor@2 296
victor@2 297 def OnOpenLoopBigData(self,e):
victor@2 298 '''
victor@2 299 ######################### PROCESS MENU ###########################
victor@2 300 BigData Process menu option
victor@2 301 The program is waiting for files to process
victor@2 302 This option can be executed in a different machine reading a common folder
victor@2 303 '''
victor@2 304 dlg = wx.DirDialog(None, "Choose a directory","",wx.DD_DEFAULT_STYLE)
victor@2 305 mf=MainMultiOMR()
victor@2 306 if dlg.ShowModal() == wx.ID_OK:
victor@2 307 rootDir = dlg.GetPath()
victor@2 308 mf.runLoopBigData(rootDir,adaptOMRs=False)
victor@2 309 dlg.Destroy()
victor@2 310
victor@2 311 def OnOpenLoopBigDataAdapt(self,e):
victor@2 312 '''
victor@2 313 ######################### PROCESS MENU ###########################
victor@2 314 BigData Process menu option
victor@2 315 The program is waiting for files to process
victor@2 316 This option can be executed in a different machine reading a common folder
victor@2 317 '''
victor@2 318 dlg = wx.DirDialog(None, "Choose a directory","",wx.DD_DEFAULT_STYLE)
victor@2 319 mf=MainMultiOMR()
victor@2 320 if dlg.ShowModal() == wx.ID_OK:
victor@2 321 rootDir = dlg.GetPath()
victor@2 322 mf.runLoopBigData(rootDir,adaptOMRs=True)
victor@2 323 dlg.Destroy()
victor@2 324
victor@2 325
victor@2 326 def OnOpenCompleteProcess(self,e):
victor@2 327 '''
victor@2 328 ######################### PROCESS MENU ###########################
victor@2 329 Run the complete process:
victor@2 330 1- Convert all .tif files to .XML (SIKULI)
victor@2 331 2- Processing all the files
victor@2 332 3- Get all the results
victor@2 333 This option is thought in mind for running in a single machine
victor@2 334 '''
victor@2 335 dlg = wx.DirDialog(None, "Choose a directory","",wx.DD_DEFAULT_STYLE)
victor@2 336 mf=MainMultiOMR()
victor@2 337 if dlg.ShowModal() == wx.ID_OK:
victor@2 338 dirGeneral = dlg.GetPath()
victor@2 339 print "----START----:",dirGeneral
victor@2 340 mf.runCompleteProcess(dirGeneral)
victor@2 341
victor@2 342 dlg.Destroy()
victor@2 343
victor@2 344
victor@2 345 def OnOpenOneMovementGround(self,e):
victor@2 346 '''
victor@2 347 ########################## RESULT MENU #################################
victor@2 348 Check each .xml file against 'ground.xml' and evaluate the differences.
victor@2 349 The final result is written in the appropriated file
victor@2 350 Example:
victor@2 351 k428\Process\m1\parts\resultGeneral.xlsx
victor@2 352 '''
victor@2 353 dlg = wx.DirDialog(None, "Choose a directory","",wx.DD_DEFAULT_STYLE)
victor@2 354 mf=MainMultiOMR()
victor@2 355 if dlg.ShowModal() == wx.ID_OK:
victor@2 356 dirGeneral = dlg.GetPath()
victor@2 357 mf.processMovementGround(dirGeneral)
victor@2 358 dlg.Destroy()
victor@2 359
victor@2 360 def OnOpenLoopBigDataGround(self,e):
victor@2 361 '''
victor@2 362 ########################## RESULT MENU #################################
victor@2 363 BigData Result menu option
victor@2 364 The program is waiting for files to get the result
victor@2 365 This option can be executed in a different machine reading a common folder
victor@2 366 '''
victor@2 367 dlg = wx.DirDialog(None, "Choose a directory","",wx.DD_DEFAULT_STYLE)
victor@2 368 mf=MainMultiOMR()
victor@2 369 if dlg.ShowModal() == wx.ID_OK:
victor@2 370 rootDir = dlg.GetPath()
victor@2 371 mf.runLoopBigDataGround(rootDir)
victor@2 372
victor@2 373 dlg.Destroy()
victor@2 374
victor@2 375 def OnOpenFinalXLS(self,e):
victor@2 376 '''
victor@2 377 ########################## RESULT MENU #################################
victor@2 378 BigData Result menu option
victor@2 379 The program is waiting for files to get the result
victor@2 380 This option can be executed in a different machine reading a common folder
victor@2 381 '''
victor@2 382 dlg = wx.DirDialog(None, "Choose a directory","",wx.DD_DEFAULT_STYLE)
victor@2 383 mf=MainMultiOMR()
victor@2 384 if dlg.ShowModal() == wx.ID_OK:
victor@2 385 rootDir = dlg.GetPath()
victor@2 386 mf.runFinalXLS(rootDir)
victor@2 387
victor@2 388 dlg.Destroy()
victor@2 389
victor@2 390 def OnViewWrongMeasures(self,e):
victor@2 391 '''
victor@2 392 ########################## UTILS MENU #####################################
victor@2 393 Check the different errors in measures using
victor@2 394 different procedures
victor@2 395 '''
victor@2 396 dlg = wx.DirDialog(None, "Choose a directory","",wx.DD_DEFAULT_STYLE)
victor@2 397 mf=MainMultiOMR()
victor@2 398 if dlg.ShowModal() == wx.ID_OK:
victor@2 399 dirname = dlg.GetPath()
victor@2 400 print "---------S1------------"
victor@2 401 mf.runViewWrongMeasures(dirname)
victor@2 402
victor@2 403 dlg.Destroy()
victor@2 404
victor@2 405
victor@2 406 def OnViewJoinXMLs(self,e):
victor@2 407 '''
victor@2 408 ########################## UTILS MENU #####################################
victor@2 409 Add different measures
victor@2 410 (under development)
victor@2 411 '''
victor@2 412 dlg = wx.DirDialog(None, "Choose a directory","",wx.DD_DEFAULT_STYLE)
victor@2 413 if dlg.ShowModal() == wx.ID_OK:
victor@2 414 dirname = dlg.GetPath()
victor@2 415 addingXML=AddingXMLSingleMeasures()
victor@2 416 addingXML.runViewJoinXML(dirname)
victor@2 417
victor@2 418 dlg.Destroy()
victor@2 419
victor@2 420
victor@2 421
victor@2 422 def OnViewM21(self,e):
victor@2 423 '''
victor@2 424 ########################## UTILS MENU #####################################
victor@2 425 Show an .xml file processed by music21
victor@2 426 to check the differences and possible errors
victor@2 427 '''
victor@2 428 dlg = wx.DirDialog(None, "Choose a directory","",wx.DD_DEFAULT_STYLE)
victor@2 429 mf=MainMultiOMR()
victor@2 430 if dlg.ShowModal() == wx.ID_OK:
victor@2 431 dirname = dlg.GetPath()
victor@2 432 mf.runViewM21(dirname)
victor@2 433 dlg.Destroy()
victor@2 434
victor@2 435
victor@2 436
victor@2 437
victor@2 438 def OnViewConvertKrnToMusicXML(self,e):
victor@2 439 '''
victor@2 440 ########################## UTILS MENU #####################################
victor@2 441 convert one .krn file to .xml
victor@2 442 '''
victor@2 443 dlg = wx.FileDialog(self, "Open .krn file", "", "",
victor@2 444 "KRN files (*.krn)|*.krn", wx.FD_OPEN | wx.FD_FILE_MUST_EXIST)
victor@2 445 mf=MainMultiOMR()
victor@2 446 if dlg.ShowModal() == wx.ID_OK:
victor@2 447 filename = dlg.GetPath()
victor@2 448 mf.runConvertKrnToMusicXML(filename)
victor@2 449 print "END"
victor@2 450 dlg.Destroy()
victor@2 451
victor@2 452 def OnViewConvertMidiToMusicXML(self,e):
victor@2 453 '''
victor@2 454 ########################## UTILS MENU #####################################
victor@2 455 convert one .midi file to .xml
victor@2 456 '''
victor@2 457 dlg = wx.FileDialog(self, "Open .mid file", "", "",
victor@2 458 "MIDI files (*.mid)|*.mid", wx.FD_OPEN | wx.FD_FILE_MUST_EXIST)
victor@2 459 mf=MainMultiOMR()
victor@2 460 if dlg.ShowModal() == wx.ID_OK:
victor@2 461 filename = dlg.GetPath()
victor@2 462 mf.runConvertMidiToMusicXML(filename)
victor@2 463 print "END"
victor@2 464 dlg.Destroy()
victor@2 465
victor@2 466 def OnViewConvertVoicesToChord(self,e):
victor@2 467 '''
victor@2 468 ########################## UTILS MENU #####################################
victor@2 469 '''
victor@2 470 dlg = wx.FileDialog(self, "Open .mid file", "", "",
victor@2 471 "xml files (*.xml)|*.xml", wx.FD_OPEN | wx.FD_FILE_MUST_EXIST)
victor@2 472 mf=MainMultiOMR()
victor@2 473 if dlg.ShowModal() == wx.ID_OK:
victor@2 474 filename = dlg.GetPath()
victor@2 475 mf.runConvertVoicesToChord(filename)
victor@2 476 print "END"
victor@2 477 dlg.Destroy()
victor@2 478
victor@2 479 def OnViewConvertBeamsToTriplets(self,e):
victor@2 480 '''
victor@2 481 ########################## UTILS MENU #####################################
victor@2 482 '''
victor@2 483 dlg = wx.FileDialog(self, "Open .mid file", "", "",
victor@2 484 "xml files (*.xml)|*.xml", wx.FD_OPEN | wx.FD_FILE_MUST_EXIST)
victor@2 485 mf=MainMultiOMR()
victor@2 486 if dlg.ShowModal() == wx.ID_OK:
victor@2 487 filename = dlg.GetPath()
victor@2 488 mf.runConvertBeamsToTriplets(filename)
victor@2 489 print "END"
victor@2 490 dlg.Destroy()
victor@2 491
victor@2 492 def OnViewRemovesEmptyVoices(self,e):
victor@2 493 '''
victor@2 494 ########################## UTILS MENU #####################################
victor@2 495 '''
victor@2 496 dlg = wx.FileDialog(self, "Open .mid file", "", "",
victor@2 497 "xml files (*.xml)|*.xml", wx.FD_OPEN | wx.FD_FILE_MUST_EXIST)
victor@2 498 mf=MainMultiOMR()
victor@2 499 if dlg.ShowModal() == wx.ID_OK:
victor@2 500 filename = dlg.GetPath()
victor@2 501 mf.runRemovesEmptyVoices(filename)
victor@2 502 print "END"
victor@2 503 dlg.Destroy()
victor@2 504 def OnViewRemovesGaps(self,e):
victor@2 505 '''
victor@2 506 ########################## UTILS MENU #####################################
victor@2 507 '''
victor@2 508 dlg = wx.FileDialog(self, "Open .mid file", "", "",
victor@2 509 "xml files (*.xml)|*.xml", wx.FD_OPEN | wx.FD_FILE_MUST_EXIST)
victor@2 510 mf=MainMultiOMR()
victor@2 511 if dlg.ShowModal() == wx.ID_OK:
victor@2 512 filename = dlg.GetPath()
victor@2 513 mf.runRemovesGaps(filename)
victor@2 514 print "END"
victor@2 515 dlg.Destroy()
victor@2 516
victor@2 517 def OnViewAdaptOMRs(self,e):
victor@2 518 '''
victor@2 519 ########################## UTILS MENU #####################################
victor@2 520 '''
victor@2 521
victor@2 522 dlg = wx.DirDialog(None, "Choose a directory","",wx.DD_DEFAULT_STYLE)
victor@2 523 mf=MainMultiOMR()
victor@2 524 if dlg.ShowModal() == wx.ID_OK:
victor@2 525 dirname = dlg.GetPath()
victor@2 526 mf.runAdaptOMRs(dirname)
victor@2 527 dlg.Destroy()
victor@2 528
victor@2 529 def OnAbout(self,e):
victor@2 530 '''
victor@2 531 ########################## MENU #####################################
victor@2 532 about menu option
victor@2 533 '''
victor@2 534 dlg = wx.MessageDialog( self, "Big Data Project", "Big Data Project", wx.OK)
victor@2 535 dlg.ShowModal()
victor@2 536 dlg.Destroy()
victor@2 537
victor@2 538 def OnDocumentation(self,e):
victor@2 539 '''
victor@2 540 ########################## MENU #####################################
victor@2 541 open documentation web
victor@2 542 '''
victor@2 543 webbrowser.open_new("..\\Documentation\\html\\index.html")
victor@2 544 def OnUserManual(self,e):
victor@2 545 '''
victor@2 546 ########################## MENU #####################################
victor@2 547 open user manual
victor@2 548 '''
victor@2 549 webbrowser.open_new("..\\Documentation\\Manual.pdf")
victor@2 550 def OnExit(self,e):
victor@2 551 '''
victor@2 552 ########################## MENU #####################################
victor@2 553 exit menu option
victor@2 554 '''
victor@2 555 self.Close(True)
victor@2 556
victor@2 557
victor@2 558
victor@2 559
victor@2 560 app = wx.App(False)
victor@2 561 frame = MainWindow(None, "Big Data Process")
victor@2 562 app.MainLoop()