forked from belangeo/soundgrain
/
SoundGrain.py
63 lines (55 loc) · 1.99 KB
/
SoundGrain.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
#!/usr/bin/env python
# encoding: utf-8
"""
Copyright 2009-2017 Olivier Belanger
This file is part of SoundGrain.
SoundGrain 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.
SoundGrain 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 SoundGrain. If not, see <http://www.gnu.org/licenses/>.
"""
import sys
import wx
from Resources.constants import *
from Resources.splash import SoundGrainSplashScreen
from Resources.MainFrame import MainFrame
class SoundGrainApp(wx.App):
def __init__(self, *args, **kwargs):
wx.App.__init__(self, *args, **kwargs)
sysx = wx.SystemSettings.GetMetric(wx.SYS_SCREEN_X)
sysy = wx.SystemSettings.GetMetric(wx.SYS_SCREEN_Y)
if sysx < 900:
sizex = sysx - 40
else:
sizex = 900
if sysy < 720:
sizey = sysy - 40
else:
sizey = 720
self.frame = MainFrame(None, -1, pos=(0, 20), size=(sizex, sizey),
screen_size=(sysx, sysy))
def MacOpenFiles(self, filenames):
if type(filenames) is not list:
filenames = [filenames]
if hasattr(self, "frame"):
self.frame.loadFile(ensureNFD(filenames[0]))
def MacReopenApp(self):
try:
self.frame.Raise()
except:
pass
if __name__ == '__main__':
sgfile = None
if len(sys.argv) > 1:
sgfile = sys.argv[1]
app = SoundGrainApp(redirect=False)
splash = SoundGrainSplashScreen(None, SPLASH_FILE, app.frame)
if sgfile:
wx.CallAfter(app.frame.loadFile, ensureNFD(sgfile))
app.MainLoop()