-
Notifications
You must be signed in to change notification settings - Fork 0
/
youmoney.py
executable file
·123 lines (93 loc) · 3.04 KB
/
youmoney.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
#!/usr/bin/python
# coding: utf-8
# YouMoney is a opensource personal finance software
# License: GPL
# Author: zhaoweiakid <zhaoweikid@163.com>
# 感谢 Jacky MA <jackyma1981@gmail.com> 制作的日文支持
import os, sys
import threading, urllib, urllib2
import wx
ver = int('%d%02d%02d' % wx.VERSION[:3])
if ver < 20809:
print 'wxPython version must >= 2.8.9, current:', '.'.join([ str(k) for k in wx.VERSION[:3]])
sys.exit()
import ui
import traceback
home = os.path.dirname(os.path.abspath(sys.argv[0]))
cf = ui.config.Configure()
langdir = os.path.join(home, "lang")
try:
ui.i18n.install(langdir, [cf['lang']])
except:
traceback.print_exc()
ui.i18n.install(langdir, ['en_US'])
cf['lang'] = 'en_US'
cf.dump()
import version
from ui import window, logfile, update, task, loader
class YouMoneySplashScreen (wx.SplashScreen):
def __init__(self, parent):
global home
self.parent = parent
bmp = loader.load_bitmap(os.path.join(home, 'images', 'splash.png'))
wx.SplashScreen.__init__(self, bmp, wx.SPLASH_CENTER_ON_SCREEN|wx.SPLASH_TIMEOUT, 5000, None, -1)
self.fc = wx.FutureCall(100, self.ShowMain)
def OnClose(self, event):
event.Skip()
self.Hide()
if self.fc.IsRunning():
self.fc.Stop()
self.ShowMain()
def ShowMain(self):
global cf
self.frame = window.MainFrame(None, 101, 'YouMoney ' + version.VERSION, cf)
self.frame.CenterOnScreen()
self.parent.SetTopWindow(self.frame)
self.frame.Show(True)
class YouMoney (wx.App):
def __init__(self):
wx.App.__init__(self, 0)
def OnInit(self):
global cf
self.frame = window.MainFrame(None, 101, 'YouMoney ' + version.VERSION, cf)
self.frame.CenterOnScreen()
self.SetTopWindow(self.frame)
self.frame.Show(True)
self.Bind(wx.EVT_ACTIVATE_APP, self.OnActivate)
return True
def OnInit2(self):
splash = YouMoneySplashScreen(self)
#self.frame = splash.frame
splash.Show()
return True
def OnActivate(self, event):
if event.GetActive():
pass
event.Skip()
def main():
if sys.platform.startswith('win32'):
filename = os.path.join(home, "youmoney.log")
vername = os.path.join(home, "version.dat")
reportfile = os.path.join(home, "youmoney.report.txt")
else:
filename = os.path.join(os.environ['HOME'], ".youmoney", "youmoney.log")
vername = os.path.join(os.environ['HOME'], ".youmoney", "verion.dat")
reportfile = os.path.join(os.environ['HOME'], "youmoney.report.txt")
#logfile.install(filename)
logfile.install('stdout')
f = open(vername, 'w')
f.write(version.VERSION)
f.close()
th = task.Task()
th.start()
try:
app = YouMoney()
app.MainLoop()
except:
s = traceback.format_exc()
f = open(reportfile, 'a+')
f.write(s)
f.close()
raise
if __name__ == '__main__':
main()