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
|
#! /usr/bin/env python
# encoding: utf-8
"""
Copyright 2013 iACT, Universite de Montreal, Jean Piche, Olivier Belanger, Jean-Michel Dumas
This file is part of Cecilia 5.
Cecilia 5 is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Cecilia 5 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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with Cecilia 5. If not, see <http://www.gnu.org/licenses/>.
"""
import wx
import os, sys, random
from cecilia.Resources.constants import *
from cecilia.Resources import audio, CeciliaMainFrame
import cecilia.Resources.CeciliaLib as CeciliaLib
from cecilia.Resources.splash import CeciliaSplashScreen
def GetRoundBitmap( w, h, r ):
maskColor = wx.Colour(0,0,0)
shownColor = wx.Colour(5,5,5)
b = wx.EmptyBitmap(w,h)
dc = wx.MemoryDC(b)
dc.SetBrush(wx.Brush(maskColor))
dc.DrawRectangle(0,0,w,h)
dc.SetBrush(wx.Brush(shownColor))
dc.SetPen(wx.Pen(shownColor))
dc.DrawRoundedRectangle(0,0,w,h,r)
dc.SelectObject(wx.NullBitmap)
b.SetMaskColour(maskColor)
return b
def GetRoundShape( w, h, r ):
return wx.RegionFromBitmap(GetRoundBitmap(w,h,r))
class CeciliaApp(wx.App):
def __init__(self, *args, **kwargs):
wx.App.__init__(self, *args, **kwargs)
def MacOpenFile(self, filename):
CeciliaLib.getVar("mainFrame").onOpen(filename)
def onStart():
ceciliaMainFrame = CeciliaMainFrame.CeciliaMainFrame(None, -1)
CeciliaLib.setVar("mainFrame", ceciliaMainFrame)
file = None
if len(sys.argv) >= 2:
file = sys.argv[1]
if file:
ceciliaMainFrame.onOpen(file)
else:
categories = [folder for folder in os.listdir(MODULES_PATH) if not folder.startswith(".")]
category = random.choice(categories)
files = [f for f in os.listdir(os.path.join(MODULES_PATH, category)) if f.endswith(FILE_EXTENSION)]
file = random.choice(files)
ceciliaMainFrame.onOpen(os.path.join(MODULES_PATH, category, file), True)
if __name__ == '__main__':
reload(sys)
sys.setdefaultencoding('utf-8')
if not os.path.isdir(TMP_PATH):
os.mkdir(TMP_PATH)
if not os.path.isfile(os.path.join(TMP_PATH,'.recent.txt')):
f = open(os.path.join(TMP_PATH,'.recent.txt'), "w")
f.close()
if not os.path.isdir(AUTOMATION_SAVE_PATH):
os.mkdir(AUTOMATION_SAVE_PATH)
audioServer = audio.AudioServer()
CeciliaLib.setVar("audioServer", audioServer)
try:
CeciliaLib.queryAudioMidiDrivers()
except:
pass
app = CeciliaApp(redirect=False)
wx.SetDefaultPyEncoding('utf-8')
try:
display = wx.Display()
numDisp = display.GetCount()
if CeciliaLib.getVar("DEBUG"):
print 'Numbers of displays:', numDisp
displays = []
displayOffset = []
displaySize = []
for i in range(numDisp):
displays.append(wx.Display(i))
offset = displays[i].GetGeometry()[:2]
size = displays[i].GetGeometry()[2:]
if CeciliaLib.getVar("DEBUG"):
print 'display %d:' % i
print ' pos =', offset
print ' size =', size
displayOffset.append(offset)
displaySize.append(size)
except:
numDisp = 1
displayOffset = [(0, 0)]
displaySize = [(1024, 768)]
CeciliaLib.setVar("numDisplays", numDisp)
CeciliaLib.setVar("displayOffset", displayOffset)
CeciliaLib.setVar("displaySize", displaySize)
sp = CeciliaSplashScreen(None, img=SPLASH_FILE_PATH, callback=onStart)
app.MainLoop()
|