├── __init__.py
├── requirements.txt
├── fintrack.app
└── Contents
│ ├── PkgInfo
│ ├── MacOS
│ ├── python
│ └── fintrack
│ ├── Resources
│ ├── PythonApplet.icns
│ ├── __error__.sh
│ ├── __boot__.py
│ └── site.py
│ ├── Info.plist
│ └── _CodeSignature
│ └── CodeResources
├── logo.png
├── logo.icns
├── data
├── credit_scores.csv
├── budget.csv
├── assets_debts.csv
├── accounts.csv
├── metrics.csv
└── stocks.csv
├── functions
├── funcs.py
└── cjs.py
├── .vscode
└── settings.json
├── setup.py
├── fintrack.py
├── gui
├── toolbar.py
├── widgets
│ ├── logindialog.py
│ ├── creditscoresupdatedialog.py
│ ├── stocklist.py
│ ├── financials.py
│ └── dashboard.py
├── mainwindow.py
└── menubar.py
├── README.md
├── model
└── stocklist.py
├── settings.py
├── .gitignore
└── LICENSE
/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/requirements.txt:
--------------------------------------------------------------------------------
1 | wxpython
2 |
--------------------------------------------------------------------------------
/fintrack.app/Contents/PkgInfo:
--------------------------------------------------------------------------------
1 | APPL????
--------------------------------------------------------------------------------
/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wenbinwu85/personal-finance-tracker/HEAD/logo.png
--------------------------------------------------------------------------------
/logo.icns:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wenbinwu85/personal-finance-tracker/HEAD/logo.icns
--------------------------------------------------------------------------------
/data/credit_scores.csv:
--------------------------------------------------------------------------------
1 | Equifax,812
2 | Transunion,812
3 | Experian,812
4 | Average,710
5 |
--------------------------------------------------------------------------------
/fintrack.app/Contents/MacOS/python:
--------------------------------------------------------------------------------
1 | /Library/Frameworks/Python.framework/Versions/3.10/bin/python3
--------------------------------------------------------------------------------
/fintrack.app/Contents/MacOS/fintrack:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wenbinwu85/personal-finance-tracker/HEAD/fintrack.app/Contents/MacOS/fintrack
--------------------------------------------------------------------------------
/fintrack.app/Contents/Resources/PythonApplet.icns:
--------------------------------------------------------------------------------
1 | /Library/Frameworks/Python.framework/Versions/3.10/Resources/Python.app/Contents/Resources/PythonApplet.icns
--------------------------------------------------------------------------------
/functions/funcs.py:
--------------------------------------------------------------------------------
1 | import logging
2 | from .cjs import CJS
3 |
4 | logger = logging.getLogger('ahben')
5 | logger.setLevel('DEBUG')
6 |
7 | def load_data_from(file):
8 | """"""
9 | return CJS().load(file)
10 |
11 |
12 | def dump_data(data, file):
13 | """"""
14 | CJS().dump(data, file)
15 |
--------------------------------------------------------------------------------
/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "python.testing.pytestArgs": [
3 | "."
4 | ],
5 | "python.testing.unittestEnabled": false,
6 | "python.testing.nosetestsEnabled": false,
7 | "python.testing.pytestEnabled": false,
8 | "python.pythonPath": "/usr/bin/python3",
9 | "python.testing.promptToConfigure": false
10 | }
--------------------------------------------------------------------------------
/setup.py:
--------------------------------------------------------------------------------
1 | """
2 | This is a setup.py script generated by py2applet
3 |
4 | Usage:
5 | python setup.py py2app
6 | """
7 |
8 | from setuptools import setup
9 |
10 | APP = ['fintrack.py']
11 | DATA_FILES = []
12 | OPTIONS = {}
13 |
14 | setup(
15 | app=APP,
16 | data_files=DATA_FILES,
17 | options={'py2app': OPTIONS},
18 | setup_requires=['py2app'],
19 | )
20 |
--------------------------------------------------------------------------------
/data/budget.csv:
--------------------------------------------------------------------------------
1 | Verizon FIOS,$79.99,Monthly,1st,Expense,checking
2 | Apple Music,$9.99,Monthly,15th,Expense,Apple Card
3 | Amazon Prime,$9.90,Monthly,Feburary,Expense,Amazon Card
4 | AWS,$99.00,Monthly,,Expense,Amazon Card
5 | Mattress,$123.00,2021,2022,Need,Apple Card
6 | Air Purifier,$50.00,2021,,Need,Apple Card
7 | Tesla Model 3,$54321,2021,2025,Want,Apple Card
8 | Diablo 4,?,???,2023,Want,Apple Card
9 | TV,$999.00,2021,2022,Want,Apple Card
10 |
--------------------------------------------------------------------------------
/data/assets_debts.csv:
--------------------------------------------------------------------------------
1 | Apple Card,-234,Debt,Pay first
2 | Chase Card,-321,Debt,pay after apple card
3 | Cash,99.00,Cash,
4 | Brokage Cash,555.00,Cash,
5 | Citibank Checking,1234,Cash,
6 | Webull cash,123,Cash,
7 | Citibank Savings,234,Cash,
8 | iPhone,999.00,Assets,
9 | Nintendo Switch,299.00,Assets,
10 | Apple Watch,350.00,Assets,
11 | Kindle,99.00,Assets,
12 | Home,12345,Assets,
13 | Nio,1234.00,Assets,
14 | Tesla,2345.00,Assets,
15 | Beach Home,6543,Assets,
16 |
--------------------------------------------------------------------------------
/data/accounts.csv:
--------------------------------------------------------------------------------
1 | Chase Savings,Savings,Active
2 | Citibank Checking,Checking,Active
3 | USAA Signature,Credit Card,Active
4 | USAA Rate Advantage,Credit Card,Active
5 | Apple Card,Credit Card,Active
6 | Amazon Card,Credit Card,Active
7 | Schwab Brokerage,Investment,Active
8 | Webull,Investment,Active
9 | Coinbase,Investment,Not Used
10 | Schwab Roth IRA,Retirement,Inactive
11 | TSP,Retirement,Active
12 | Transferwise,Debit,Active
13 | Macy's Card,Credit Card,Active
14 |
--------------------------------------------------------------------------------
/fintrack.app/Contents/Resources/__error__.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # This is the default apptemplate error script
4 | #
5 |
6 | echo "Launch error"
7 | if [ -n "$2" ]; then
8 | echo "An unexpected error has occurred during execution of the main script"
9 | echo ""
10 | echo "$2: $3"
11 | echo ""
12 | fi
13 |
14 | echo "See the py2app website for debugging launch issues"
15 | echo ""
16 | echo "ERRORURL: https://py2app.readthedocs.io/en/latest/debugging.html"
17 | exit
18 |
19 |
20 |
--------------------------------------------------------------------------------
/fintrack.py:
--------------------------------------------------------------------------------
1 | #! /usr/bin/python3
2 |
3 | import wx
4 | from gui.mainwindow import MainWindow
5 |
6 |
7 | class FinTrack(wx.App):
8 | """Main app class"""
9 |
10 | def OnInit(self):
11 | self.frame = MainWindow()
12 |
13 | self.frame.ShowWithEffect(True)
14 | self.SetTopWindow(self.frame)
15 | return True
16 |
17 | def OnExit(self):
18 | return super().OnExit()
19 |
20 |
21 | if __name__ == '__main__':
22 | app = FinTrack(False)
23 | app.MainLoop()
24 |
--------------------------------------------------------------------------------
/gui/toolbar.py:
--------------------------------------------------------------------------------
1 | import wx
2 |
3 |
4 | class MyToolbar(wx.ToolBar):
5 | def __init__(self, frame, *args, **kwargs):
6 | super().__init__(frame, *args, **kwargs)
7 | self.frame = frame
8 |
9 | self.search_field = wx.SearchCtrl(
10 | self, size=(300, -1), value='', style=wx.TE_PROCESS_ENTER
11 | )
12 | self.search_field.ShowCancelButton(True)
13 | self.search_field.ShowSearchButton(True)
14 | self.search_field.Bind(wx.EVT_TEXT, self.search)
15 |
16 | self.AddControl(self.search_field) # by pos: 0
17 | # self.SetToolBitmapSize((32, 32))
18 |
19 | def search(self, event):
20 | """"""
21 |
22 | filter = self.search_field.GetValue()
23 | self.frame.SetStatusText(f'Search..."{filter}"')
24 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # personal-finance-tracker
2 | This is my personal finance tracker :)
3 | I track my finance with a spreadsheet, and I am trying to turn it into a Python desktop app with a wxPython based GUI.
4 | This is very much work in progress, there are many more features I want to implement.
5 |
6 | Features
7 | - read data from CSV files
8 | - save data to CSV files
9 | - edit data directly on GUI
10 |
11 | v.0.0.9
12 | - updated stocks list tab
13 | - code cleanup
14 |
15 | Screenshots
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/data/metrics.csv:
--------------------------------------------------------------------------------
1 | January,12345.67,12345.67,12345.67,12345.67,12345,123.45,$0.00,123,123,12345,123456
2 | Febuary,23456.78,23456.78,23456.78,23456.78,12345,234.56,$0.00,123,123,12345,234567
3 | March,34567.89,34567.89,34567.89,34567.89,12345,345.67,$0.00,123,123,12345,345678
4 | April,12345.67,12345.67,12345.67,12345.67,12345,123.45,$0.00,123,123,12345,123456
5 | May,23456.78,23456.78,23456.78,23456.78,12345,234.56,$0.00,123,123,12345,234567
6 | June,34567.89,34567.89,34567.89,34567.89,12345,345.67,$0.00,123,123,12345,345678
7 | July,12345.67,12345.67,12345.67,12345.67,12345,123.45,$0.00,123,123,12345,123456
8 | August,23456.78,23456.78,23456.78,23456.78,12345,234.56,$0.00,123,123,12345,234567
9 | September,34567.89,34567.89,34567.89,34567.89,12345,345.67,$0.00,123,123,12345,345678
10 | October,12345.67,12345.67,12345.67,12345.67,12345,123.45,$0.00,123,123,12345,123456
11 | November,23456.78,23456.78,23456.78,23456.78,12345,234.56,$0.00,123,123,12345,234567
12 | December,1234,23456,34567.89,1234,2345,345.67,$0.00,14356.0,-555.0,112863.56,112308.56
13 |
--------------------------------------------------------------------------------
/model/stocklist.py:
--------------------------------------------------------------------------------
1 | import wx.dataview as dv
2 |
3 |
4 | class DVIListModel(dv.DataViewIndexListModel):
5 | def __init__(self, data):
6 | dv.DataViewIndexListModel.__init__(self, len(data))
7 | self.data = data
8 |
9 | def add_row(self, value):
10 | self.data.append(value)
11 | self.RowAppended()
12 |
13 | def delete_rows(self, rows):
14 | rows = sorted(rows, reverse=True)
15 |
16 | for row in rows:
17 | del self.data[row]
18 | self.RowDeleted(row)
19 |
20 | def GetColumnType(self, col):
21 | return 'string'
22 |
23 | def GetValueByRow(self, row, col):
24 | return self.data[row][col]
25 |
26 | def SetValueByRow(self, value, row, col):
27 | self.data[row][col] = value
28 | return True
29 |
30 | def GetRowData(self, row):
31 | return self.data[row]
32 |
33 | def GetColumnCount(self):
34 | try:
35 | return len(self.data[0])
36 | except IndexError:
37 | return 1
38 |
39 | def GetRowCount(self):
40 | return len(self.data)
41 |
42 | def Compare(self, item1, item2, col, ascending):
43 | if not ascending: # swap sort order?
44 | item2, item1 = item1, item2
45 | row1 = self.GetRow(item1)
46 | row2 = self.GetRow(item2)
47 | a = self.data[row1][col]
48 | b = self.data[row2][col]
49 | if col == 0:
50 | a = int(a)
51 | b = int(b)
52 | if a < b: return -1
53 | if a > b: return 1
54 | return 0
55 |
--------------------------------------------------------------------------------
/gui/widgets/logindialog.py:
--------------------------------------------------------------------------------
1 | import wx
2 |
3 |
4 | class LoginDialog(wx.Dialog):
5 | def __init__(self, *args, **kw):
6 | super().__init__(
7 | style=wx.DEFAULT_FRAME_STYLE & ~(wx.RESIZE_BORDER | wx.MAXIMIZE_BOX | wx.MINIMIZE_BOX),
8 | *args,
9 | **kw
10 | )
11 |
12 | # ----- username -----
13 | username_sizer = wx.BoxSizer(wx.HORIZONTAL)
14 | username_label = wx.StaticText(self, -1, label='Username:')
15 | self.username_field = wx.TextCtrl(self)
16 | username_sizer.Add(username_label, 0, wx.ALL | wx.CENTER, 5)
17 | username_sizer.Add(self.username_field, 0, wx.ALL, 5)
18 |
19 | # ----- password -----
20 | password_sizer = wx.BoxSizer(wx.HORIZONTAL)
21 | password_label = wx.StaticText(self, -1, label='Password:')
22 | self.password_field = wx.TextCtrl(self, style=wx.TE_PASSWORD)
23 | password_sizer.Add(password_label, 0, wx.ALL | wx.CENTER, 5)
24 | password_sizer.Add(self.password_field, 0, wx.ALL, 5)
25 |
26 | # ----- buttons -----
27 | button_sizer = wx.StdDialogButtonSizer()
28 | login_button = wx.Button(self, wx.ID_OK, label='Login')
29 | login_button.SetDefault()
30 | cancel_button = wx.Button(self, wx.ID_CANCEL)
31 | button_sizer.AddButton(login_button)
32 | button_sizer.AddButton(cancel_button)
33 | button_sizer.Realize()
34 |
35 | # ----- main container -----
36 | main_sizer = wx.BoxSizer(wx.VERTICAL)
37 | main_sizer.Add(username_sizer, 0, wx.ALL | wx.CENTER, 5)
38 | main_sizer.Add(password_sizer, 0, wx.ALL | wx.CENTER, 5)
39 | main_sizer.Add(button_sizer, 0, wx.ALL | wx.CENTER, 5)
40 |
41 | self.SetSizerAndFit(main_sizer)
42 | self.CenterOnParent()
43 | self.ShowWithEffect(True)
44 |
--------------------------------------------------------------------------------
/gui/widgets/creditscoresupdatedialog.py:
--------------------------------------------------------------------------------
1 | import wx
2 |
3 |
4 | def make_credit_score_widget(parent, label):
5 | sizer = wx.BoxSizer(wx.HORIZONTAL)
6 | cs_label = wx.StaticText(parent, -1, label=label)
7 | text_field = wx.TextCtrl(parent, size=(100, -1))
8 | sizer.Add(cs_label, 0, wx.ALL, 5)
9 | sizer.Add(text_field, 1, wx.ALL, 5)
10 | return sizer, text_field
11 |
12 |
13 | class CreditScoresUpdateDialog(wx.Dialog):
14 | def __init__(self, *args, **kwargs):
15 | super().__init__(
16 | style=wx.DEFAULT_FRAME_STYLE & ~(wx.RESIZE_BORDER | wx.MAXIMIZE_BOX | wx.MINIMIZE_BOX),
17 | *args,
18 | **kwargs
19 | )
20 |
21 | equifax_sizer, self.equifax_field = make_credit_score_widget(self, 'Equifax:')
22 | transunion_sizer, self.transunion_field = make_credit_score_widget(self, 'Transunion:')
23 | experian_sizer, self.experian_field = make_credit_score_widget(self, 'Experian:')
24 | avg_sizer, self.avg_field = make_credit_score_widget(self, 'Average:')
25 |
26 | # ----- buttons -----
27 | button_sizer = wx.StdDialogButtonSizer()
28 | login_button = wx.Button(self, wx.ID_OK, label='Update')
29 | login_button.SetDefault()
30 | cancel_button = wx.Button(self, wx.ID_CANCEL)
31 | button_sizer.AddButton(login_button)
32 | button_sizer.AddButton(cancel_button)
33 | button_sizer.Realize()
34 |
35 | # ----- main container -----
36 | main_sizer = wx.BoxSizer(wx.VERTICAL)
37 | main_sizer.Add(equifax_sizer, 0, wx.ALL | wx.ALIGN_RIGHT, 5)
38 | main_sizer.Add(transunion_sizer, 0, wx.ALL | wx.ALIGN_RIGHT, 5)
39 | main_sizer.Add(experian_sizer, 0, wx.ALL | wx.ALIGN_RIGHT, 5)
40 | main_sizer.Add(avg_sizer, 0, wx.ALL | wx.ALIGN_RIGHT, 5)
41 | main_sizer.Add(button_sizer, 0, wx.ALL | wx.ALIGN_RIGHT, 5)
42 |
43 | self.SetSizerAndFit(main_sizer)
44 | self.CenterOnParent()
45 | self.ShowWithEffect(True)
46 |
--------------------------------------------------------------------------------
/settings.py:
--------------------------------------------------------------------------------
1 | import os
2 | from re import A
3 |
4 | APP_NAME = "FinanceTracker"
5 | VERSION = 'v0.0.10'
6 | EMAIL = 'Email: ahbenebha@gmail.com'
7 | DEVELOPER = 'Wenbin Wu'
8 | WEBSITE = 'https://github.com/wenbinwu85/', 'Github'
9 | LICENSE = ''
10 | COPYRIGHT = f'\t(c) 2021 {DEVELOPER}\t'
11 |
12 | ADMIN_ACCOUNT = ('ahben', 'ahben') # hardcoded admin account
13 |
14 | STATUS_BAR_MESSAGE = f'{APP_NAME} {VERSION}'
15 |
16 | APP_DIR = os.path.abspath(os.path.dirname(__file__))
17 | DATA_PATH = os.path.join(APP_DIR, 'data')
18 | METRICS_DATA_PATH = os.path.join(DATA_PATH, 'metrics.csv')
19 | ASSETS_DEBTS_DATA_PATH = os.path.join(DATA_PATH, 'assets_debts.csv')
20 | BUDGET_PLAN_DATA_PATH = os.path.join(DATA_PATH, 'budget.csv')
21 | ACCOUNTS_DATA_PATH = os.path.join(DATA_PATH, 'accounts.csv')
22 | STOCKLIST_DATA_PATH = os.path.join(DATA_PATH, 'stocks.csv')
23 | CREDIT_SCORES_DATA_PATH = os.path.join(DATA_PATH, 'credit_scores.csv')
24 |
25 | net_worth_labels = ['Total Debts', 'Total Assets', 'Net Worth', 'D/A Ratio %']
26 | passive_income_labels = [
27 | 'Annual Yield %', 'Annual Yield', 'Monthly Yield', 'Total Dividend Earned'
28 | ]
29 | metrics_columns = [
30 | 'Month', 'TSP', 'Schwab', 'Roth IRA', 'Webull', 'Coinbase',
31 | 'Dividend', 'Invested', 'Cash', 'Debts', 'Assets', 'Net Worth'
32 | ]
33 |
34 | assets_debts_columns = ['Item', 'Value', 'Type', 'Note']
35 | budget_plan_columns = ['Item', 'Amount', 'Time', 'Due Date', 'Type', 'Payback Plan']
36 | accounts_columns = ['Account', 'Type', 'Status']
37 |
38 | stocks_columns = [
39 | 'Symbol', 'Shares', 'Cost Avg',
40 | 'Price', 'Cost Basis', 'Market Value', 'Gain / Lost', 'G / L %',
41 | 'Yield %', 'Annual Div', 'Div. Earned',
42 | 'Y / C %', 'Beta', 'P/E', 'EPS', '1Y Target',
43 | 'Payout %', '1Y Div ^', '3Y Div ^', '5Y Div ^',
44 | 'Sector', 'Account'
45 | ]
46 |
47 | stocks_footer_columns = [
48 | 'Selected', 'Cost Basis', 'Market Value', 'Gain / Lost', 'Gain / Lost %',
49 | 'Yield %', 'Annual Dividend', 'Div. Received', 'Account %'
50 | ]
51 |
--------------------------------------------------------------------------------
/data/stocks.csv:
--------------------------------------------------------------------------------
1 | AAPL,12,123.83,121.77,1485.96,1461.24,807,82.24%,0,120,45.75,10.32%,2.49,6.83,3.71,126.13,136.84%,1.97%,2.01%,2.05%,Tech,Stonks
2 | T,23,123.45,36.07,2839.35,829.61,1871.44,54.84%,0,0,130,9.12%,1.55,29.05,-0.27,50.67,108.64%,,,,Comms,Stonks
3 | DIS,34,321.88,9.3,10943.92,316.2,475.24,71.51%,3.99%,78,189,5.97%,0.79,32.57,-3.52,17.66,260.49%,1.94%,2.15%,3.12%,Comms,Stonks
4 | ENB,45,76.54,72.22,3444.3,3249.9,1130.7,114.32%,0.74%,0,0,0.00%,1.2,297.21,-0.31,31.18,0%,,,,Energy,Stonks
5 | ET,56,12.34,4.55,691.04,254.8,658.9,65.10%,3.45%,141.5,0,0.00%,2.54,0,4.63,148.88,88.44%,5.56%,5.90%,6.30%,Energy,Stonks
6 | BEN,67,34.56,42.5,2315.52,2847.5,384.76,42.96%,0,260,0,0.00%,1.08,0,2.38,41.66,69.87%,3.82%,9.51%,11.59%,Financial,Stonks
7 | ABBV,78,65.43,61.68,5103.54,4811.04,4.55,0.00%,0,0,128.6,1.28%,1.2,29.72,-0.49,64.88,0%,,,,Healthcare,Stonks
8 | PFE,89,123.45,32.44,10987.05,2887.16,13.18,33.90%,6.56%,42.8,200.88,8.90%,0.95,16.54,0.99,77.94,177.29%,10.29%,22.63%,18.51%,Healthcare,Stonks
9 | O,90,34.356,8.22,3092.04,739.8,560,33.20%,0,0,0,0.00%,4.78,0,-2.59,121.78,0%,,,,Reit,Stonks
10 | SPG,12,4.56,301.88,54.72,3622.56,415.1,123.39%,0,72,65.7,1.34%,0.78,37.5,0.86,38.23,31.65%,10.59%,9.55%,10.14%,Reit,Stonks
11 | STOR,23,23.45,39.31,539.35,904.13,458.5,0.00%,0,228.8,36,5.21%,1.24,42.14,1.36,13.82,215.23%,9.12%,9.38%,10.53%,Reit,Stonks
12 | FRT,34,43.2,105.41,1468.8,3583.94,8457.43,37.68%,0,33.6,93.84,4.58%,0.74,72.88,5.11,166.23,243.91%,3.10%,3.36%,4.22%,Reit,Stonks
13 | DOCN,45,45.67,181.3,2055.15,8158.5,2454.43,0.00%,4.31%,0,0,0.00%,4.49,0,2.42,32.65,175.96%,,,,Tech,Roth
14 | DIDI,56,9.87,40.59,552.72,2273.04,4109.73,38.44%,3.53%,0.04,69.4,4.55%,0.67,19.67,8.05,330.41,54.74%,6.25%,9.51%,9.74%,Tech,Roth
15 | NIO,67,123.45,120.78,8271.15,8092.26,-1310.99,39.84%,6.79%,61,0,0.00%,0,0,-1.89,6.35,,,,,EV,Roth
16 | XPEV,78,45.67,134.45,3562.26,10487.1,13.72,806.03%,3.39%,0,21.2,5.60%,1.17,61.72,0.61,210.34,,,,,EV,Roth
17 | MARA,89,32.1,27.42,2856.9,2440.38,612.84,-1.76%,4.50%,0,22.4,5.79%,1.25,13.41,-1.08,346.78,,,,,Crypto,Roth
18 | AR,90,176.5,46.07,15885,4146.3,1503.66,62.23%,3.91%,0,0,0.00%,1.45,0,-0.88,389.16,,,,,Free,Webull
19 | GE,12,8.76,13.72,105.12,164.64,361.1,19.82%,7.64%,267,182,7.03%,0.75,0,1.97,126.06,,,,,Free,Webull
20 | SWN,23,123.45,151.83,2839.35,3492.09,655.35,-34.71%,0.30%,67.2,0,0.00%,0,0,2.34,45.86,,,,,Free,Webull
21 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 |
3 | # Byte-compiled / optimized / DLL files
4 | __pycache__/
5 | *.py[cod]
6 | *$py.class
7 |
8 | # C extensions
9 | *.so
10 |
11 | # Distribution / packaging
12 | .Python
13 | build/
14 | develop-eggs/
15 | dist/
16 | downloads/
17 | eggs/
18 | .eggs/
19 | lib/
20 | lib64/
21 | parts/
22 | sdist/
23 | var/
24 | wheels/
25 | pip-wheel-metadata/
26 | share/python-wheels/
27 | *.egg-info/
28 | .installed.cfg
29 | *.egg
30 | MANIFEST
31 |
32 | # PyInstaller
33 | # Usually these files are written by a python script from a template
34 | # before PyInstaller builds the exe, so as to inject date/other infos into it.
35 | *.manifest
36 | *.spec
37 |
38 | # Installer logs
39 | pip-log.txt
40 | pip-delete-this-directory.txt
41 |
42 | # Unit test / coverage reports
43 | htmlcov/
44 | .tox/
45 | .nox/
46 | .coverage
47 | .coverage.*
48 | .cache
49 | nosetests.xml
50 | coverage.xml
51 | *.cover
52 | *.py,cover
53 | .hypothesis/
54 | .pytest_cache/
55 |
56 | # Translations
57 | *.mo
58 | *.pot
59 |
60 | # Django stuff:
61 | *.log
62 | local_settings.py
63 | db.sqlite3
64 | db.sqlite3-journal
65 |
66 | # Flask stuff:
67 | instance/
68 | .webassets-cache
69 |
70 | # Scrapy stuff:
71 | .scrapy
72 |
73 | # Sphinx documentation
74 | docs/_build/
75 |
76 | # PyBuilder
77 | target/
78 |
79 | # Jupyter Notebook
80 | .ipynb_checkpoints
81 |
82 | # IPython
83 | profile_default/
84 | ipython_config.py
85 |
86 | # pyenv
87 | .python-version
88 |
89 | # pipenv
90 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
91 | # However, in case of collaboration, if having platform-specific dependencies or dependencies
92 | # having no cross-platform support, pipenv may install dependencies that don't work, or not
93 | # install all needed dependencies.
94 | #Pipfile.lock
95 |
96 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow
97 | __pypackages__/
98 |
99 | # Celery stuff
100 | celerybeat-schedule
101 | celerybeat.pid
102 |
103 | # SageMath parsed files
104 | *.sage.py
105 |
106 | # Environments
107 | .env
108 | .venv
109 | env/
110 | venv/
111 | ENV/
112 | env.bak/
113 | venv.bak/
114 |
115 | # Spyder project settings
116 | .spyderproject
117 | .spyproject
118 |
119 | # Rope project settings
120 | .ropeproject
121 |
122 | # mkdocs documentation
123 | /site
124 |
125 | # mypy
126 | .mypy_cache/
127 | .dmypy.json
128 | dmypy.json
129 |
130 | # Pyre type checker
131 | .pyre/
132 |
--------------------------------------------------------------------------------
/gui/mainwindow.py:
--------------------------------------------------------------------------------
1 | import wx
2 | import wx.aui as aui # import wx.lib.agw.aui as aui
3 | import wx.dataview as dv
4 | from settings import APP_NAME, STATUS_BAR_MESSAGE
5 | from gui.menubar import MyMenuBar
6 | from gui.toolbar import MyToolbar
7 | from gui.widgets.dashboard import Dashboard
8 | from gui.widgets.financials import Financials
9 | from gui.widgets.stocklist import StockList
10 |
11 |
12 | class MainWindow(wx.Frame):
13 | """Main window GUI"""
14 |
15 | def __init__(self):
16 | super().__init__(
17 | parent=None,
18 | title=APP_NAME,
19 | style=wx.DEFAULT_FRAME_STYLE & ~(wx.RESIZE_BORDER | wx.MAXIMIZE_BOX)
20 | )
21 | self.panel = wx.Panel(self)
22 |
23 | # icon = wx.Icon('logo.png', wx.BITMAP_TYPE_ANY)
24 | # self.SetIcon(icon)
25 |
26 | self.toolbar = MyToolbar(
27 | self, style=wx.TB_HORIZONTAL | wx.NO_BORDER | wx.TB_FLAT
28 | )
29 | self.SetToolBar(self.toolbar)
30 | self.toolbar.Realize()
31 |
32 | self.SetMenuBar(MyMenuBar(self))
33 |
34 | self.CreateStatusBar()
35 | self.statusbar = self.GetStatusBar()
36 | self.statusbar.SetFieldsCount(3)
37 | self.statusbar.SetStatusWidths([-2, 150, 140])
38 | self.SetStatusText(STATUS_BAR_MESSAGE, 2)
39 |
40 | self.tabs = aui.AuiNotebook(
41 | self.panel, wx.ID_ANY, style=aui.AUI_NB_WINDOWLIST_BUTTON | aui.AUI_NB_TAB_MOVE
42 | )
43 | self.dashboard = Dashboard('Dashboard', self.tabs)
44 | self.financials = Financials('Financials', self.tabs)
45 | self.stocklist = StockList('Stocks', self.tabs)
46 | self.tabs.AddPage(self.dashboard, self.dashboard.name)
47 | self.tabs.AddPage(self.financials, self.financials.name)
48 | self.tabs.AddPage(self.stocklist, self.stocklist.name)
49 | self.Bind(aui.EVT_AUINOTEBOOK_PAGE_CHANGED, self.tab_change, self.tabs)
50 |
51 | main_sizer = wx.BoxSizer(wx.VERTICAL)
52 | main_sizer.Add(self.tabs)
53 |
54 | self.panel.SetSizerAndFit(main_sizer)
55 | self.SetClientSize(self.dashboard.GetBestSize())
56 | self.CenterOnScreen()
57 |
58 | def tab_change(self, event):
59 | """Resizes the main window frame to fit notbook page content"""
60 |
61 | tab = self.tabs.GetCurrentPage()
62 | if tab == self.dashboard:
63 | self.dashboard.update_metrics_net_worth()
64 | self.dashboard.update_passive_income()
65 | self.dashboard.update_pie_chart(dv.EVT_DATAVIEW_SELECTION_CHANGED)
66 | self.SetClientSize(tab.GetMinSize())
67 | self.SendSizeEvent()
68 | self.CenterOnScreen()
69 |
--------------------------------------------------------------------------------
/fintrack.app/Contents/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | English
7 | CFBundleDisplayName
8 | fintrack
9 | CFBundleExecutable
10 | fintrack
11 | CFBundleIconFile
12 | PythonApplet.icns
13 | CFBundleIdentifier
14 | org.pythonmac.unspecified.fintrack
15 | CFBundleInfoDictionaryVersion
16 | 6.0
17 | CFBundleName
18 | fintrack
19 | CFBundlePackageType
20 | APPL
21 | CFBundleShortVersionString
22 | 0.0.0
23 | CFBundleSignature
24 | ????
25 | CFBundleVersion
26 | 0.0.0
27 | LSHasLocalizedDisplayName
28 |
29 | NSAppleScriptEnabled
30 |
31 | NSHumanReadableCopyright
32 | Copyright not specified
33 | NSMainNibFile
34 | MainMenu
35 | NSPrincipalClass
36 | NSApplication
37 | PyMainFileNames
38 |
39 | __boot__
40 |
41 | PyOptions
42 |
43 | alias
44 |
45 | argv_emulation
46 |
47 | emulate_shell_environment
48 |
49 | no_chdir
50 |
51 | prefer_ppc
52 |
53 | site_packages
54 |
55 | use_faulthandler
56 |
57 | use_pythonpath
58 |
59 | verbose
60 |
61 |
62 | PyResourcePackages
63 |
64 | PyRuntimeLocations
65 |
66 | @executable_path/../Frameworks/Python.framework/Versions/3.10/Python
67 | /Library/Frameworks/Python.framework/Versions/3.10/Python
68 |
69 | PythonInfoDict
70 |
71 | PythonExecutable
72 | /Library/Frameworks/Python.framework/Versions/3.10/bin/python3
73 | PythonLongVersion
74 | 3.10.4 (v3.10.4:9d38120e33, Mar 23 2022, 17:29:05) [Clang 13.0.0 (clang-1300.0.29.30)]
75 | PythonShortVersion
76 | 3.1
77 | py2app
78 |
79 | alias
80 |
81 | template
82 | app
83 | version
84 | 0.28.2
85 |
86 |
87 |
88 |
89 |
--------------------------------------------------------------------------------
/gui/menubar.py:
--------------------------------------------------------------------------------
1 | import wx
2 | import wx.adv
3 | import wx.lib.inspection
4 | from settings import APP_NAME, VERSION, EMAIL, DEVELOPER
5 | from settings import COPYRIGHT, LICENSE, WEBSITE
6 |
7 |
8 | class MyMenuBar(wx.MenuBar):
9 | """Menubar"""
10 |
11 | def __init__(self, frame):
12 | super().__init__()
13 | self.frame = frame
14 |
15 | file_menu = wx.Menu()
16 | # file_menu.Append(102, '&Login', 'User login')
17 | # file_menu.AppendSeparator()
18 | file_menu.Append(wx.ID_EXIT, '&Quit', f'Quit {APP_NAME}')
19 |
20 | view_menu = wx.Menu()
21 | self.sb_toggle = view_menu.Append(
22 | wx.ID_ANY, 'Show Statusbar', 'Show Statusbar', kind=wx.ITEM_CHECK
23 | )
24 | self.tb_toggle = view_menu.Append(
25 | wx.ID_ANY, 'Show Toolbar', 'Show Toolbar', kind=wx.ITEM_CHECK
26 | )
27 | # check both items on application start
28 | view_menu.Check(self.sb_toggle.GetId(), True)
29 | view_menu.Check(self.tb_toggle.GetId(), True)
30 |
31 | window_menu = wx.Menu()
32 | help_menu = wx.Menu()
33 | inspector = help_menu.Append(901, 'Widget Inspector', 'Widget Inspector')
34 | about = help_menu.Append(wx.ID_ABOUT)
35 |
36 | # self.Bind(wx.EVT_MENU, self.login, id=102)
37 | self.Bind(wx.EVT_MENU, self.quit, id=wx.ID_EXIT)
38 | self.Bind(wx.EVT_MENU, self.about_dialog, about)
39 | self.Bind(wx.EVT_MENU, self.statusbar_toggle, self.sb_toggle)
40 | self.Bind(wx.EVT_MENU, self.toolbar_toggle, self.tb_toggle)
41 | self.Bind(wx.EVT_MENU, self.widget_inspector, inspector)
42 |
43 | self.Append(file_menu, 'File')
44 | self.Append(view_menu, 'View')
45 | self.Append(window_menu, 'Window')
46 | self.Append(help_menu, 'Help')
47 |
48 | def about_dialog(self, event):
49 | """About info box"""
50 |
51 | info = wx.adv.AboutDialogInfo()
52 | info.SetName(APP_NAME)
53 | info.SetVersion(VERSION)
54 | info.SetDescription(EMAIL)
55 | info.AddDeveloper(DEVELOPER)
56 | info.SetCopyright(COPYRIGHT)
57 | info.SetLicense(LICENSE)
58 | info.SetWebSite(*WEBSITE)
59 | wx.adv.GenericAboutBox(info)
60 |
61 | # def login(self, event):
62 | # """enbable admin mode"""
63 |
64 | # dialog = LoginDialog(self, title='Admin Login')
65 | # if dialog.ShowModal() == wx.ID_OK:
66 | # username = dialog.username_field.GetValue()
67 | # password = dialog.password_field.GetValue()
68 |
69 | # if (username, password) != ADMIN_ACCOUNT:
70 | # self.frame.SetStatusText('Unable to login. Invalid credentials.')
71 | # return None
72 |
73 | # item = self.FindItemById(102)
74 | # item.SetItemLabel('Logout')
75 | # self.Bind(wx.EVT_MENU, self.logout, id=102)
76 |
77 | # return None
78 |
79 | # def logout(self, event):
80 | # """disable admin mode"""
81 |
82 | # item = self.FindItemById(102)
83 | # item.SetItemLabel('Login')
84 | # self.Bind(wx.EVT_MENU, self.login, id=102)
85 |
86 | # return None
87 |
88 | def statusbar_toggle(self, event):
89 | if self.sb_toggle.IsChecked():
90 | self.frame.statusbar.Show()
91 | else:
92 | self.frame.statusbar.Hide()
93 |
94 | def toolbar_toggle(self, event):
95 | if self.tb_toggle.IsChecked():
96 | self.frame.toolbar.Show()
97 | else:
98 | self.frame.toolbar.Hide()
99 |
100 | def widget_inspector(self, event):
101 | wx.lib.inspection.InspectionTool().Show()
102 |
103 | def quit(self, event):
104 | self.frame.Close()
105 |
--------------------------------------------------------------------------------
/functions/cjs.py:
--------------------------------------------------------------------------------
1 | import csv
2 | import json
3 | import shelve
4 | import re
5 | from functools import singledispatchmethod
6 |
7 |
8 | class CJSException(Exception):
9 | """"""
10 |
11 |
12 | class DataLoadException(CJSException):
13 | """"""
14 |
15 |
16 | class DataDumpException(CJSException):
17 | """"""
18 |
19 |
20 | class CJS:
21 | def __init__(self):
22 | self.filename = ''
23 | self.ext = ''
24 | self.data = None
25 | self.size = 0
26 | self.position = 0
27 |
28 | def __str__(self):
29 | attrs = f'filname={self.filename}, ext={self.ext}, data={type(data)}, size={self.size}'
30 | return f'{self.__class__.__name__}({attrs})'
31 |
32 | def __iter__(self):
33 | return self
34 |
35 | def __next__(self):
36 | if not self.size or self.position >= self.size:
37 | self.position = 0
38 | raise StopIteration
39 |
40 | if isinstance(self.data, dict):
41 | item = list(self.data.items())[self.position]
42 | else:
43 | item = self.data[self.position]
44 | self.position += 1
45 | return item
46 |
47 | def _parse_filename(self, filename):
48 | if filename:
49 | regex = re.match('^(.+)(\.db|\.csv|\.txt|\.json)$', filename)
50 | try:
51 | self.filename, self.ext = regex.groups()
52 | except AttributeError:
53 | raise CJSException(f'Invalid file name: {filename}.')
54 | elif not self.filename:
55 | raise CJSException('File name is not specified.')
56 |
57 | def load(self, filename=None):
58 | self._parse_filename(filename)
59 |
60 | if self.ext == '.db':
61 | with shelve.open(self.filename) as file:
62 | self.data = {key:val for key, val in file.items()}
63 | else:
64 | with open(self.filename+self.ext, encoding='utf-8') as file:
65 | if self.ext == '.csv':
66 | self.data = list(csv.reader(file, delimiter=','))
67 | elif self.ext == '.json':
68 | self.data = json.load(file)
69 | elif self.ext == '.txt':
70 | self.data = [line.strip('\n').split(',') for line in file.readlines()]
71 | else:
72 | msg = f'Unable to load {self.filename+self.ext}.'
73 | raise DataLoadException(msg)
74 |
75 | self.size = len(self.data)
76 | return self.data
77 |
78 | @singledispatchmethod
79 | def dump(self, data, filename):
80 | raise NotImplementedError
81 |
82 | @dump.register(list)
83 | @dump.register(tuple)
84 | @dump.register(set)
85 | def _(self, data=[], filename=None):
86 | self._parse_filename(filename)
87 | self.data = data
88 | self.size = len(self.data)
89 |
90 | with open(self.filename+self.ext, 'w', encoding='utf-8') as file:
91 | if self.ext == '.csv':
92 | writer = csv.writer(file)
93 | writer.writerows(self.data)
94 | elif self.ext == '.txt':
95 | lines = [','.join(i) + '\n' for i in self.data]
96 | file.writelines(lines)
97 | else:
98 | msg = f'Unsupported dump: {type(self.data)} -> {self.filename+self.ext}'
99 | raise DataDumpException(msg)
100 | return None
101 |
102 | @dump.register(dict)
103 | def _(self, data={}, filename=None):
104 | self._parse_filename(filename)
105 | self.data = data
106 | self.size = len(self.data)
107 |
108 | if self.ext == '.json':
109 | with open(self.filename+self.ext, 'w', encoding='utf-8') as file:
110 | json.dump(self.data, file, ensure_ascii=True, indent=4)
111 | elif self.ext == '.db':
112 | with shelve.open(self.filename, writeback=True) as file:
113 | file.update(self.data)
114 | else:
115 | msg = f'Unsupported dump: {type(self.data)} -> {self.filename+self.ext}'
116 | raise DataDumpException(msg)
117 | return None
118 |
--------------------------------------------------------------------------------
/fintrack.app/Contents/Resources/__boot__.py:
--------------------------------------------------------------------------------
1 | def _reset_sys_path():
2 | # Clear generic sys.path[0]
3 | import os
4 | import sys
5 |
6 | resources = os.environ["RESOURCEPATH"]
7 | while sys.path[0] == resources:
8 | del sys.path[0]
9 |
10 |
11 | _reset_sys_path()
12 |
13 |
14 | def _site_packages():
15 | import os
16 | import site
17 | import sys
18 |
19 | paths = []
20 | prefixes = [sys.prefix]
21 | if sys.exec_prefix != sys.prefix:
22 | prefixes.append(sys.exec_prefix)
23 | for prefix in prefixes:
24 | paths.append(
25 | os.path.join(
26 | prefix, "lib", "python%d.%d" % (sys.version_info[:2]), "site-packages"
27 | )
28 | )
29 |
30 | if os.path.join(".framework", "") in os.path.join(sys.prefix, ""):
31 | home = os.environ.get("HOME")
32 | if home:
33 | # Sierra and later
34 | paths.append(
35 | os.path.join(
36 | home,
37 | "Library",
38 | "Python",
39 | "%d.%d" % (sys.version_info[:2]),
40 | "lib",
41 | "python",
42 | "site-packages",
43 | )
44 | )
45 |
46 | # Before Sierra
47 | paths.append(
48 | os.path.join(
49 | home,
50 | "Library",
51 | "Python",
52 | "%d.%d" % (sys.version_info[:2]),
53 | "site-packages",
54 | )
55 | )
56 |
57 | # Work around for a misfeature in setuptools: easy_install.pth places
58 | # site-packages way to early on sys.path and that breaks py2app bundles.
59 | # NOTE: this is hacks into an undocumented feature of setuptools and
60 | # might stop to work without warning.
61 | sys.__egginsert = len(sys.path)
62 |
63 | for path in paths:
64 | site.addsitedir(path)
65 |
66 |
67 | _site_packages()
68 |
69 |
70 | def _chdir_resource():
71 | import os
72 |
73 | os.chdir(os.environ["RESOURCEPATH"])
74 |
75 |
76 | _chdir_resource()
77 |
78 |
79 | def _setup_ctypes():
80 | import os
81 | from ctypes.macholib import dyld
82 |
83 | frameworks = os.path.join(os.environ["RESOURCEPATH"], "..", "Frameworks")
84 | dyld.DEFAULT_FRAMEWORK_FALLBACK.insert(0, frameworks)
85 | dyld.DEFAULT_LIBRARY_FALLBACK.insert(0, frameworks)
86 |
87 |
88 | _setup_ctypes()
89 |
90 |
91 | def _path_inject(paths):
92 | import sys
93 |
94 | sys.path[:0] = paths
95 |
96 |
97 | _path_inject(['/Users/wenbin/Desktop/personal-finance-tracker'])
98 |
99 |
100 | import re
101 | import sys
102 |
103 | cookie_re = re.compile(rb"coding[:=]\s*([-\w.]+)")
104 | if sys.version_info[0] == 2:
105 | default_encoding = "ascii"
106 | else:
107 | default_encoding = "utf-8"
108 |
109 |
110 | def guess_encoding(fp):
111 | for _i in range(2):
112 | ln = fp.readline()
113 |
114 | m = cookie_re.search(ln)
115 | if m is not None:
116 | return m.group(1).decode("ascii")
117 |
118 | return default_encoding
119 |
120 |
121 | def _run():
122 | global __file__
123 | import os
124 | import site # noqa: F401
125 |
126 | sys.frozen = "macosx_app"
127 |
128 | argv0 = os.path.basename(os.environ["ARGVZERO"])
129 | script = SCRIPT_MAP.get(argv0, DEFAULT_SCRIPT) # noqa: F821
130 |
131 | sys.argv[0] = __file__ = script
132 | if sys.version_info[0] == 2:
133 | with open(script, "rU") as fp:
134 | source = fp.read() + "\n"
135 | else:
136 | with open(script, "rb") as fp:
137 | encoding = guess_encoding(fp)
138 |
139 | with open(script, "r", encoding=encoding) as fp:
140 | source = fp.read() + "\n"
141 |
142 | BOM = b"\xef\xbb\xbf".decode("utf-8")
143 |
144 | if source.startswith(BOM):
145 | source = source[1:]
146 |
147 | exec(compile(source, script, "exec"), globals(), globals())
148 |
149 |
150 | DEFAULT_SCRIPT='/Users/wenbin/Desktop/personal-finance-tracker/fintrack.py'
151 | SCRIPT_MAP={}
152 | try:
153 | _run()
154 | except KeyboardInterrupt:
155 | pass
156 |
--------------------------------------------------------------------------------
/fintrack.app/Contents/_CodeSignature/CodeResources:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | files
6 |
7 | Resources/__boot__.py
8 |
9 | Dg0D6OmS92NeeUSoTZSEbLn1KQA=
10 |
11 | Resources/__error__.sh
12 |
13 | jiMXHe2/gGu9p3+O3RpqVGbONRE=
14 |
15 | Resources/__pycache__/site.cpython-310.opt-1.pyc
16 |
17 | 6jwgVAxJh4x6c2uYdCmbmdzxOH8=
18 |
19 | Resources/__pycache__/site.cpython-310.pyc
20 |
21 | A8gS7NDv5iqNhQa0ukPnAw24Jcs=
22 |
23 | Resources/site.py
24 |
25 | hVOAaI28CXHytfoByVdYfNDxy9k=
26 |
27 |
28 | files2
29 |
30 | MacOS/python
31 |
32 | symlink
33 | /Library/Frameworks/Python.framework/Versions/3.10/bin/python3
34 |
35 | Resources/PythonApplet.icns
36 |
37 | symlink
38 | /Library/Frameworks/Python.framework/Versions/3.10/Resources/Python.app/Contents/Resources/PythonApplet.icns
39 |
40 | Resources/__boot__.py
41 |
42 | hash
43 |
44 | Dg0D6OmS92NeeUSoTZSEbLn1KQA=
45 |
46 | hash2
47 |
48 | cT4tB+5bkedg5WCYfbyjVMcbHi35ir8Cc5bShYdpWHQ=
49 |
50 |
51 | Resources/__error__.sh
52 |
53 | hash
54 |
55 | jiMXHe2/gGu9p3+O3RpqVGbONRE=
56 |
57 | hash2
58 |
59 | X92yvDN0TrSkH2FT7nqBEm6WgAZJ9CS2MXV1a7IpE4o=
60 |
61 |
62 | Resources/__pycache__/site.cpython-310.opt-1.pyc
63 |
64 | hash
65 |
66 | 6jwgVAxJh4x6c2uYdCmbmdzxOH8=
67 |
68 | hash2
69 |
70 | 1FzbV5KNjnQ+ZZMdtrGxiZN/ZVs1recLbrz9ajPVN8g=
71 |
72 |
73 | Resources/__pycache__/site.cpython-310.pyc
74 |
75 | hash
76 |
77 | A8gS7NDv5iqNhQa0ukPnAw24Jcs=
78 |
79 | hash2
80 |
81 | hRAwVFDCJ2SnJ6TeYzHCgnGeolMN7AM4Qqq1CxRTJQE=
82 |
83 |
84 | Resources/lib/python3.10/config
85 |
86 | symlink
87 | /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/config
88 |
89 | Resources/lib/python3.10/site.pyc
90 |
91 | symlink
92 | ../../site.pyc
93 |
94 | Resources/site.py
95 |
96 | hash
97 |
98 | hVOAaI28CXHytfoByVdYfNDxy9k=
99 |
100 | hash2
101 |
102 | OJjuwoQlOOy9eI1StcNkpXbaXSFT4KM6Uyhwn22JYHk=
103 |
104 |
105 |
106 | rules
107 |
108 | ^Resources/
109 |
110 | ^Resources/.*\.lproj/
111 |
112 | optional
113 |
114 | weight
115 | 1000
116 |
117 | ^Resources/.*\.lproj/locversion.plist$
118 |
119 | omit
120 |
121 | weight
122 | 1100
123 |
124 | ^Resources/Base\.lproj/
125 |
126 | weight
127 | 1010
128 |
129 | ^version.plist$
130 |
131 |
132 | rules2
133 |
134 | .*\.dSYM($|/)
135 |
136 | weight
137 | 11
138 |
139 | ^(.*/)?\.DS_Store$
140 |
141 | omit
142 |
143 | weight
144 | 2000
145 |
146 | ^(Frameworks|SharedFrameworks|PlugIns|Plug-ins|XPCServices|Helpers|MacOS|Library/(Automator|Spotlight|LoginItems))/
147 |
148 | nested
149 |
150 | weight
151 | 10
152 |
153 | ^.*
154 |
155 | ^Info\.plist$
156 |
157 | omit
158 |
159 | weight
160 | 20
161 |
162 | ^PkgInfo$
163 |
164 | omit
165 |
166 | weight
167 | 20
168 |
169 | ^Resources/
170 |
171 | weight
172 | 20
173 |
174 | ^Resources/.*\.lproj/
175 |
176 | optional
177 |
178 | weight
179 | 1000
180 |
181 | ^Resources/.*\.lproj/locversion.plist$
182 |
183 | omit
184 |
185 | weight
186 | 1100
187 |
188 | ^Resources/Base\.lproj/
189 |
190 | weight
191 | 1010
192 |
193 | ^[^/]+$
194 |
195 | nested
196 |
197 | weight
198 | 10
199 |
200 | ^embedded\.provisionprofile$
201 |
202 | weight
203 | 20
204 |
205 | ^version\.plist$
206 |
207 | weight
208 | 20
209 |
210 |
211 |
212 |
213 |
--------------------------------------------------------------------------------
/gui/widgets/stocklist.py:
--------------------------------------------------------------------------------
1 | import wx
2 | import wx.dataview as dv
3 | from settings import STOCKLIST_DATA_PATH, stocks_columns, stocks_footer_columns
4 | from functions.funcs import load_data_from, dump_data
5 | from model.stocklist import DVIListModel
6 |
7 |
8 | class StockList(wx.Panel):
9 | """"""
10 |
11 | def __init__(self, name, parent, *args, **kwargs):
12 | super().__init__(parent, *args, **kwargs)
13 |
14 | self.parent = parent
15 | self.name = name
16 |
17 | self.stocks_dvc = dv.DataViewCtrl(
18 | self,
19 | size=(1600, 680),
20 | style=wx.BORDER_THEME | dv.DV_ROW_LINES | dv.DV_VERT_RULES | dv.DV_MULTIPLE
21 | )
22 | self.stocks_dvc.Bind(dv.EVT_DATAVIEW_ITEM_CONTEXT_MENU, self.stocks_dvc_context_menu)
23 | self.stocks_dvc.Bind(dv.EVT_DATAVIEW_SELECTION_CHANGED, self.stock_selected)
24 |
25 | self.stocks_dvc_model = DVIListModel(load_data_from(STOCKLIST_DATA_PATH))
26 | self.stocks_dvc.AssociateModel(self.stocks_dvc_model)
27 |
28 | for i in range(3):
29 | self.stocks_dvc.AppendTextColumn(
30 | stocks_columns[i], i, width=wx.COL_WIDTH_AUTOSIZE, mode=dv.DATAVIEW_CELL_EDITABLE
31 | )
32 | for idx, val in enumerate(stocks_columns[3:-2]):
33 | self.stocks_dvc.AppendTextColumn(val, idx+3, width=wx.COL_WIDTH_AUTOSIZE)
34 | col_count = self.stocks_dvc.GetColumnCount()
35 | self.stocks_dvc.AppendTextColumn(
36 | stocks_columns[-2], col_count, width=wx.COL_WIDTH_AUTOSIZE, mode=dv.DATAVIEW_CELL_EDITABLE
37 | )
38 | self.stocks_dvc.AppendTextColumn(
39 | stocks_columns[-1], col_count+1, width=wx.COL_WIDTH_AUTOSIZE, mode=dv.DATAVIEW_CELL_EDITABLE
40 | )
41 | for col in self.stocks_dvc.Columns:
42 | col.Sortable = True
43 | col.Reorderable = True
44 |
45 | self.stocks_footer_dvlc = dv.DataViewListCtrl(self, size=(1600, 10), style=dv.DV_VERT_RULES)
46 | for val in stocks_footer_columns:
47 | self.stocks_footer_dvlc.AppendTextColumn(val, width=wx.COL_WIDTH_AUTOSIZE)
48 | self.stocks_footer_dvlc.AppendItem(['0' for _ in range(len(stocks_footer_columns))])
49 |
50 | stocklist_sizer = wx.BoxSizer(wx.VERTICAL)
51 | stocklist_sizer.Add(self.stocks_dvc, 0, wx.EXPAND)
52 | stocklist_sizer.Add(self.stocks_footer_dvlc, 1, wx.EXPAND)
53 | self.SetSizerAndFit(stocklist_sizer)
54 | self.SetMinSize((1600, 765))
55 |
56 | def stocks_dvc_context_menu(self, event):
57 | context_menu = wx.Menu()
58 | item1 = wx.MenuItem(context_menu, wx.NewIdRef(), 'Add Row')
59 | item2 = wx.MenuItem(context_menu, wx.NewIdRef(), 'Delete Rows')
60 | item9 = wx.MenuItem(context_menu, wx.NewIdRef(), 'Save Stocks Data')
61 | context_menu.Append(item1)
62 | context_menu.Append(item2)
63 | context_menu.Append(item9)
64 |
65 | self.Bind(wx.EVT_MENU, self.add_row, id=item1.GetId())
66 | self.Bind(wx.EVT_MENU, self.delete_rows, id=item2.GetId())
67 | self.Bind(wx.EVT_MENU, self.save_stocks_data, id=item9.GetId())
68 |
69 | self.PopupMenu(context_menu)
70 | context_menu.Destroy()
71 |
72 | def add_row(self, event):
73 | col_count = self.stocks_dvc.GetColumnCount()
74 | values = ['0' for _ in range(col_count)]
75 | self.stocks_dvc_model.add_row(values)
76 |
77 | def delete_rows(self, event):
78 | selected = self.stocks_dvc.GetSelections()
79 | rows = [self.stocks_dvc_model.GetRow(item) for item in selected]
80 | self.stocks_dvc_model.delete_rows(rows)
81 |
82 | def save_stocks_data(self, event):
83 | dump_data(self.stocks_dvc_model.data, STOCKLIST_DATA_PATH)
84 | self.parent.GetTopLevelParent().dashboard.update_passive_income()
85 |
86 | def stock_selected(self, event):
87 | selected = self.stocks_dvc.GetSelections()
88 | count = len(selected)
89 | cost_basis = 0
90 | market_value = 0
91 | gain_lost = 0
92 | annual_dividend = 0
93 | dividend_received = 0
94 |
95 | for i in selected:
96 | row = self.stocks_dvc_model.GetRow(i)
97 | row_data = self.stocks_dvc_model.GetRowData(row)
98 | cost_basis += float(row_data[4])
99 | market_value += float(row_data[5])
100 | gain_lost += float(row_data[6])
101 | annual_dividend += float(row_data[9])
102 | dividend_received += float(row_data[10])
103 |
104 | row_count = self.stocks_dvc_model.GetRowCount()
105 | account_total = sum([float(self.stocks_dvc_model.GetValueByRow(i, 5)) for i in range(row_count)])
106 |
107 | try:
108 | gain_lost_percentage = gain_lost / cost_basis * 100
109 | yield_percentage = annual_dividend / market_value * 100
110 | account_percentage = market_value / account_total * 100
111 | except ZeroDivisionError:
112 | gain_lost_percentage = 0
113 | yield_percentage = 0
114 | account_percentage = 0
115 |
116 | footer_data = [
117 | count, cost_basis, market_value,
118 | gain_lost, gain_lost_percentage,
119 | yield_percentage, annual_dividend, dividend_received,
120 | account_percentage
121 | ]
122 | footer_data = [str(round(i, 2)) for i in footer_data]
123 |
124 | self.stocks_footer_dvlc.DeleteItem(0)
125 | self.stocks_footer_dvlc.AppendItem(footer_data)
126 |
--------------------------------------------------------------------------------
/fintrack.app/Contents/Resources/site.py:
--------------------------------------------------------------------------------
1 | """
2 | Append module search paths for third-party packages to sys.path.
3 |
4 | This is stripped down and customized for use in py2app applications
5 | """
6 |
7 | import sys
8 |
9 | # os is actually in the zip, so we need to do this here.
10 | # we can't call it python24.zip because zlib is not a built-in module (!)
11 | _libdir = "/lib/python" + sys.version[:3]
12 | _parent = "/".join(__file__.split("/")[:-1])
13 | if not _parent.endswith(_libdir):
14 | _parent += _libdir
15 | sys.path.append(_parent + "/site-packages.zip")
16 |
17 | # Stuffit decompresses recursively by default, that can mess up py2app bundles,
18 | # add the uncompressed site-packages to the path to compensate for that.
19 | sys.path.append(_parent + "/site-packages")
20 |
21 | ENABLE_USER_SITE = False
22 |
23 | USER_SITE = None
24 | USER_BASE = None
25 |
26 | import os # noqa: E402
27 |
28 | try:
29 | basestring
30 | except NameError:
31 | basestring = str
32 |
33 |
34 | def makepath(*paths):
35 | dir = os.path.abspath(os.path.join(*paths))
36 | return dir, os.path.normcase(dir)
37 |
38 |
39 | for m in sys.modules.values():
40 | f = getattr(m, "__file__", None)
41 | if isinstance(f, basestring) and os.path.exists(f):
42 | m.__file__ = os.path.abspath(m.__file__)
43 | del m
44 |
45 | # This ensures that the initial path provided by the interpreter contains
46 | # only absolute pathnames, even if we're running from the build directory.
47 | L = []
48 | _dirs_in_sys_path = {}
49 | dir = dircase = None # sys.path may be empty at this point
50 | for dir in sys.path:
51 | # Filter out duplicate paths (on case-insensitive file systems also
52 | # if they only differ in case); turn relative paths into absolute
53 | # paths.
54 | dir, dircase = makepath(dir)
55 | if dircase not in _dirs_in_sys_path:
56 | L.append(dir)
57 | _dirs_in_sys_path[dircase] = 1
58 |
59 | sys.path[:] = L
60 | del dir, dircase, L
61 | _dirs_in_sys_path = None
62 |
63 |
64 | def _init_pathinfo():
65 | global _dirs_in_sys_path
66 | _dirs_in_sys_path = d = {}
67 | for dir in sys.path:
68 | if dir and not os.path.isdir(dir):
69 | continue
70 | dir, dircase = makepath(dir)
71 | d[dircase] = 1
72 |
73 |
74 | def addsitedir(sitedir):
75 | global _dirs_in_sys_path
76 | if _dirs_in_sys_path is None:
77 | _init_pathinfo()
78 | reset = 1
79 | else:
80 | reset = 0
81 | sitedir, sitedircase = makepath(sitedir)
82 | if sitedircase not in _dirs_in_sys_path:
83 | sys.path.append(sitedir) # Add path component
84 | try:
85 | names = os.listdir(sitedir)
86 | except os.error:
87 | return
88 | names.sort()
89 | for name in names:
90 | if name[-4:] == os.extsep + "pth":
91 | addpackage(sitedir, name)
92 | if reset:
93 | _dirs_in_sys_path = None
94 |
95 |
96 | def addpackage(sitedir, name):
97 | global _dirs_in_sys_path
98 | if _dirs_in_sys_path is None:
99 | _init_pathinfo()
100 | reset = 1
101 | else:
102 | reset = 0
103 | fullname = os.path.join(sitedir, name)
104 | try:
105 | with open(fullname) as f:
106 | while 1:
107 | dir = f.readline()
108 | if not dir:
109 | break
110 | if dir[0] == "#":
111 | continue
112 | if dir.startswith("import"):
113 | exec(dir)
114 | continue
115 | if dir[-1] == "\n":
116 | dir = dir[:-1]
117 | dir, dircase = makepath(sitedir, dir)
118 | if dircase not in _dirs_in_sys_path and os.path.exists(dir):
119 | sys.path.append(dir)
120 | _dirs_in_sys_path[dircase] = 1
121 | except IOError:
122 | return
123 | if reset:
124 | _dirs_in_sys_path = None
125 |
126 |
127 | def _get_path(userbase):
128 | version = sys.version_info
129 |
130 | if sys.platform == "darwin" and getattr(sys, "_framework", None):
131 | return "%s/lib/python/site-packages" % (userbase,)
132 |
133 | return "%s/lib/python%d.%d/site-packages" % (userbase, version[0], version[1])
134 |
135 |
136 | def _getuserbase():
137 | env_base = os.environ.get("PYTHONUSERBASE", None)
138 | if env_base:
139 | return env_base
140 |
141 | def joinuser(*args):
142 | return os.path.expanduser(os.path.join(*args))
143 |
144 | if getattr(sys, "_framework", None):
145 | return joinuser("~", "Library", sys._framework, "%d.%d" % sys.version_info[:2])
146 |
147 | return joinuser("~", ".local")
148 |
149 |
150 | def getuserbase():
151 | """Returns the `user base` directory path.
152 |
153 | The `user base` directory can be used to store data. If the global
154 | variable ``USER_BASE`` is not initialized yet, this function will also set
155 | it.
156 | """
157 | global USER_BASE
158 | if USER_BASE is None:
159 | USER_BASE = _getuserbase()
160 | return USER_BASE
161 |
162 |
163 | def getusersitepackages():
164 | """Returns the user-specific site-packages directory path.
165 |
166 | If the global variable ``USER_SITE`` is not initialized yet, this
167 | function will also set it.
168 | """
169 | global USER_SITE
170 | userbase = getuserbase() # this will also set USER_BASE
171 |
172 | if USER_SITE is None:
173 | USER_SITE = _get_path(userbase)
174 |
175 | return USER_SITE
176 |
177 |
178 | #
179 | # Run custom site specific code, if available.
180 | #
181 | try:
182 | import sitecustomize # noqa: F401
183 | except ImportError:
184 | pass
185 |
186 | #
187 | # Remove sys.setdefaultencoding() so that users cannot change the
188 | # encoding after initialization. The test for presence is needed when
189 | # this module is run as a script, because this code is executed twice.
190 | #
191 | if hasattr(sys, "setdefaultencoding"):
192 | del sys.setdefaultencoding
193 |
194 | if sys.version_info[0] == 3:
195 | import builtins # noqa: E402
196 |
197 | import _sitebuiltins # noqa: E402
198 |
199 | builtins.help = _sitebuiltins._Helper()
200 | builtins.quit = _sitebuiltins.Quitter("quit", "Ctrl-D (i.e. EOF)")
201 | builtins.exit = _sitebuiltins.Quitter("exit", "Ctrl-D (i.e. EOF)")
202 |
203 | # Prefixes for site-packages; add additional prefixes like /usr/local here
204 | PREFIXES = [sys.prefix, sys.exec_prefix]
205 |
--------------------------------------------------------------------------------
/gui/widgets/financials.py:
--------------------------------------------------------------------------------
1 | import wx
2 | import wx.dataview as dv
3 | from functions.funcs import load_data_from, dump_data
4 | from settings import ASSETS_DEBTS_DATA_PATH, BUDGET_PLAN_DATA_PATH, ACCOUNTS_DATA_PATH
5 | from settings import assets_debts_columns, budget_plan_columns, accounts_columns
6 |
7 |
8 | def make_dvlc(parent, values, size):
9 | dvlc = dv.DataViewListCtrl(
10 | parent,
11 | size=size,
12 | style=dv.DV_MULTIPLE | dv.DV_ROW_LINES | dv.DV_ROW_LINES | dv.DV_VERT_RULES
13 | )
14 | for v in values:
15 | dvlc.AppendTextColumn(
16 | v,
17 | width=wx.COL_WIDTH_AUTOSIZE,
18 | mode=dv.DATAVIEW_CELL_EDITABLE,
19 | flags=dv.DATAVIEW_COL_SORTABLE | dv.DATAVIEW_COL_REORDERABLE | dv.DATAVIEW_COL_RESIZABLE
20 | )
21 | return dvlc
22 |
23 |
24 | class Financials(wx.Panel):
25 | """"""
26 |
27 | def __init__(self, name, parent, *args, **kwargs):
28 | super().__init__(parent, *args, **kwargs)
29 |
30 | self.parent = parent
31 | self.name = name
32 |
33 | ##### assets and debts #####
34 | self.dvlc = make_dvlc(self, assets_debts_columns, (500, 600))
35 | self.dvlc.Bind(dv.EVT_DATAVIEW_ITEM_CONTEXT_MENU, self.dvlc_context_menu)
36 | self.dvlc.Bind(dv.EVT_DATAVIEW_ITEM_VALUE_CHANGED, self.show_dvlc_status)
37 |
38 | for item in load_data_from(ASSETS_DEBTS_DATA_PATH):
39 | self.dvlc.AppendItem(item)
40 |
41 | self.dvlc_popup_id1 = wx.NewIdRef() # add new row
42 | self.dvlc_popup_id2 = wx.NewIdRef() # delete selected rows
43 | self.dvlc_popup_id9 = wx.NewIdRef() # save data
44 |
45 | self.dvlc_status = wx.StaticText(self, -1, ' ')
46 | self.dvlc_status.SetForegroundColour('red')
47 |
48 | asset_debt_sizer = wx.StaticBoxSizer(wx.VERTICAL, self, label='Assets and Debts')
49 | asset_debt_sizer.Add(self.dvlc, 0)
50 | asset_debt_sizer.Add(self.dvlc_status, 0)
51 |
52 | ##### budget plan #####
53 | self.dvlc2 = make_dvlc(self, budget_plan_columns, (600, 600))
54 | self.dvlc2.Bind(dv.EVT_DATAVIEW_ITEM_CONTEXT_MENU, self.dvlc2_context_menu)
55 | self.dvlc2.Bind(dv.EVT_DATAVIEW_ITEM_VALUE_CHANGED, self.show_dvlc_status)
56 |
57 | for item in load_data_from(BUDGET_PLAN_DATA_PATH):
58 | self.dvlc2.AppendItem(item)
59 |
60 | self.dvlc2_popup_id1 = wx.NewIdRef()
61 | self.dvlc2_popup_id2 = wx.NewIdRef()
62 | self.dvlc2_popup_id9 = wx.NewIdRef()
63 |
64 | self.dvlc2_status = wx.StaticText(self, -1, ' ')
65 | self.dvlc2_status.SetForegroundColour('red')
66 |
67 | budget_sizer = wx.StaticBoxSizer(wx.VERTICAL, self, label='Budget Plan')
68 | budget_sizer.Add(self.dvlc2, 0)
69 | budget_sizer.Add(self.dvlc2_status, 0)
70 |
71 | ##### financial account #####
72 |
73 | self.dvlc3 = make_dvlc(self, accounts_columns, (340, 600))
74 | self.dvlc3.Bind(dv.EVT_DATAVIEW_ITEM_CONTEXT_MENU, self.dvlc3_context_menu)
75 | self.dvlc3.Bind(dv.EVT_DATAVIEW_ITEM_VALUE_CHANGED, self.show_dvlc_status)
76 |
77 | for item in load_data_from(ACCOUNTS_DATA_PATH):
78 | self.dvlc3.AppendItem(item)
79 |
80 | self.dvlc3_popup_id1 = wx.NewIdRef()
81 | self.dvlc3_popup_id2 = wx.NewIdRef()
82 | self.dvlc3_popup_id9 = wx.NewIdRef()
83 |
84 | self.dvlc3_status = wx.StaticText(self, -1, ' ')
85 | self.dvlc3_status.SetForegroundColour('red')
86 |
87 | accounts_sizer = wx.StaticBoxSizer(wx.VERTICAL, self, label='Financial Accounts')
88 | accounts_sizer.Add(self.dvlc3, 0)
89 | accounts_sizer.Add(self.dvlc3_status, 0)
90 |
91 | financials_sizer = wx.BoxSizer(wx.HORIZONTAL)
92 | financials_sizer.AddMany((asset_debt_sizer, budget_sizer, accounts_sizer))
93 | self.SetSizerAndFit(financials_sizer)
94 | self.SetMinSize((self.GetMinWidth(), self.GetMinHeight() + 30))
95 |
96 | def dvlc_context_menu(self, event):
97 | context_menu = wx.Menu()
98 | item1 = wx.MenuItem(context_menu, self.dvlc_popup_id1, 'Add New Row')
99 | item2 = wx.MenuItem(context_menu, self.dvlc_popup_id2, 'Delete Rows')
100 | item9 = wx.MenuItem(context_menu, self.dvlc_popup_id9, 'Save Assets and Debts Data')
101 | context_menu.Append(item1)
102 | context_menu.Append(item2)
103 | context_menu.Append(item9)
104 |
105 | self.Bind(wx.EVT_MENU, self.dvlc_add_row, id=self.dvlc_popup_id1)
106 | self.Bind(wx.EVT_MENU, self.dvlc_delete_rows, id=self.dvlc_popup_id2)
107 | self.Bind(wx.EVT_MENU, self.dvlc_save_data, id=self.dvlc_popup_id9)
108 |
109 | self.PopupMenu(context_menu)
110 | context_menu.Destroy()
111 |
112 | def dvlc2_context_menu(self, event):
113 | context_menu = wx.Menu()
114 | item1 = wx.MenuItem(context_menu, self.dvlc2_popup_id1, 'Add New Row')
115 | item2 = wx.MenuItem(context_menu, self.dvlc2_popup_id2, 'Delete Rows')
116 | item9 = wx.MenuItem(context_menu, self.dvlc2_popup_id9, 'Save Budget Plan Data')
117 | context_menu.Append(item1)
118 | context_menu.Append(item2)
119 | context_menu.Append(item9)
120 |
121 | self.Bind(wx.EVT_MENU, self.dvlc_add_row, id=self.dvlc2_popup_id1)
122 | self.Bind(wx.EVT_MENU, self.dvlc_delete_rows, id=self.dvlc2_popup_id2)
123 | self.Bind(wx.EVT_MENU, self.dvlc_save_data, id=self.dvlc2_popup_id9)
124 |
125 | self.PopupMenu(context_menu)
126 | context_menu.Destroy()
127 |
128 | def dvlc3_context_menu(self, event):
129 | context_menu = wx.Menu()
130 | item1 = wx.MenuItem(context_menu, self.dvlc3_popup_id1, 'Add New Row')
131 | item2 = wx.MenuItem(context_menu, self.dvlc3_popup_id2, 'Delete Rows')
132 | item9 = wx.MenuItem(context_menu, self.dvlc3_popup_id9, 'Save Accounts Data')
133 | context_menu.Append(item1)
134 | context_menu.Append(item2)
135 | context_menu.Append(item9)
136 |
137 | self.Bind(wx.EVT_MENU, self.dvlc_add_row, id=self.dvlc3_popup_id1)
138 | self.Bind(wx.EVT_MENU, self.dvlc_delete_rows, id=self.dvlc3_popup_id2)
139 | self.Bind(wx.EVT_MENU, self.dvlc_save_data, id=self.dvlc3_popup_id9)
140 |
141 | self.PopupMenu(context_menu)
142 | context_menu.Destroy()
143 |
144 | def dvlc_add_row(self, event):
145 | dvlc = self.dvlc
146 | status_text = self.dvlc_status
147 | if event.GetId() == self.dvlc2_popup_id1:
148 | dvlc = self.dvlc2
149 | status_text = self.dvlc2_status
150 | elif event.GetId() == self.dvlc3_popup_id1:
151 | dvlc = self.dvlc3
152 | status_text = self.dvlc3_status
153 | col_count = dvlc.GetColumnCount()
154 | dvlc.AppendItem(['0' for _ in range(col_count)])
155 | status_text.SetLabel('Data edited, please save.')
156 |
157 | def dvlc_delete_rows(self, event):
158 | dvlc = self.dvlc
159 | status_text = self.dvlc_status
160 | if event.GetId() == self.dvlc2_popup_id2:
161 | dvlc = self.dvlc2
162 | status_text = self.dvlc2_status
163 | elif event.GetId() == self.dvlc3_popup_id2:
164 | dvlc = self.dvlc3
165 | status_text = self.dvlc3_status
166 |
167 | for i in range(dvlc.GetItemCount() - 1, -1, -1):
168 | if dvlc.IsRowSelected(i):
169 | dvlc.DeleteItem(i)
170 |
171 | status_text.SetLabel('Data edited, please save.')
172 |
173 | def dvlc_save_data(self, event):
174 | path = ASSETS_DEBTS_DATA_PATH
175 | dvlc = self.dvlc
176 | status_text = self.dvlc_status
177 | if event.GetId() == self.dvlc2_popup_id9:
178 | path = BUDGET_PLAN_DATA_PATH
179 | dvlc = self.dvlc2
180 | status_text = self.dvlc2_status
181 | elif event.GetId() == self.dvlc3_popup_id9:
182 | path = ACCOUNTS_DATA_PATH
183 | dvlc = self.dvlc3
184 | status_text = self.dvlc3_status
185 | data = []
186 | col_count = dvlc.GetColumnCount()
187 | row_count = dvlc.GetItemCount()
188 | for i in range(row_count):
189 | data.append([dvlc.GetTextValue(i, j) for j in range(col_count)])
190 | dump_data(data, path)
191 | status_text.SetLabel(' ')
192 |
193 | self.parent.GetTopLevelParent().dashboard.update_metrics_net_worth()
194 |
195 | def show_dvlc_status(self, event):
196 | status_text = self.dvlc_status
197 | if event.GetEventObject() == self.dvlc2:
198 | status_text = self.dvlc2_status
199 | elif event.GetEventObject() == self.dvlc3:
200 | status_text = self.dvlc3_status
201 | status_text.SetLabel('Data edited, please save.')
202 |
--------------------------------------------------------------------------------
/gui/widgets/dashboard.py:
--------------------------------------------------------------------------------
1 | from math import pi
2 | import wx
3 | import wx.dataview as dv
4 | import wx.lib.gizmos as gizmos
5 | from wx.lib.agw.piectrl import PieCtrl, PiePart
6 | from wx.lib.agw.pycollapsiblepane import PyCollapsiblePane
7 | from functions.funcs import load_data_from, dump_data
8 | from gui.widgets.creditscoresupdatedialog import CreditScoresUpdateDialog
9 | from settings import METRICS_DATA_PATH, CREDIT_SCORES_DATA_PATH
10 | from settings import ASSETS_DEBTS_DATA_PATH, STOCKLIST_DATA_PATH
11 | from settings import net_worth_labels, passive_income_labels, metrics_columns
12 |
13 |
14 | def make_led_num_ctrl(parent, label, value, color, size=(200, 50)):
15 | label = wx.StaticText(parent, label=label)
16 | led = gizmos.LEDNumberCtrl(
17 | parent, wx.ID_ANY, (25, 25), size=size, style=gizmos.LED_ALIGN_RIGHT
18 | )
19 | led.SetValue(value)
20 | led.SetForegroundColour(color)
21 | led.SetDrawFaded(True)
22 | return label, led
23 |
24 |
25 | class Dashboard(wx.Panel):
26 | """"""
27 |
28 | def __init__(self, name, parent, *args, **kwargs):
29 | super().__init__(parent, *args, **kwargs)
30 |
31 | self.name = name
32 |
33 | ##### net worth LEDs #####
34 | net_worth_led_colors = ['firebrick', 'forest green', 'lime green', 'forest green']
35 | self.net_worth_sizer = wx.StaticBoxSizer(wx.VERTICAL, self, label='Personal Summary')
36 | for idx, text in enumerate(net_worth_labels):
37 | label, led = make_led_num_ctrl(self, text, '', net_worth_led_colors[idx])
38 | self.net_worth_sizer.Add(label)
39 | self.net_worth_sizer.Add(led, 0, wx.BOTTOM, 10)
40 |
41 | ##### passive income LEDs #####
42 | self.dividend_sizer = wx.StaticBoxSizer(wx.VERTICAL, self, label='Passive Income')
43 | for text in passive_income_labels:
44 | label, led = make_led_num_ctrl(self, text, '', 'forest green', size=(175, 50))
45 | self.dividend_sizer.Add(label)
46 | self.dividend_sizer.Add(led, 0, wx.BOTTOM, 10)
47 |
48 | ##### credit scores LEDs #####
49 | self.credit_score_sizer = wx.StaticBoxSizer(wx.VERTICAL, self, label='Credit Scores')
50 | for (text, value) in load_data_from(CREDIT_SCORES_DATA_PATH):
51 | label, led = make_led_num_ctrl(self, text, value, 'sky blue', (100, 50))
52 | led.Bind(wx.EVT_CONTEXT_MENU, self.credit_scores_context_menu)
53 | self.credit_score_sizer.Add(label)
54 | self.credit_score_sizer.Add(led, 0, wx.BOTTOM, 10)
55 |
56 | ##### pie chart #####
57 | self.pie = PieCtrl(self, wx.ID_ANY, wx.DefaultPosition, wx.Size(320, 260))
58 | self.pie.SetHeight(25)
59 | self.pie.SetBackColour('dark grey')
60 | self.pie.SetShowEdges(False)
61 | legend = self.pie.GetLegend()
62 | legend.SetLabelColour('white')
63 | legend.SetTransparent(True)
64 | self.pie_part1 = PiePart(100, wx.Colour(200, 50, 50), 'TSP')
65 | self.pie_part2 = PiePart(250, wx.Colour(50, 200, 50), 'Schwab')
66 | self.pie_part3 = PiePart(450, wx.Colour(50, 50, 200), 'Roth IRA')
67 | self.pie_part4 = PiePart(150, wx.Colour(200, 200, 50), 'Webull')
68 | self.pie_part5 = PiePart(150, wx.Colour(200, 50, 200), 'Coinbase')
69 | self.pie._series.append(self.pie_part1)
70 | self.pie._series.append(self.pie_part2)
71 | self.pie._series.append(self.pie_part3)
72 | self.pie._series.append(self.pie_part4)
73 | self.pie._series.append(self.pie_part5)
74 |
75 | self.hslider = wx.Slider(
76 | self, wx.ID_ANY, 180, 0, 360, size=(260, -1), style=wx.SL_LABELS | wx.SL_TOP
77 | )
78 | self.hslider.Bind(wx.EVT_SLIDER, self.hslider_handler)
79 | self.vslider = wx.Slider(
80 | self, wx.ID_ANY, 40, 20, 60, size=wx.DefaultSize, style=wx.SL_VERTICAL | wx.SL_LABELS
81 | )
82 | self.vslider.Bind(wx.EVT_SLIDER, self.vslider_handler)
83 | hsizer = wx.BoxSizer(wx.HORIZONTAL)
84 | hsizer.Add(self.pie, 0, wx.EXPAND)
85 | hsizer.Add(self.vslider, 1, wx.EXPAND | wx.GROW)
86 | pie_sizer = wx.StaticBoxSizer(wx.VERTICAL, self, label='Investment Distribution')
87 | pie_sizer.Add(hsizer)
88 | pie_sizer.Add(self.hslider, 1, wx.EXPAND | wx.GROW)
89 |
90 | led_pie_sizer = wx.BoxSizer(wx.HORIZONTAL)
91 | led_pie_sizer.Add(self.net_worth_sizer, 0, wx.BOTTOM)
92 | led_pie_sizer.Add(self.dividend_sizer, 0, wx.BOTTOM)
93 | led_pie_sizer.Add(self.credit_score_sizer, 0, wx.BOTTOM)
94 | led_pie_sizer.Add(pie_sizer, 0, wx.BOTTOM | wx.EXPAND)
95 |
96 | ##### Monthly Metrics dataview #####
97 | self.cpane = PyCollapsiblePane(self, label='Monthly Metrics', style=wx.CP_DEFAULT_STYLE)
98 | self.cpane.SetAutoLayout(True)
99 | self.cpane.Bind(wx.EVT_COLLAPSIBLEPANE_CHANGED, self.collapse_pane_change)
100 |
101 | self.metrics_dvlc = dv.DataViewListCtrl(
102 | self.cpane.GetPane(), size=(920, 280), style=dv.DV_ROW_LINES | dv.DV_VERT_RULES
103 | )
104 | self.metrics_dvlc.Bind(dv.EVT_DATAVIEW_ITEM_CONTEXT_MENU, self.metrics_context_menu)
105 | self.metrics_dvlc.Bind(dv.EVT_DATAVIEW_SELECTION_CHANGED, self.update_pie_chart)
106 |
107 | for i in metrics_columns[:8]:
108 | self.metrics_dvlc.AppendTextColumn(
109 | i, width=wx.COL_WIDTH_AUTOSIZE, mode=dv.DATAVIEW_CELL_EDITABLE
110 | )
111 | for i in metrics_columns[8:]:
112 | self.metrics_dvlc.AppendTextColumn(i, width=wx.COL_WIDTH_AUTOSIZE)
113 | for item in load_data_from(METRICS_DATA_PATH):
114 | self.metrics_dvlc.AppendItem(item)
115 |
116 | self.dashboard_sizer = wx.BoxSizer(wx.VERTICAL)
117 | self.dashboard_sizer.Add(led_pie_sizer, 0, wx.EXPAND)
118 | self.dashboard_sizer.Add(self.cpane, 0, wx.EXPAND)
119 |
120 | self.SetSizerAndFit(self.dashboard_sizer)
121 | self.dashboard_sizer.Layout()
122 | self.SetMinSize((self.GetMinWidth(), self.GetMinHeight() + 30))
123 |
124 | self.hslider_handler(wx.EVT_SLIDER)
125 | self.vslider_handler(wx.EVT_SLIDER)
126 |
127 | self.update_metrics_net_worth()
128 | self.update_passive_income()
129 | self.update_pie_chart(dv.EVT_DATAVIEW_SELECTION_CHANGED)
130 |
131 | def vslider_handler(self, event):
132 | self.pie.SetAngle(float(self.vslider.GetValue()) / 180.0 * pi)
133 |
134 | def hslider_handler(self, event):
135 | self.pie.SetRotationAngle(float(self.hslider.GetValue()) / 180.0 * pi)
136 |
137 | def collapse_pane_change(self, event):
138 | self.SetSizerAndFit(self.dashboard_sizer)
139 | self.dashboard_sizer.Layout()
140 |
141 | if self.cpane.IsExpanded():
142 | size = self.GetSize()
143 | else:
144 | size = (self.GetMinWidth(), self.GetMinHeight() + 30)
145 | self.SetMinSize(size)
146 |
147 | frame = self.GetTopLevelParent()
148 | frame.SetClientSize(size)
149 | frame.SendSizeEvent()
150 | frame.CenterOnScreen()
151 |
152 | def update_metrics_net_worth(self):
153 | debts = 0
154 | cash = 0
155 | assets = 0
156 | for item in load_data_from(ASSETS_DEBTS_DATA_PATH):
157 | if item[2] == 'Debt':
158 | debts += float(item[1])
159 | elif item[2] == 'Cash':
160 | cash += float(item[1])
161 | elif item[2] == 'Assets':
162 | assets += float(item[1])
163 |
164 | last_col = self.metrics_dvlc.GetColumnCount() - 1
165 | last_row = self.metrics_dvlc.GetItemCount() - 1
166 |
167 | tsp = self.metrics_dvlc.GetTextValue(last_row, 1)
168 | stonks = self.metrics_dvlc.GetTextValue(last_row, 2)
169 | roth = self.metrics_dvlc.GetTextValue(last_row, 3)
170 | webull = self.metrics_dvlc.GetTextValue(last_row, 4)
171 | coinbase = self.metrics_dvlc.GetTextValue(last_row, 5)
172 | dividend = self.metrics_dvlc.GetTextValue(last_row, 6)
173 |
174 | investments = sum(map(float, (tsp, stonks, roth, webull, coinbase, dividend)))
175 | total_assets = round(assets + investments + cash, 2)
176 | net_worth = round(total_assets + debts, 2) # debts is negative
177 | debt_asset_ratio = round(abs(debts / total_assets), 4)
178 |
179 | self.metrics_dvlc.SetTextValue(str(round(net_worth, 2)), last_row, last_col)
180 | self.metrics_dvlc.SetTextValue(str(round(assets, 2)), last_row, last_col - 1)
181 | self.metrics_dvlc.SetTextValue(str(round(debts, 2)), last_row, last_col - 2)
182 | self.metrics_dvlc.SetTextValue(str(round(cash)), last_row, last_col - 3)
183 |
184 | children = self.net_worth_sizer.GetChildren()
185 | children[1].GetWindow().SetValue(str(debts))
186 | children[3].GetWindow().SetValue(str(total_assets))
187 | children[5].GetWindow().SetValue(str(net_worth))
188 | children[7].GetWindow().SetValue(str(debt_asset_ratio))
189 |
190 | def update_passive_income(self):
191 | annual_dividend = 0
192 | earned_dividend = 0
193 | market_value = 0
194 | for stock in load_data_from(STOCKLIST_DATA_PATH)[1:]:
195 | market_value += float(stock[5])
196 | annual_dividend += float(stock[9])
197 | earned_dividend += float(stock[10])
198 |
199 | data = {
200 | 1: str(round(annual_dividend / market_value * 100, 4)),
201 | 3: str(round(annual_dividend, 2)),
202 | 5: str(round(annual_dividend / 12, 2)),
203 | 7: str(round(earned_dividend, 2))
204 | }
205 | children = self.dividend_sizer.GetChildren()
206 | for key, val in data.items():
207 | ctrl = children[key].GetWindow()
208 | ctrl.SetValue(val)
209 |
210 | def update_pie_chart(self, event):
211 | row = self.metrics_dvlc.GetSelectedRow()
212 | if row is wx.NOT_FOUND:
213 | row = self.metrics_dvlc.GetItemCount() - 1
214 |
215 | data_store = self.metrics_dvlc.GetStore()
216 | col_count = self.metrics_dvlc.GetColumnCount()
217 | row_data = [data_store.GetValueByRow(row, col) for col in range(col_count)]
218 |
219 | self.pie_part1.SetValue(float(row_data[1]))
220 | self.pie_part2.SetValue(float(row_data[2]))
221 | self.pie_part3.SetValue(float(row_data[3]))
222 | self.pie_part4.SetValue(float(row_data[4]))
223 | self.pie_part5.SetValue(float(row_data[5]))
224 | self.pie.Refresh()
225 |
226 | def credit_scores_context_menu(self, event):
227 | self.context_menu_id1 = wx.NewIdRef()
228 | context_menu = wx.Menu()
229 | item1 = wx.MenuItem(context_menu, self.context_menu_id1, 'Update Credit Scores')
230 | context_menu.Append(item1)
231 |
232 | self.Bind(wx.EVT_MENU, self.credit_scores_update_dialog, id=self.context_menu_id1)
233 |
234 | self.PopupMenu(context_menu)
235 | context_menu.Destroy()
236 |
237 | def credit_scores_update_dialog(self, event):
238 | dialog = CreditScoresUpdateDialog(self, title='Update Credit Scores')
239 | children = self.credit_score_sizer.GetChildren()
240 |
241 | dialog.equifax_field.SetValue(children[1].GetWindow().GetValue())
242 | dialog.transunion_field.SetValue(children[3].GetWindow().GetValue())
243 | dialog.experian_field.SetValue(children[5].GetWindow().GetValue())
244 | dialog.avg_field.SetValue(children[7].GetWindow().GetValue())
245 |
246 | if dialog.ShowModal() == wx.ID_OK:
247 | data = {
248 | 1: dialog.equifax_field.GetValue(),
249 | 3: dialog.transunion_field.GetValue(),
250 | 5: dialog.experian_field.GetValue(),
251 | 7: dialog.avg_field.GetValue()
252 | }
253 | for key, val in data.items():
254 | ctrl = children[key].GetWindow()
255 | ctrl.SetValue(val)
256 |
257 | new_data = [
258 | ['Equifax', data[1]],
259 | ['Transunion', data[3]],
260 | ['Experian', data[5]],
261 | ['Average', data[7]]
262 | ]
263 | dump_data(new_data, CREDIT_SCORES_DATA_PATH)
264 | return None
265 |
266 | def metrics_context_menu(self, event):
267 | context_menu = wx.Menu()
268 | item1 = wx.MenuItem(context_menu, wx.NewIdRef(), 'Add new row')
269 | item2 = wx.MenuItem(context_menu, wx.NewIdRef(), 'Delete last row')
270 | item9 = wx.MenuItem(context_menu, wx.NewIdRef(), 'Save Metrics Data')
271 | context_menu.Append(item1)
272 | context_menu.Append(item2)
273 | context_menu.Append(item9)
274 |
275 | self.Bind(wx.EVT_MENU, self.metrics_add_row, id=item1.GetId())
276 | self.Bind(wx.EVT_MENU, self.metrics_delete_last_row, id=item2.GetId())
277 | self.Bind(wx.EVT_MENU, self.metrics_save_data, id=item9.GetId())
278 |
279 | self.PopupMenu(context_menu)
280 | context_menu.Destroy()
281 |
282 | def metrics_add_row(self, event):
283 | col_count = self.metrics_dvlc.GetColumnCount()
284 | self.metrics_dvlc.AppendItem(['123' for _ in range(col_count)])
285 |
286 | def metrics_delete_last_row(self, event):
287 | self.metrics_dvlc.DeleteItem(self.metrics_dvlc.GetItemCount() - 1)
288 |
289 | def metrics_save_data(self, event):
290 | data = []
291 | col_count = self.metrics_dvlc.GetColumnCount()
292 | for row in range(self.metrics_dvlc.GetItemCount()):
293 | data.append([self.metrics_dvlc.GetTextValue(row, col) for col in range(col_count)])
294 | dump_data(data, METRICS_DATA_PATH)
295 | self.update_metrics_net_worth()
296 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 | Preamble
9 |
10 | The GNU General Public License is a free, copyleft license for
11 | software and other kinds of works.
12 |
13 | The licenses for most software and other practical works are designed
14 | to take away your freedom to share and change the works. By contrast,
15 | the GNU General Public License is intended to guarantee your freedom to
16 | share and change all versions of a program--to make sure it remains free
17 | software for all its users. We, the Free Software Foundation, use the
18 | GNU General Public License for most of our software; it applies also to
19 | any other work released this way by its authors. You can apply it to
20 | your programs, too.
21 |
22 | When we speak of free software, we are referring to freedom, not
23 | price. Our General Public Licenses are designed to make sure that you
24 | have the freedom to distribute copies of free software (and charge for
25 | them if you wish), that you receive source code or can get it if you
26 | want it, that you can change the software or use pieces of it in new
27 | free programs, and that you know you can do these things.
28 |
29 | To protect your rights, we need to prevent others from denying you
30 | these rights or asking you to surrender the rights. Therefore, you have
31 | certain responsibilities if you distribute copies of the software, or if
32 | you modify it: responsibilities to respect the freedom of others.
33 |
34 | For example, if you distribute copies of such a program, whether
35 | gratis or for a fee, you must pass on to the recipients the same
36 | freedoms that you received. You must make sure that they, too, receive
37 | or can get the source code. And you must show them these terms so they
38 | know their rights.
39 |
40 | Developers that use the GNU GPL protect your rights with two steps:
41 | (1) assert copyright on the software, and (2) offer you this License
42 | giving you legal permission to copy, distribute and/or modify it.
43 |
44 | For the developers' and authors' protection, the GPL clearly explains
45 | that there is no warranty for this free software. For both users' and
46 | authors' sake, the GPL requires that modified versions be marked as
47 | changed, so that their problems will not be attributed erroneously to
48 | authors of previous versions.
49 |
50 | Some devices are designed to deny users access to install or run
51 | modified versions of the software inside them, although the manufacturer
52 | can do so. This is fundamentally incompatible with the aim of
53 | protecting users' freedom to change the software. The systematic
54 | pattern of such abuse occurs in the area of products for individuals to
55 | use, which is precisely where it is most unacceptable. Therefore, we
56 | have designed this version of the GPL to prohibit the practice for those
57 | products. If such problems arise substantially in other domains, we
58 | stand ready to extend this provision to those domains in future versions
59 | of the GPL, as needed to protect the freedom of users.
60 |
61 | Finally, every program is threatened constantly by software patents.
62 | States should not allow patents to restrict development and use of
63 | software on general-purpose computers, but in those that do, we wish to
64 | avoid the special danger that patents applied to a free program could
65 | make it effectively proprietary. To prevent this, the GPL assures that
66 | patents cannot be used to render the program non-free.
67 |
68 | The precise terms and conditions for copying, distribution and
69 | modification follow.
70 |
71 | TERMS AND CONDITIONS
72 |
73 | 0. Definitions.
74 |
75 | "This License" refers to version 3 of the GNU General Public License.
76 |
77 | "Copyright" also means copyright-like laws that apply to other kinds of
78 | works, such as semiconductor masks.
79 |
80 | "The Program" refers to any copyrightable work licensed under this
81 | License. Each licensee is addressed as "you". "Licensees" and
82 | "recipients" may be individuals or organizations.
83 |
84 | To "modify" a work means to copy from or adapt all or part of the work
85 | in a fashion requiring copyright permission, other than the making of an
86 | exact copy. The resulting work is called a "modified version" of the
87 | earlier work or a work "based on" the earlier work.
88 |
89 | A "covered work" means either the unmodified Program or a work based
90 | on the Program.
91 |
92 | To "propagate" a work means to do anything with it that, without
93 | permission, would make you directly or secondarily liable for
94 | infringement under applicable copyright law, except executing it on a
95 | computer or modifying a private copy. Propagation includes copying,
96 | distribution (with or without modification), making available to the
97 | public, and in some countries other activities as well.
98 |
99 | To "convey" a work means any kind of propagation that enables other
100 | parties to make or receive copies. Mere interaction with a user through
101 | a computer network, with no transfer of a copy, is not conveying.
102 |
103 | An interactive user interface displays "Appropriate Legal Notices"
104 | to the extent that it includes a convenient and prominently visible
105 | feature that (1) displays an appropriate copyright notice, and (2)
106 | tells the user that there is no warranty for the work (except to the
107 | extent that warranties are provided), that licensees may convey the
108 | work under this License, and how to view a copy of this License. If
109 | the interface presents a list of user commands or options, such as a
110 | menu, a prominent item in the list meets this criterion.
111 |
112 | 1. Source Code.
113 |
114 | The "source code" for a work means the preferred form of the work
115 | for making modifications to it. "Object code" means any non-source
116 | form of a work.
117 |
118 | A "Standard Interface" means an interface that either is an official
119 | standard defined by a recognized standards body, or, in the case of
120 | interfaces specified for a particular programming language, one that
121 | is widely used among developers working in that language.
122 |
123 | The "System Libraries" of an executable work include anything, other
124 | than the work as a whole, that (a) is included in the normal form of
125 | packaging a Major Component, but which is not part of that Major
126 | Component, and (b) serves only to enable use of the work with that
127 | Major Component, or to implement a Standard Interface for which an
128 | implementation is available to the public in source code form. A
129 | "Major Component", in this context, means a major essential component
130 | (kernel, window system, and so on) of the specific operating system
131 | (if any) on which the executable work runs, or a compiler used to
132 | produce the work, or an object code interpreter used to run it.
133 |
134 | The "Corresponding Source" for a work in object code form means all
135 | the source code needed to generate, install, and (for an executable
136 | work) run the object code and to modify the work, including scripts to
137 | control those activities. However, it does not include the work's
138 | System Libraries, or general-purpose tools or generally available free
139 | programs which are used unmodified in performing those activities but
140 | which are not part of the work. For example, Corresponding Source
141 | includes interface definition files associated with source files for
142 | the work, and the source code for shared libraries and dynamically
143 | linked subprograms that the work is specifically designed to require,
144 | such as by intimate data communication or control flow between those
145 | subprograms and other parts of the work.
146 |
147 | The Corresponding Source need not include anything that users
148 | can regenerate automatically from other parts of the Corresponding
149 | Source.
150 |
151 | The Corresponding Source for a work in source code form is that
152 | same work.
153 |
154 | 2. Basic Permissions.
155 |
156 | All rights granted under this License are granted for the term of
157 | copyright on the Program, and are irrevocable provided the stated
158 | conditions are met. This License explicitly affirms your unlimited
159 | permission to run the unmodified Program. The output from running a
160 | covered work is covered by this License only if the output, given its
161 | content, constitutes a covered work. This License acknowledges your
162 | rights of fair use or other equivalent, as provided by copyright law.
163 |
164 | You may make, run and propagate covered works that you do not
165 | convey, without conditions so long as your license otherwise remains
166 | in force. You may convey covered works to others for the sole purpose
167 | of having them make modifications exclusively for you, or provide you
168 | with facilities for running those works, provided that you comply with
169 | the terms of this License in conveying all material for which you do
170 | not control copyright. Those thus making or running the covered works
171 | for you must do so exclusively on your behalf, under your direction
172 | and control, on terms that prohibit them from making any copies of
173 | your copyrighted material outside their relationship with you.
174 |
175 | Conveying under any other circumstances is permitted solely under
176 | the conditions stated below. Sublicensing is not allowed; section 10
177 | makes it unnecessary.
178 |
179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180 |
181 | No covered work shall be deemed part of an effective technological
182 | measure under any applicable law fulfilling obligations under article
183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184 | similar laws prohibiting or restricting circumvention of such
185 | measures.
186 |
187 | When you convey a covered work, you waive any legal power to forbid
188 | circumvention of technological measures to the extent such circumvention
189 | is effected by exercising rights under this License with respect to
190 | the covered work, and you disclaim any intention to limit operation or
191 | modification of the work as a means of enforcing, against the work's
192 | users, your or third parties' legal rights to forbid circumvention of
193 | technological measures.
194 |
195 | 4. Conveying Verbatim Copies.
196 |
197 | You may convey verbatim copies of the Program's source code as you
198 | receive it, in any medium, provided that you conspicuously and
199 | appropriately publish on each copy an appropriate copyright notice;
200 | keep intact all notices stating that this License and any
201 | non-permissive terms added in accord with section 7 apply to the code;
202 | keep intact all notices of the absence of any warranty; and give all
203 | recipients a copy of this License along with the Program.
204 |
205 | You may charge any price or no price for each copy that you convey,
206 | and you may offer support or warranty protection for a fee.
207 |
208 | 5. Conveying Modified Source Versions.
209 |
210 | You may convey a work based on the Program, or the modifications to
211 | produce it from the Program, in the form of source code under the
212 | terms of section 4, provided that you also meet all of these conditions:
213 |
214 | a) The work must carry prominent notices stating that you modified
215 | it, and giving a relevant date.
216 |
217 | b) The work must carry prominent notices stating that it is
218 | released under this License and any conditions added under section
219 | 7. This requirement modifies the requirement in section 4 to
220 | "keep intact all notices".
221 |
222 | c) You must license the entire work, as a whole, under this
223 | License to anyone who comes into possession of a copy. This
224 | License will therefore apply, along with any applicable section 7
225 | additional terms, to the whole of the work, and all its parts,
226 | regardless of how they are packaged. This License gives no
227 | permission to license the work in any other way, but it does not
228 | invalidate such permission if you have separately received it.
229 |
230 | d) If the work has interactive user interfaces, each must display
231 | Appropriate Legal Notices; however, if the Program has interactive
232 | interfaces that do not display Appropriate Legal Notices, your
233 | work need not make them do so.
234 |
235 | A compilation of a covered work with other separate and independent
236 | works, which are not by their nature extensions of the covered work,
237 | and which are not combined with it such as to form a larger program,
238 | in or on a volume of a storage or distribution medium, is called an
239 | "aggregate" if the compilation and its resulting copyright are not
240 | used to limit the access or legal rights of the compilation's users
241 | beyond what the individual works permit. Inclusion of a covered work
242 | in an aggregate does not cause this License to apply to the other
243 | parts of the aggregate.
244 |
245 | 6. Conveying Non-Source Forms.
246 |
247 | You may convey a covered work in object code form under the terms
248 | of sections 4 and 5, provided that you also convey the
249 | machine-readable Corresponding Source under the terms of this License,
250 | in one of these ways:
251 |
252 | a) Convey the object code in, or embodied in, a physical product
253 | (including a physical distribution medium), accompanied by the
254 | Corresponding Source fixed on a durable physical medium
255 | customarily used for software interchange.
256 |
257 | b) Convey the object code in, or embodied in, a physical product
258 | (including a physical distribution medium), accompanied by a
259 | written offer, valid for at least three years and valid for as
260 | long as you offer spare parts or customer support for that product
261 | model, to give anyone who possesses the object code either (1) a
262 | copy of the Corresponding Source for all the software in the
263 | product that is covered by this License, on a durable physical
264 | medium customarily used for software interchange, for a price no
265 | more than your reasonable cost of physically performing this
266 | conveying of source, or (2) access to copy the
267 | Corresponding Source from a network server at no charge.
268 |
269 | c) Convey individual copies of the object code with a copy of the
270 | written offer to provide the Corresponding Source. This
271 | alternative is allowed only occasionally and noncommercially, and
272 | only if you received the object code with such an offer, in accord
273 | with subsection 6b.
274 |
275 | d) Convey the object code by offering access from a designated
276 | place (gratis or for a charge), and offer equivalent access to the
277 | Corresponding Source in the same way through the same place at no
278 | further charge. You need not require recipients to copy the
279 | Corresponding Source along with the object code. If the place to
280 | copy the object code is a network server, the Corresponding Source
281 | may be on a different server (operated by you or a third party)
282 | that supports equivalent copying facilities, provided you maintain
283 | clear directions next to the object code saying where to find the
284 | Corresponding Source. Regardless of what server hosts the
285 | Corresponding Source, you remain obligated to ensure that it is
286 | available for as long as needed to satisfy these requirements.
287 |
288 | e) Convey the object code using peer-to-peer transmission, provided
289 | you inform other peers where the object code and Corresponding
290 | Source of the work are being offered to the general public at no
291 | charge under subsection 6d.
292 |
293 | A separable portion of the object code, whose source code is excluded
294 | from the Corresponding Source as a System Library, need not be
295 | included in conveying the object code work.
296 |
297 | A "User Product" is either (1) a "consumer product", which means any
298 | tangible personal property which is normally used for personal, family,
299 | or household purposes, or (2) anything designed or sold for incorporation
300 | into a dwelling. In determining whether a product is a consumer product,
301 | doubtful cases shall be resolved in favor of coverage. For a particular
302 | product received by a particular user, "normally used" refers to a
303 | typical or common use of that class of product, regardless of the status
304 | of the particular user or of the way in which the particular user
305 | actually uses, or expects or is expected to use, the product. A product
306 | is a consumer product regardless of whether the product has substantial
307 | commercial, industrial or non-consumer uses, unless such uses represent
308 | the only significant mode of use of the product.
309 |
310 | "Installation Information" for a User Product means any methods,
311 | procedures, authorization keys, or other information required to install
312 | and execute modified versions of a covered work in that User Product from
313 | a modified version of its Corresponding Source. The information must
314 | suffice to ensure that the continued functioning of the modified object
315 | code is in no case prevented or interfered with solely because
316 | modification has been made.
317 |
318 | If you convey an object code work under this section in, or with, or
319 | specifically for use in, a User Product, and the conveying occurs as
320 | part of a transaction in which the right of possession and use of the
321 | User Product is transferred to the recipient in perpetuity or for a
322 | fixed term (regardless of how the transaction is characterized), the
323 | Corresponding Source conveyed under this section must be accompanied
324 | by the Installation Information. But this requirement does not apply
325 | if neither you nor any third party retains the ability to install
326 | modified object code on the User Product (for example, the work has
327 | been installed in ROM).
328 |
329 | The requirement to provide Installation Information does not include a
330 | requirement to continue to provide support service, warranty, or updates
331 | for a work that has been modified or installed by the recipient, or for
332 | the User Product in which it has been modified or installed. Access to a
333 | network may be denied when the modification itself materially and
334 | adversely affects the operation of the network or violates the rules and
335 | protocols for communication across the network.
336 |
337 | Corresponding Source conveyed, and Installation Information provided,
338 | in accord with this section must be in a format that is publicly
339 | documented (and with an implementation available to the public in
340 | source code form), and must require no special password or key for
341 | unpacking, reading or copying.
342 |
343 | 7. Additional Terms.
344 |
345 | "Additional permissions" are terms that supplement the terms of this
346 | License by making exceptions from one or more of its conditions.
347 | Additional permissions that are applicable to the entire Program shall
348 | be treated as though they were included in this License, to the extent
349 | that they are valid under applicable law. If additional permissions
350 | apply only to part of the Program, that part may be used separately
351 | under those permissions, but the entire Program remains governed by
352 | this License without regard to the additional permissions.
353 |
354 | When you convey a copy of a covered work, you may at your option
355 | remove any additional permissions from that copy, or from any part of
356 | it. (Additional permissions may be written to require their own
357 | removal in certain cases when you modify the work.) You may place
358 | additional permissions on material, added by you to a covered work,
359 | for which you have or can give appropriate copyright permission.
360 |
361 | Notwithstanding any other provision of this License, for material you
362 | add to a covered work, you may (if authorized by the copyright holders of
363 | that material) supplement the terms of this License with terms:
364 |
365 | a) Disclaiming warranty or limiting liability differently from the
366 | terms of sections 15 and 16 of this License; or
367 |
368 | b) Requiring preservation of specified reasonable legal notices or
369 | author attributions in that material or in the Appropriate Legal
370 | Notices displayed by works containing it; or
371 |
372 | c) Prohibiting misrepresentation of the origin of that material, or
373 | requiring that modified versions of such material be marked in
374 | reasonable ways as different from the original version; or
375 |
376 | d) Limiting the use for publicity purposes of names of licensors or
377 | authors of the material; or
378 |
379 | e) Declining to grant rights under trademark law for use of some
380 | trade names, trademarks, or service marks; or
381 |
382 | f) Requiring indemnification of licensors and authors of that
383 | material by anyone who conveys the material (or modified versions of
384 | it) with contractual assumptions of liability to the recipient, for
385 | any liability that these contractual assumptions directly impose on
386 | those licensors and authors.
387 |
388 | All other non-permissive additional terms are considered "further
389 | restrictions" within the meaning of section 10. If the Program as you
390 | received it, or any part of it, contains a notice stating that it is
391 | governed by this License along with a term that is a further
392 | restriction, you may remove that term. If a license document contains
393 | a further restriction but permits relicensing or conveying under this
394 | License, you may add to a covered work material governed by the terms
395 | of that license document, provided that the further restriction does
396 | not survive such relicensing or conveying.
397 |
398 | If you add terms to a covered work in accord with this section, you
399 | must place, in the relevant source files, a statement of the
400 | additional terms that apply to those files, or a notice indicating
401 | where to find the applicable terms.
402 |
403 | Additional terms, permissive or non-permissive, may be stated in the
404 | form of a separately written license, or stated as exceptions;
405 | the above requirements apply either way.
406 |
407 | 8. Termination.
408 |
409 | You may not propagate or modify a covered work except as expressly
410 | provided under this License. Any attempt otherwise to propagate or
411 | modify it is void, and will automatically terminate your rights under
412 | this License (including any patent licenses granted under the third
413 | paragraph of section 11).
414 |
415 | However, if you cease all violation of this License, then your
416 | license from a particular copyright holder is reinstated (a)
417 | provisionally, unless and until the copyright holder explicitly and
418 | finally terminates your license, and (b) permanently, if the copyright
419 | holder fails to notify you of the violation by some reasonable means
420 | prior to 60 days after the cessation.
421 |
422 | Moreover, your license from a particular copyright holder is
423 | reinstated permanently if the copyright holder notifies you of the
424 | violation by some reasonable means, this is the first time you have
425 | received notice of violation of this License (for any work) from that
426 | copyright holder, and you cure the violation prior to 30 days after
427 | your receipt of the notice.
428 |
429 | Termination of your rights under this section does not terminate the
430 | licenses of parties who have received copies or rights from you under
431 | this License. If your rights have been terminated and not permanently
432 | reinstated, you do not qualify to receive new licenses for the same
433 | material under section 10.
434 |
435 | 9. Acceptance Not Required for Having Copies.
436 |
437 | You are not required to accept this License in order to receive or
438 | run a copy of the Program. Ancillary propagation of a covered work
439 | occurring solely as a consequence of using peer-to-peer transmission
440 | to receive a copy likewise does not require acceptance. However,
441 | nothing other than this License grants you permission to propagate or
442 | modify any covered work. These actions infringe copyright if you do
443 | not accept this License. Therefore, by modifying or propagating a
444 | covered work, you indicate your acceptance of this License to do so.
445 |
446 | 10. Automatic Licensing of Downstream Recipients.
447 |
448 | Each time you convey a covered work, the recipient automatically
449 | receives a license from the original licensors, to run, modify and
450 | propagate that work, subject to this License. You are not responsible
451 | for enforcing compliance by third parties with this License.
452 |
453 | An "entity transaction" is a transaction transferring control of an
454 | organization, or substantially all assets of one, or subdividing an
455 | organization, or merging organizations. If propagation of a covered
456 | work results from an entity transaction, each party to that
457 | transaction who receives a copy of the work also receives whatever
458 | licenses to the work the party's predecessor in interest had or could
459 | give under the previous paragraph, plus a right to possession of the
460 | Corresponding Source of the work from the predecessor in interest, if
461 | the predecessor has it or can get it with reasonable efforts.
462 |
463 | You may not impose any further restrictions on the exercise of the
464 | rights granted or affirmed under this License. For example, you may
465 | not impose a license fee, royalty, or other charge for exercise of
466 | rights granted under this License, and you may not initiate litigation
467 | (including a cross-claim or counterclaim in a lawsuit) alleging that
468 | any patent claim is infringed by making, using, selling, offering for
469 | sale, or importing the Program or any portion of it.
470 |
471 | 11. Patents.
472 |
473 | A "contributor" is a copyright holder who authorizes use under this
474 | License of the Program or a work on which the Program is based. The
475 | work thus licensed is called the contributor's "contributor version".
476 |
477 | A contributor's "essential patent claims" are all patent claims
478 | owned or controlled by the contributor, whether already acquired or
479 | hereafter acquired, that would be infringed by some manner, permitted
480 | by this License, of making, using, or selling its contributor version,
481 | but do not include claims that would be infringed only as a
482 | consequence of further modification of the contributor version. For
483 | purposes of this definition, "control" includes the right to grant
484 | patent sublicenses in a manner consistent with the requirements of
485 | this License.
486 |
487 | Each contributor grants you a non-exclusive, worldwide, royalty-free
488 | patent license under the contributor's essential patent claims, to
489 | make, use, sell, offer for sale, import and otherwise run, modify and
490 | propagate the contents of its contributor version.
491 |
492 | In the following three paragraphs, a "patent license" is any express
493 | agreement or commitment, however denominated, not to enforce a patent
494 | (such as an express permission to practice a patent or covenant not to
495 | sue for patent infringement). To "grant" such a patent license to a
496 | party means to make such an agreement or commitment not to enforce a
497 | patent against the party.
498 |
499 | If you convey a covered work, knowingly relying on a patent license,
500 | and the Corresponding Source of the work is not available for anyone
501 | to copy, free of charge and under the terms of this License, through a
502 | publicly available network server or other readily accessible means,
503 | then you must either (1) cause the Corresponding Source to be so
504 | available, or (2) arrange to deprive yourself of the benefit of the
505 | patent license for this particular work, or (3) arrange, in a manner
506 | consistent with the requirements of this License, to extend the patent
507 | license to downstream recipients. "Knowingly relying" means you have
508 | actual knowledge that, but for the patent license, your conveying the
509 | covered work in a country, or your recipient's use of the covered work
510 | in a country, would infringe one or more identifiable patents in that
511 | country that you have reason to believe are valid.
512 |
513 | If, pursuant to or in connection with a single transaction or
514 | arrangement, you convey, or propagate by procuring conveyance of, a
515 | covered work, and grant a patent license to some of the parties
516 | receiving the covered work authorizing them to use, propagate, modify
517 | or convey a specific copy of the covered work, then the patent license
518 | you grant is automatically extended to all recipients of the covered
519 | work and works based on it.
520 |
521 | A patent license is "discriminatory" if it does not include within
522 | the scope of its coverage, prohibits the exercise of, or is
523 | conditioned on the non-exercise of one or more of the rights that are
524 | specifically granted under this License. You may not convey a covered
525 | work if you are a party to an arrangement with a third party that is
526 | in the business of distributing software, under which you make payment
527 | to the third party based on the extent of your activity of conveying
528 | the work, and under which the third party grants, to any of the
529 | parties who would receive the covered work from you, a discriminatory
530 | patent license (a) in connection with copies of the covered work
531 | conveyed by you (or copies made from those copies), or (b) primarily
532 | for and in connection with specific products or compilations that
533 | contain the covered work, unless you entered into that arrangement,
534 | or that patent license was granted, prior to 28 March 2007.
535 |
536 | Nothing in this License shall be construed as excluding or limiting
537 | any implied license or other defenses to infringement that may
538 | otherwise be available to you under applicable patent law.
539 |
540 | 12. No Surrender of Others' Freedom.
541 |
542 | If conditions are imposed on you (whether by court order, agreement or
543 | otherwise) that contradict the conditions of this License, they do not
544 | excuse you from the conditions of this License. If you cannot convey a
545 | covered work so as to satisfy simultaneously your obligations under this
546 | License and any other pertinent obligations, then as a consequence you may
547 | not convey it at all. For example, if you agree to terms that obligate you
548 | to collect a royalty for further conveying from those to whom you convey
549 | the Program, the only way you could satisfy both those terms and this
550 | License would be to refrain entirely from conveying the Program.
551 |
552 | 13. Use with the GNU Affero General Public License.
553 |
554 | Notwithstanding any other provision of this License, you have
555 | permission to link or combine any covered work with a work licensed
556 | under version 3 of the GNU Affero General Public License into a single
557 | combined work, and to convey the resulting work. The terms of this
558 | License will continue to apply to the part which is the covered work,
559 | but the special requirements of the GNU Affero General Public License,
560 | section 13, concerning interaction through a network will apply to the
561 | combination as such.
562 |
563 | 14. Revised Versions of this License.
564 |
565 | The Free Software Foundation may publish revised and/or new versions of
566 | the GNU General Public License from time to time. Such new versions will
567 | be similar in spirit to the present version, but may differ in detail to
568 | address new problems or concerns.
569 |
570 | Each version is given a distinguishing version number. If the
571 | Program specifies that a certain numbered version of the GNU General
572 | Public License "or any later version" applies to it, you have the
573 | option of following the terms and conditions either of that numbered
574 | version or of any later version published by the Free Software
575 | Foundation. If the Program does not specify a version number of the
576 | GNU General Public License, you may choose any version ever published
577 | by the Free Software Foundation.
578 |
579 | If the Program specifies that a proxy can decide which future
580 | versions of the GNU General Public License can be used, that proxy's
581 | public statement of acceptance of a version permanently authorizes you
582 | to choose that version for the Program.
583 |
584 | Later license versions may give you additional or different
585 | permissions. However, no additional obligations are imposed on any
586 | author or copyright holder as a result of your choosing to follow a
587 | later version.
588 |
589 | 15. Disclaimer of Warranty.
590 |
591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599 |
600 | 16. Limitation of Liability.
601 |
602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610 | SUCH DAMAGES.
611 |
612 | 17. Interpretation of Sections 15 and 16.
613 |
614 | If the disclaimer of warranty and limitation of liability provided
615 | above cannot be given local legal effect according to their terms,
616 | reviewing courts shall apply local law that most closely approximates
617 | an absolute waiver of all civil liability in connection with the
618 | Program, unless a warranty or assumption of liability accompanies a
619 | copy of the Program in return for a fee.
620 |
621 | END OF TERMS AND CONDITIONS
622 |
623 | How to Apply These Terms to Your New Programs
624 |
625 | If you develop a new program, and you want it to be of the greatest
626 | possible use to the public, the best way to achieve this is to make it
627 | free software which everyone can redistribute and change under these terms.
628 |
629 | To do so, attach the following notices to the program. It is safest
630 | to attach them to the start of each source file to most effectively
631 | state the exclusion of warranty; and each file should have at least
632 | the "copyright" line and a pointer to where the full notice is found.
633 |
634 |
635 | Copyright (C)
636 |
637 | This program is free software: you can redistribute it and/or modify
638 | it under the terms of the GNU General Public License as published by
639 | the Free Software Foundation, either version 3 of the License, or
640 | (at your option) any later version.
641 |
642 | This program is distributed in the hope that it will be useful,
643 | but WITHOUT ANY WARRANTY; without even the implied warranty of
644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645 | GNU General Public License for more details.
646 |
647 | You should have received a copy of the GNU General Public License
648 | along with this program. If not, see .
649 |
650 | Also add information on how to contact you by electronic and paper mail.
651 |
652 | If the program does terminal interaction, make it output a short
653 | notice like this when it starts in an interactive mode:
654 |
655 | Copyright (C)
656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657 | This is free software, and you are welcome to redistribute it
658 | under certain conditions; type `show c' for details.
659 |
660 | The hypothetical commands `show w' and `show c' should show the appropriate
661 | parts of the General Public License. Of course, your program's commands
662 | might be different; for a GUI interface, you would use an "about box".
663 |
664 | You should also get your employer (if you work as a programmer) or school,
665 | if any, to sign a "copyright disclaimer" for the program, if necessary.
666 | For more information on this, and how to apply and follow the GNU GPL, see
667 | .
668 |
669 | The GNU General Public License does not permit incorporating your program
670 | into proprietary programs. If your program is a subroutine library, you
671 | may consider it more useful to permit linking proprietary applications with
672 | the library. If this is what you want to do, use the GNU Lesser General
673 | Public License instead of this License. But first, please read
674 | .
675 |
--------------------------------------------------------------------------------