diff --git a/plugins/native-ui/config.py b/plugins/native-ui/config.py new file mode 100644 index 0000000..b0273fa --- /dev/null +++ b/plugins/native-ui/config.py @@ -0,0 +1,5 @@ +# -*- coding: utf-8 -*- +import os + +BASE_PATH = os.path.realpath(os.getcwd()) +LOG_PATH = os.path.join(BASE_PATH, 'log') diff --git a/plugins/native-ui/designer/native-ui.fbp b/plugins/native-ui/designer/native-ui.fbp new file mode 100644 index 0000000..30f1594 --- /dev/null +++ b/plugins/native-ui/designer/native-ui.fbp @@ -0,0 +1,301 @@ + + + + + ; + Python + 1 + source_name + 0 + 0 + res + UTF-8 + connect + ui_base + 1000 + none + + 1 + 0 + native-ui + + . + + 1 + 1 + 1 + 1 + UI + 0 + 0 + 0 + + 0 + wxAUI_MGR_DEFAULT + + wxBOTH + + 1 + 0 + 1 + impl_virtual + + + + 0 + wxID_ANY + + + ConfigFrame + + 500,300 + wxDEFAULT_FRAME_STYLE + ; ; forward_declare + 设置 + + 0 + + + wxTAB_TRAVERSAL + 1 + + + 0 + wxAUI_MGR_DEFAULT + + wxBOTH + + 1 + 0 + 1 + impl_virtual + + + + 0 + wxID_ANY + + + RoomFrame + + 750,650 + wxDEFAULT_FRAME_STYLE + ; ; forward_declare + 房间 + + 0 + + + wxTAB_TRAVERSAL + 1 + + + bSizer4 + wxHORIZONTAL + none + + 5 + wxEXPAND + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + + 1 + self.chat_web_view = wx.html2.WebView.New(self) + + 1 + + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + wxID_ANY + import wx.html2 + + 0 + + + 0 + + 1 + chat_web_view + 1 + + + protected + 1 + + Resizable + + 1 + + ; ; forward_declare + 0 + + + + + + + + 5 + wxEXPAND + 1 + + + bSizer5 + wxVERTICAL + none + + 5 + wxEXPAND + 4 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + "醒目留言" "" + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + + 1 + m_listBox2 + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + 5 + wxEXPAND + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + "礼物" "" + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + + 1 + m_listBox3 + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + diff --git a/plugins/native-ui/designer/ui_base.py b/plugins/native-ui/designer/ui_base.py new file mode 100644 index 0000000..5da666a --- /dev/null +++ b/plugins/native-ui/designer/ui_base.py @@ -0,0 +1,70 @@ +# -*- coding: utf-8 -*- + +########################################################################### +## Python code generated with wxFormBuilder (version 4.1.0-0-g733bf3d) +## http://www.wxformbuilder.org/ +## +## PLEASE DO *NOT* EDIT THIS FILE! +########################################################################### + +import wx +import wx.xrc +import wx.html2 + +########################################################################### +## Class ConfigFrame +########################################################################### + +class ConfigFrame ( wx.Frame ): + + def __init__( self, parent ): + wx.Frame.__init__ ( self, parent, id = wx.ID_ANY, title = u"设置", pos = wx.DefaultPosition, size = wx.Size( 500,300 ), style = wx.DEFAULT_FRAME_STYLE|wx.TAB_TRAVERSAL ) + + self.SetSizeHints( wx.DefaultSize, wx.DefaultSize ) + + + self.Centre( wx.BOTH ) + + def __del__( self ): + pass + + +########################################################################### +## Class RoomFrame +########################################################################### + +class RoomFrame ( wx.Frame ): + + def __init__( self, parent ): + wx.Frame.__init__ ( self, parent, id = wx.ID_ANY, title = u"房间", pos = wx.DefaultPosition, size = wx.Size( 750,650 ), style = wx.DEFAULT_FRAME_STYLE|wx.TAB_TRAVERSAL ) + + self.SetSizeHints( wx.DefaultSize, wx.DefaultSize ) + + bSizer4 = wx.BoxSizer( wx.HORIZONTAL ) + + self.chat_web_view = wx.html2.WebView.New(self) + bSizer4.Add( self.chat_web_view, 1, wx.EXPAND, 5 ) + + bSizer5 = wx.BoxSizer( wx.VERTICAL ) + + m_listBox2Choices = [ u"醒目留言" ] + self.m_listBox2 = wx.ListBox( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, m_listBox2Choices, 0 ) + bSizer5.Add( self.m_listBox2, 4, wx.EXPAND, 5 ) + + m_listBox3Choices = [ u"礼物" ] + self.m_listBox3 = wx.ListBox( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, m_listBox3Choices, 0 ) + bSizer5.Add( self.m_listBox3, 1, wx.EXPAND, 5 ) + + + bSizer4.Add( bSizer5, 1, wx.EXPAND, 5 ) + + + self.SetSizer( bSizer4 ) + self.Layout() + + self.Centre( wx.BOTH ) + + def __del__( self ): + pass + + diff --git a/plugins/native-ui/log/.gitkeep b/plugins/native-ui/log/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/plugins/native-ui/main.pyw b/plugins/native-ui/main.pyw new file mode 100755 index 0000000..d3f3d09 --- /dev/null +++ b/plugins/native-ui/main.pyw @@ -0,0 +1,68 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +import asyncio +import logging.handlers +import os +import sys +from typing import * + +import wxasync + +import config +import designer.ui_base + +logger = logging.getLogger('native-ui') + +app: Optional[wxasync.WxAsyncApp] = None + + +async def main(): + try: + await init() + await run() + finally: + await shut_down() + return 0 + + +async def init(): + init_logging() + + global app + app = wxasync.WxAsyncApp() + + # TODO 测试 + frame = designer.ui_base.RoomFrame(None) + frame.chat_web_view.LoadURL('http://localhost:12450/room/test?minGiftPrice=0&showGiftName=true&lang=zh') + frame.Show() + + app.SetTopWindow(frame) + + +def init_logging(): + filename = os.path.join(config.LOG_PATH, 'native-ui.log') + stream_handler = logging.StreamHandler() + file_handler = logging.handlers.TimedRotatingFileHandler( + filename, encoding='utf-8', when='midnight', backupCount=7, delay=True + ) + logging.basicConfig( + format='{asctime} {levelname} [{name}]: {message}', + style='{', + level=logging.INFO, + # level=logging.DEBUG, + handlers=[stream_handler, file_handler], + ) + + +async def run(): + logger.info('Running event loop') + await app.MainLoop() + logger.info('Start to shut down') + + +async def shut_down(): + pass + + +if __name__ == '__main__': + sys.exit(asyncio.run(main())) diff --git a/plugins/native-ui/requirements.txt b/plugins/native-ui/requirements.txt new file mode 100644 index 0000000..e8c6f1b --- /dev/null +++ b/plugins/native-ui/requirements.txt @@ -0,0 +1,2 @@ +wxasync==0.49 +wxPython==4.2.1