Skip to content

Commit

Permalink
版本推进至0.10.10
Browse files Browse the repository at this point in the history
+ 插件托盘现在存在Tcl主循环
  • Loading branch information
lunzhiPenxil committed Sep 19, 2022
1 parent 4b242bc commit cefe28b
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 6 deletions.
4 changes: 2 additions & 2 deletions OlivOS/infoAPI.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
import OlivOS


OlivOS_Version = '0.10.9'
OlivOS_SVN = 109
OlivOS_Version = '0.10.10'
OlivOS_SVN = 110

# Compatible <= Plugin[compatible_svn] : Compatible
# OldCompatible <= Plugin[compatible_svn] < Compatible : OldCompatible Warn
Expand Down
2 changes: 1 addition & 1 deletion OlivOS/nativeWinUIAPI.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def run(self):
self.UIObject['main_tk'].mainloop()

def process_msg(self):
self.UIObject['main_tk'].after(50,self.process_msg)
self.UIObject['main_tk'].after(50, self.process_msg)
self.mainrun()

def mainrun(self):
Expand Down
28 changes: 25 additions & 3 deletions OlivOS/pluginAPI.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
'''

import multiprocessing
import platform
import threading
import time
import datetime
Expand All @@ -25,6 +26,8 @@
import traceback
import zipfile
import shutil
if platform.system() == 'Windows':
import tkinter

import OlivOS

Expand Down Expand Up @@ -67,14 +70,31 @@ def __init__(self, Proc_name = 'native_plugin', scan_interval = 0.001, dead_inte
self.Proc_config['step_to_restart'] = restart_gate
self.Proc_data['plugin_func_dict'] = plugin_func_dict
self.Proc_data['bot_info_dict'] = bot_info_dict
self.Proc_data['main_tk'] = None
self.plugin_models_dict = {}
self.plugin_models_call_list = []
self.tx_queue = []
self.menu_queue = []

class rx_packet(object):
def __init__(self, sdk_event):
self.sdk_event = sdk_event

def __init_GUI(self):
if platform.system() == 'Windows':
self.Proc_data['main_tk'] = tkinter.Tk()
self.Proc_data['main_tk'].withdraw()
self.Proc_data['main_tk'].iconbitmap('./resource/tmp_favoricon.ico')
self.__update_GUI()
self.Proc_data['main_tk'].mainloop()

def __update_GUI(self):
if platform.system() == 'Windows':
self.Proc_data['main_tk'].after(50, self.__update_GUI)
if len(self.menu_queue) > 0:
rx_packet_data = self.menu_queue.pop(0)
self.run_plugin(rx_packet_data)

def run(self):
releaseDir('./plugin')
releaseDir('./plugin/app')
Expand All @@ -84,6 +104,7 @@ def run(self):
releaseDir('./lib')
releaseDir('./lib/Lib')
releaseDir('./lib/DLLs')
threading.Thread(target = self.__init_GUI).start()
#self.set_check_update()
self.sendPluginList()
time.sleep(1) # 此处延迟用于在终端第一次启动时等待终端初始化,避免日志丢失,后续需要用异步(控制包流程)方案替代
Expand Down Expand Up @@ -112,9 +133,7 @@ def run(self):
self.run_plugin_func(None, 'save')
self.Proc_info.control_queue.put(OlivOS.API.Control.packet('init_type', 'update_replace'), block=False)
elif rx_packet_data.action == 'send':
t_run_plugin = None
t_run_plugin = threading.Thread(target=self.run_plugin, args=(rx_packet_data,))
t_run_plugin.start()
self.menu_queue.append(rx_packet_data)
else:
if self.Proc_config['treading_mode'] == 'none':
self.run_plugin(rx_packet_data.sdk_event)
Expand All @@ -138,6 +157,9 @@ def set_check_update(self):
def get_plugin_list(self):
return self.plugin_models_call_list

def get_main_root(self):
return self.Proc_data['main_tk']

def run_plugin(self, sdk_event):
plugin_event = OlivOS.API.Event(sdk_event, self.log)
plugin_event_bot_hash = OlivOS.API.getBotHash(
Expand Down

0 comments on commit cefe28b

Please sign in to comment.