Browse Source

feat(gui): package the gui file

master
louisyoungx 3 years ago
parent
commit
3c30e0cf94
  1. 4
      Config/config.ini
  2. 21
      GUI/gui.py
  3. 1
      TEST/pack.py
  4. 30
      TEST/py2app_setup.py
  5. 11
      runserver.py

4
Config/config.ini

@ -92,6 +92,10 @@ PORT = 12021 @@ -92,6 +92,10 @@ PORT = 12021
PROCESS_MODEL = False
PROCESS_COUNT = 4
[GUI]
# GUI Settings
START_USING = False
[Logger]
# 记录设置
# FILE_NAME-记录文件名,AMOUNT-记录文件个数,MAX_BYTES-单个记录文件的大小

21
GUI/gui.py

@ -0,0 +1,21 @@ @@ -0,0 +1,21 @@
import webview
from Config.settings import config
PROJECT = config.settings("Information", "PROJECT")
SERVER_HOST = config.settings("Server", "SERVER_HOST")
PORT = config.settings("Server", "PORT")
def gui():
url = "http://{}:{}/".format(SERVER_HOST, PORT)
webview.create_window(PROJECT,
url=url,
js_api=None,
width=900,
height=800,
resizable=True,
fullscreen=False,
min_size=(200, 200),
background_color='#FFF',
text_select=False)
webview.start()

1
TEST/pack.py

@ -0,0 +1 @@ @@ -0,0 +1 @@
command = ''

30
TEST/py2app_setup.py

@ -0,0 +1,30 @@ @@ -0,0 +1,30 @@
"""
This is an example of py2app py2app_setup.py script for freezing your pywebview
application
Usage:
python py2app_setup.py py2app
"""
import os
from setuptools import setup
def tree(src):
return [(root, map(lambda f: os.path.join(root, f), files))
for (root, dirs, files) in os.walk(os.path.normpath(src))]
ENTRY_POINT = ['runserver.py']
DATA_FILES = tree('DATA_FILES_DIR') + tree('DATA_FILE_DIR2')
OPTIONS = {'argv_emulation': False,
'strip': True,
#'iconfile': 'icon.icns', # uncomment to include an icon
'includes': ['WebKit', 'Foundation', 'webview']}
setup(
app=ENTRY_POINT,
data_files=DATA_FILES,
options={'py2app': OPTIONS},
setup_requires=['py2app'],
)

11
runserver.py

@ -4,12 +4,16 @@ from Scheduler.scheduler import Timer @@ -4,12 +4,16 @@ from Scheduler.scheduler import Timer
from Config.settings import config
from Server.server import server
from threading import Thread
from GUI.gui import gui
from concurrent.futures import ProcessPoolExecutor
def running():
PROCESS_MODEL = config.settings("Server", "PROCESS_MODEL")
SCHEDULER = config.settings("Scheduler", "START_USING")
SERVER = config.settings("Server", "START_USING")
GUI = config.settings("GUI", "START_USING")
def running():
if not SCHEDULER:
thread_main = Thread(target=main)
thread_main.start()
@ -26,12 +30,16 @@ def running(): @@ -26,12 +30,16 @@ def running():
else:
thread_server = Thread(target=server)
thread_server.start()
if GUI:
gui()
def server_process(work_count=4):
with ProcessPoolExecutor(work_count) as pool:
for i in range(work_count):
pool.submit(server())
if __name__ == "__main__":
DEBUG = config.settings("Debug", "DEBUG")
if DEBUG:
@ -39,4 +47,3 @@ if __name__ == "__main__": @@ -39,4 +47,3 @@ if __name__ == "__main__":
main()
else:
running()

Loading…
Cancel
Save