mirror of
https://github.com/smallevilbeast/ntchat.git
synced 2025-05-23 05:29:43 +08:00
更新send_text_ui例子
This commit is contained in:
parent
89ea755606
commit
734eab020e
|
@ -146,7 +146,7 @@ except KeyboardInterrupt:
|
|||
# -*- coding: utf8 -*-
|
||||
import xcgui
|
||||
import ntchat
|
||||
from xcgui import XApp, XWindow
|
||||
from xcgui import XApp, XWindow, RunUiThread
|
||||
|
||||
|
||||
class NtChatWindow(XWindow):
|
||||
|
@ -171,6 +171,8 @@ class NtChatWindow(XWindow):
|
|||
def on_btn_open_clicked(self, sender, _):
|
||||
self.wechat_instance = ntchat.WeChat()
|
||||
self.wechat_instance.open(smart=True)
|
||||
|
||||
# 监听所有通知消息
|
||||
self.wechat_instance.on(ntchat.MT_ALL, self.on_recv_message)
|
||||
|
||||
def on_btn_send_clicked(self, sender, _):
|
||||
|
@ -182,6 +184,7 @@ class NtChatWindow(XWindow):
|
|||
else:
|
||||
self.wechat_instance.send_text(self.edit_wxid.getText(), self.edit_content.getText())
|
||||
|
||||
@RunUiThread()
|
||||
def on_recv_message(self, wechat, message):
|
||||
text = self.edit_log.getText()
|
||||
text += "\n"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import xcgui
|
||||
import ntchat
|
||||
from xcgui import XApp, XWindow
|
||||
from xcgui import XApp, XWindow, RunUiThread
|
||||
|
||||
|
||||
class NtChatWindow(XWindow):
|
||||
|
@ -38,6 +38,7 @@ class NtChatWindow(XWindow):
|
|||
else:
|
||||
self.wechat_instance.send_text(self.edit_wxid.getText(), self.edit_content.getText())
|
||||
|
||||
@RunUiThread()
|
||||
def on_recv_message(self, wechat, message):
|
||||
text = self.edit_log.getText()
|
||||
text += "\n"
|
||||
|
|
|
@ -263,7 +263,5 @@ async def send_gif(model: models.SendPatReqModel):
|
|||
return response_json(1, data)
|
||||
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
uvicorn.run(app=app, host='0.0.0.0', port=8000)
|
||||
|
|
Loading…
Reference in New Issue
Block a user