controller: Initial Windows app
This commit is contained in:
parent
6de0451f33
commit
46cdc9cd43
controller
4
controller/.gitignore
vendored
Normal file
4
controller/.gitignore
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
__pycache__/
|
||||
/build/
|
||||
/dist/
|
||||
Valconomy.spec
|
@ -0,0 +1,43 @@
|
||||
import logging
|
||||
import os
|
||||
import sys
|
||||
import time
|
||||
|
||||
import infi.systray
|
||||
|
||||
import pkg_resources # needed for pyinstaller?
|
||||
import valconomy
|
||||
|
||||
DATA_DIR = os.path.join(os.environ['LOCALAPPDATA'], 'Valconomy')
|
||||
LOG_FILE = os.path.join(DATA_DIR, 'app.log')
|
||||
|
||||
log = logging.getLogger('valconomy')
|
||||
|
||||
def data_file(fname: str) -> str:
|
||||
return os.path.abspath(os.path.join(os.path.dirname(__file__), fname))
|
||||
|
||||
running = True
|
||||
def do_quit(tray: infi.systray.SysTrayIcon):
|
||||
global running
|
||||
log.info('Shutting down')
|
||||
running = False
|
||||
|
||||
def do_view_logs(tray: infi.systray.SysTrayIcon):
|
||||
os.startfile(DATA_DIR)
|
||||
|
||||
def main():
|
||||
os.makedirs(DATA_DIR, exist_ok=True)
|
||||
logging.basicConfig(
|
||||
format='%(asctime)s %(levelname)s %(message)s', level=logging.INFO,
|
||||
handlers=(
|
||||
logging.StreamHandler(sys.stderr), # log to stderr as well as file
|
||||
logging.FileHandler(LOG_FILE),
|
||||
))
|
||||
|
||||
log.info('Starting up')
|
||||
with infi.systray.SysTrayIcon(data_file('icon.ico'), 'Valconomy', menu_options=(('View logs', None, do_view_logs),), on_quit=do_quit) as tray:
|
||||
while running:
|
||||
time.sleep(0.5)
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
1
controller/dist.bat
Normal file
1
controller/dist.bat
Normal file
@ -0,0 +1 @@
|
||||
pyinstaller.exe -y --onedir --windowed --name Valconomy --icon icon.ico --add-data icon.ico:. app.py
|
@ -0,0 +1 @@
|
||||
import hid
|
Loading…
Reference in New Issue
Block a user