Split main.py to separate packages and classes

This commit is contained in:
Lexi / Zoe 2021-03-28 23:01:58 +02:00
parent a4894d612a
commit 64c9a96491
Signed by: binaryDiv
GPG Key ID: F8D4956E224DA232
6 changed files with 29 additions and 11 deletions

3
.gitignore vendored
View File

@ -4,4 +4,5 @@
__pycache__
*.py[cod]
venv/
/venv/
/tmp/

View File

@ -0,0 +1,18 @@
import webview
from app.Version import Version
from app.webview_api import WebviewApi
class LauncherApplication:
def __init__(self, app_root):
self.webviewApi = WebviewApi()
self.window = webview.create_window(Version.get_full_name(), app_root + '/assets/index.html', js_api=self.webviewApi, min_size=(600,400))
def start(self):
webview.start(debug=True)
if __name__ == '__main__':
app = LauncherApplication('..')
app.start()

7
app/Version.py Normal file
View File

@ -0,0 +1,7 @@
class Version():
app_name = 'Stardew Mod Launcher'
app_version = '0.0.1'
@classmethod
def get_full_name(cls):
return '{} v{}'.format(cls.app_name, cls.app_version)

0
app/__init__.py Normal file
View File

View File

@ -1,10 +1,7 @@
#!/usr/bin/env python3
import os
import webview
class Api():
class WebviewApi():
def hello(self):
print('Received hello()!')
print('Returning "meow"!')
@ -14,9 +11,3 @@ class Api():
sdv_root_dir = "/data/Games/SteamLibrary/steamapps/common/Stardew Valley"
mod_list = os.listdir(sdv_root_dir + "/Mods")
return mod_list
if __name__ == '__main__':
api = Api()
webview.create_window('Stardew Mod Launcher v0.0.1', '../assets/index.html', js_api=api, min_size=(600,400))
webview.start(debug=True)

View File

@ -0,0 +1 @@
from .WebviewApi import WebviewApi