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. 17
      runserver.py

4
Config/config.ini

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

21
GUI/gui.py

@ -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 @@
command = ''

30
TEST/py2app_setup.py

@ -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'],
)

17
runserver.py

@ -4,16 +4,20 @@ from Scheduler.scheduler import Timer
from Config.settings import config from Config.settings import config
from Server.server import server from Server.server import server
from threading import Thread from threading import Thread
from GUI.gui import gui
from concurrent.futures import ProcessPoolExecutor from concurrent.futures import ProcessPoolExecutor
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(): def running():
PROCESS_MODEL = config.settings("Server", "PROCESS_MODEL")
SCHEDULER = config.settings("Scheduler", "START_USING")
SERVER = config.settings("Server", "START_USING")
if not SCHEDULER: if not SCHEDULER:
thread_main = Thread(target=main) thread_main = Thread(target=main)
thread_main.start() thread_main.start()
else: # 调度器开启后main函数将被scheduler调度器代理,开启定时执行main else: # 调度器开启后main函数将被scheduler调度器代理,开启定时执行main
startTime = config.settings("Scheduler", "START_TIME") startTime = config.settings("Scheduler", "START_TIME")
skipWeekend = config.settings("Scheduler", "SKIP_WEEKEND") skipWeekend = config.settings("Scheduler", "SKIP_WEEKEND")
scheduler = Timer(task=main, startTime=startTime, skipWeekend=skipWeekend) scheduler = Timer(task=main, startTime=startTime, skipWeekend=skipWeekend)
@ -26,12 +30,16 @@ def running():
else: else:
thread_server = Thread(target=server) thread_server = Thread(target=server)
thread_server.start() thread_server.start()
if GUI:
gui()
def server_process(work_count=4): def server_process(work_count=4):
with ProcessPoolExecutor(work_count) as pool: with ProcessPoolExecutor(work_count) as pool:
for i in range(work_count): for i in range(work_count):
pool.submit(server()) pool.submit(server())
if __name__ == "__main__": if __name__ == "__main__":
DEBUG = config.settings("Debug", "DEBUG") DEBUG = config.settings("Debug", "DEBUG")
if DEBUG: if DEBUG:
@ -39,4 +47,3 @@ if __name__ == "__main__":
main() main()
else: else:
running() running()

Loading…
Cancel
Save